Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4c2cb197
authored
Mar 04, 2025
by
iqbal
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
pembaruan validator dan input group by iqbal
2 parents
62e296c8
bb463100
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
280 additions
and
41 deletions
.gitignore
opensipkd/base/__init__.py
opensipkd/base/reports/Group.jrxml
opensipkd/base/views/departemen.py
opensipkd/base/views/provinsi.py
opensipkd/base/views/user.py
.gitignore
View file @
4c2cb19
...
...
@@ -5,6 +5,7 @@ __pycache__/
.vs/
.vscode/
base.ini
# C extensions
*.so
...
...
opensipkd/base/__init__.py
View file @
4c2cb19
...
...
@@ -698,9 +698,9 @@ def main(global_config, **settings):
if
'localization'
not
in
settings
:
settings
[
'localization'
]
=
'id_ID.UTF-8'
locale
.
setlocale
(
locale
.
LC_ALL
,
settings
[
'localization'
])
if
'timezone'
not
in
settings
:
settings
[
'timezone'
]
=
DefaultTimeZone
#
locale.setlocale(locale.LC_ALL, settings['localization'])
#
if 'timezone' not in settings:
#
settings['timezone'] = DefaultTimeZone
# modules = get_modules(settings)
# from importlib import import_module
...
...
opensipkd/base/reports/Group.jrxml
0 → 100644
View file @
4c2cb19
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.5.final using JasperReports Library version 6.20.5-3efcf2e67f959db3888d79f73dde2dbd7acb4f8e -->
<jasperReport
xmlns=
"http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name=
"Group"
pageWidth=
"595"
pageHeight=
"842"
columnWidth=
"555"
leftMargin=
"20"
rightMargin=
"20"
topMargin=
"20"
bottomMargin=
"20"
uuid=
"6630eb66-846c-4826-9d1e-493d584e9622"
>
<property
name=
"com.jaspersoft.studio.data.defaultdataadapter"
value=
"groups_csv"
/>
<parameter
name=
"judul1"
class=
"java.lang.String"
>
<defaultValueExpression>
<![CDATA["PEMERINTAH KABUPATEN KUNINGAN"]]>
</defaultValueExpression>
</parameter>
<queryString
language=
"csv"
>
<![CDATA[]]>
</queryString>
<field
name=
"group_name"
class=
"java.lang.String"
/>
<field
name=
"description"
class=
"java.lang.String"
/>
<field
name=
"member_count"
class=
"java.lang.Integer"
/>
<background>
<band
splitType=
"Stretch"
/>
</background>
<title>
<band
height=
"123"
splitType=
"Stretch"
>
<staticText>
<reportElement
x=
"143"
y=
"49"
width=
"269"
height=
"30"
uuid=
"5b7637d7-75f9-4fcb-83f0-3199ee657145"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"14"
isBold=
"true"
/>
</textElement>
<text>
<![CDATA[BADAN PENDAPATAN DAERAH]]>
</text>
</staticText>
<staticText>
<reportElement
x=
"186"
y=
"67"
width=
"182"
height=
"30"
uuid=
"a139563f-3249-4b06-9842-377b1c0e9730"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
isBold=
"true"
/>
</textElement>
<text>
<![CDATA[ALAMAT DEPARTEMEN BARIS 1]]>
</text>
</staticText>
<line>
<reportElement
x=
"10"
y=
"90"
width=
"551"
height=
"2"
uuid=
"86ddd920-2fb3-4145-9b92-a35c943f22d1"
/>
<graphicElement>
<pen
lineWidth=
"4.0"
/>
</graphicElement>
</line>
<image>
<reportElement
x=
"40"
y=
"14"
width=
"71"
height=
"71"
uuid=
"d7dac611-e67c-45fd-b795-9d704ae37822"
/>
<imageExpression>
<![CDATA["C:/Users/hamzah/Downloads/pngegg.png"]]>
</imageExpression>
</image>
<staticText>
<reportElement
x=
"20"
y=
"100"
width=
"191"
height=
"21"
uuid=
"073f879a-0d32-48b7-924f-1c0068f82a49"
/>
<textElement>
<font
size=
"14"
isBold=
"true"
/>
</textElement>
<text>
<![CDATA[DAFTAR GROUP APLIKASI]]>
</text>
</staticText>
<textField>
<reportElement
x=
"111"
y=
"30"
width=
"340"
height=
"30"
uuid=
"821c62e9-865c-4586-9e53-ff72d03d4189"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"16"
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{judul1}]]>
</textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band
splitType=
"Stretch"
/>
</pageHeader>
<columnHeader>
<band
height=
"24"
splitType=
"Stretch"
>
<staticText>
<reportElement
mode=
"Opaque"
x=
"10"
y=
"2"
width=
"91"
height=
"21"
backcolor=
"#F7E516"
uuid=
"8b09b79a-77ce-4c05-87ed-0a9de42057b7"
/>
<box>
<topPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<leftPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<bottomPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<rightPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
</box>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"12"
isBold=
"true"
/>
</textElement>
<text>
<![CDATA[Group]]>
</text>
</staticText>
<staticText>
<reportElement
mode=
"Opaque"
x=
"101"
y=
"2"
width=
"369"
height=
"21"
backcolor=
"#F7E516"
uuid=
"b2839bdc-e0cc-47b2-8a5e-4890a6b3daca"
/>
<box>
<topPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<leftPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<bottomPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<rightPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
</box>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"12"
isBold=
"true"
/>
</textElement>
<text>
<![CDATA[Deskripsi]]>
</text>
</staticText>
<staticText>
<reportElement
mode=
"Opaque"
x=
"470"
y=
"2"
width=
"91"
height=
"21"
backcolor=
"#F7E516"
uuid=
"a2a310fd-6670-49bb-8a41-b2adb8eb1048"
/>
<box>
<topPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<leftPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<bottomPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<rightPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
</box>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"12"
isBold=
"true"
/>
</textElement>
<text>
<![CDATA[Anggota]]>
</text>
</staticText>
</band>
</columnHeader>
<detail>
<band
height=
"21"
splitType=
"Stretch"
>
<textField>
<reportElement
x=
"470"
y=
"0"
width=
"91"
height=
"21"
uuid=
"3e05ad54-5bbb-4211-ad68-7bd5c9c652d9"
/>
<box>
<topPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<leftPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<bottomPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<rightPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
</box>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
/>
<textFieldExpression>
<![CDATA[$F{member_count}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"101"
y=
"0"
width=
"369"
height=
"21"
uuid=
"0f36284e-eadb-4603-b0f2-e2a68b7e508a"
/>
<box>
<topPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<leftPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<bottomPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<rightPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
</box>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
/>
<textFieldExpression>
<![CDATA[$F{description}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"10"
y=
"0"
width=
"91"
height=
"21"
uuid=
"7a46ccdd-d3f8-49d9-837c-f40c80ec869c"
/>
<box>
<topPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<leftPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<bottomPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<rightPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
</box>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
/>
<textFieldExpression>
<![CDATA[$F{group_name}]]>
</textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band
height=
"45"
splitType=
"Stretch"
/>
</columnFooter>
<pageFooter>
<band
height=
"54"
splitType=
"Stretch"
/>
</pageFooter>
<summary>
<band
height=
"42"
splitType=
"Stretch"
/>
</summary>
</jasperReport>
opensipkd/base/views/departemen.py
View file @
4c2cb19
...
...
@@ -39,41 +39,79 @@ def departemen_widget_form():
{
"js"
:
"opensipkd.base:static/js/form/departemen_form.js"
}),
)
# Mencoba membuat validator sendiri
class
Validator
:
def
__init__
(
self
,
user
):
self
.
user
=
user
# Validator nama
class
NameValidator
(
Validator
):
def
__call__
(
self
,
node
,
value
):
name
=
value
if
(
len
(
name
)
>
128
):
raise
colander
.
Invalid
(
node
,
_
(
'Maksimal 128 karakter'
))
@colander.deferred
def
name_validator
(
node
,
kw
):
return
NameValidator
(
kw
[
'user'
])
class
AddSchema
(
colander
.
Schema
):
parent_id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
widget
=
widget
.
HiddenWidget
(),
oid
=
"parent_id"
,
missing
=
colander
.
drop
,
)
widget
=
widget
.
HiddenWidget
(),
oid
=
"parent_id"
,
missing
=
colander
.
drop
,)
parent_nm
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
colander
.
String
(),
missing
=
colander
.
drop
,
widget
=
widget
.
AutocompleteInputWidget
(
size
=
60
,
min_length
=
3
,
requirements
=
((
"typeahead"
,
None
),
(
"deform"
,
None
),
requirements
=
((
"typeahead"
,
None
),
(
"deform"
,
None
),
{
"js"
:
"opensipkd.base:static/js/form/departemen.js"
}),
# options={"allowClear": True}
),
oid
=
"parent_nm"
,
title
=
"Induk"
)
oid
=
"parent_nm"
,
title
=
"Induk"
)
parent_kd
=
colander
.
SchemaNode
(
colander
.
String
(),
parent_kd
=
colander
.
SchemaNode
(
colander
.
String
(),
widget
=
widget
.
TextInputWidget
(
css_class
=
"readonly"
),
missing
=
colander
.
drop
,
oid
=
"parent_kd"
,
title
=
"Kode Induk"
)
missing
=
colander
.
drop
,
oid
=
"parent_kd"
,
title
=
"Kode Induk"
)
kode
=
colander
.
SchemaNode
(
colander
.
String
(),
validator
=
colander
.
Length
(
max
=
32
),
oid
=
"kode"
)
kode
=
colander
.
SchemaNode
(
colander
.
String
(),
validator
=
colander
.
Length
(
max
=
32
,
max_err
=
'Maksimal 32 karakter'
),
oid
=
"kode"
)
nama
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"nama"
)
nama
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"nama"
,
validator
=
colander
.
Length
(
min
=
1
,
max
=
128
,
max_err
=
"Maksimal 128 karakter"
,
min_err
=
'Minimal 1 karakter'
))
singkat
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
oid
=
"singkat"
)
singkat
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
oid
=
"singkat"
,
validator
=
colander
.
Length
(
max
=
32
,
max_err
=
'Maksimal 32 karakter'
))
kategori
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
oid
=
"kategori"
)
kategori
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
oid
=
"kategori"
,
validator
=
colander
.
Length
(
max
=
32
,
max_err
=
'Maksimal 32 karakter'
))
alamat
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
oid
=
"alamat"
)
company_id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
alamat
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
oid
=
"alamat"
,
validator
=
colander
.
Length
(
max
=
255
,
max_err
=
'Maksimal 255 karakter'
))
company_id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
widget
=
company_widget
,
missing
=
colander
.
drop
,
oid
=
"company_id"
)
...
...
opensipkd/base/views/provinsi.py
View file @
4c2cb19
...
...
@@ -6,6 +6,7 @@ from pyramid.view import (view_config, )
from
.
import
widget_os
from
opensipkd.models
import
DBSession
,
ResProvinsi
,
kategori_provinsi
from
..views
import
BaseView
_
=
TranslationStringFactory
(
"opensipkd"
)
SESS_ADD_FAILED
=
'Tambah provinsi gagal'
...
...
@@ -19,7 +20,8 @@ def provinsi_widget(node, kw):
slave
=
node
and
hasattr
(
node
,
'slave'
)
and
node
.
slave
or
""
values
.
insert
(
0
,
(
""
,
"Pilih Propinsi..."
))
readonly
=
kw
.
get
(
"readonly"
,
False
)
return
widget_os
.
Select2MsWidget
(
values
=
values
,
return
widget_os
.
Select2MsWidget
(
values
=
values
,
readonly
=
readonly
,
url
=
url
,
slave
=
slave
,
...
...
@@ -27,26 +29,42 @@ def provinsi_widget(node, kw):
class
AddSchema
(
colander
.
Schema
):
kode
=
colander
.
SchemaNode
(
colander
.
String
(),
kode
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"kode"
,
validator
=
colander
.
Length
(
max
=
32
),
)
kategori
=
colander
.
SchemaNode
(
colander
.
String
(),
validator
=
colander
.
Length
(
max
=
32
,
max_err
=
'Maksimal 32 karakter'
))
kategori
=
colander
.
SchemaNode
(
colander
.
String
(),
widget
=
widget
.
SelectWidget
(
values
=
kategori_provinsi
),
validator
=
colander
.
Length
(
max
=
32
),
oid
=
"kode"
)
validator
=
colander
.
Length
(
max
=
32
,
max_err
=
'Maksimal 32 karakter'
),
oid
=
"kode"
)
nama
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"nama"
,
validator
=
colander
.
Length
(
max
=
128
,
max_err
=
'Maksimal 128 karakter'
))
nama
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"nama"
)
ibu_kota
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"nama"
,
missing
=
colander
.
drop
)
ibu_kota
=
colander
.
SchemaNode
(
colander
.
String
(),
oid
=
"nama"
,
missing
=
colander
.
drop
,
validator
=
colander
.
Length
(
max
=
64
,
max_err
=
'Maksimal 64 karakter'
))
class
EditSchema
(
AddSchema
):
id
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
id
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
widget
=
widget
.
HiddenWidget
(
readonly
=
True
),
visible
=
False
)
class
ListSchema
(
colander
.
Schema
):
id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
title
=
_
(
"action"
,
default
=
"Action"
))
id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
title
=
_
(
"action"
,
default
=
"Action"
))
kode
=
colander
.
SchemaNode
(
colander
.
String
(),
width
=
100
)
nama
=
colander
.
SchemaNode
(
colander
.
String
())
ibu_kota
=
colander
.
SchemaNode
(
colander
.
String
())
...
...
@@ -69,13 +87,14 @@ class ViewProvinsi(BaseView):
def
form_validator
(
self
,
form
,
value
):
def
err_kode
():
raise
colander
.
Invalid
(
form
,
'Kode
%
s sudah digunakan oleh
%
s'
%
(
value
[
'kode'
],
found
.
nama
))
raise
colander
.
Invalid
(
form
,
'Kode
%
s sudah digunakan oleh
%
s'
%
(
value
[
'kode'
],
found
.
nama
))
def
err_nama
():
raise
colander
.
Invalid
(
form
,
'Uraian
%
s sudah digunakan oleh kode
%
s'
%
(
value
[
'nama'
],
found
.
kode
))
raise
colander
.
Invalid
(
form
,
'Uraian
%
s sudah digunakan oleh kode
%
s'
%
(
value
[
'nama'
],
found
.
kode
))
if
'id'
in
form
.
request
.
matchdict
:
uid
=
form
.
request
.
matchdict
[
'id'
]
...
...
opensipkd/base/views/user.py
View file @
4c2cb19
...
...
@@ -273,6 +273,13 @@ class EmailValidator(colander.Email, Validator):
if
found
and
(
not
self
.
user
or
self
.
user
.
email
!=
found
.
email
):
email_found
()
# Cek karakter
def
email_max
():
raise
colander
.
Invalid
(
node
,
_
(
'Maksimal 100 karakter'
))
if
(
len
(
email
)
>
100
):
email_max
()
REGEX_ONLY_CONTAIN
=
re
.
compile
(
'([A-Za-z0-9-]*)'
)
REGEX_BEGIN_END_ALPHANUMERIC
=
re
.
compile
(
'^[A-Za-z0-9]+(?:[-][A-Za-z0-9]+)*$'
)
...
...
@@ -281,6 +288,15 @@ REGEX_BEGIN_END_ALPHANUMERIC = re.compile('^[A-Za-z0-9]+(?:[-][A-Za-z0-9]+)*$')
class
UsernameValidator
(
Validator
):
def
__call__
(
self
,
node
,
value
):
username
=
value
# Fungsi menampilkan error pada field form
def
username_max
():
raise
colander
.
Invalid
(
node
,
_
(
'Maksimal 128 karakter'
))
# Jika karakter melebihi 128 karakter maka, panggil fungsi
if
(
len
(
username
)
>
128
):
username_max
()
if
self
.
user
and
self
.
user
.
user_name
==
username
:
return
match
=
REGEX_ONLY_CONTAIN
.
search
(
username
)
...
...
@@ -333,20 +349,34 @@ def save_user(values, user, row=None):
class
AddSchema
(
colander
.
Schema
):
email
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
_
(
'Email'
),
colander
.
String
(),
title
=
_
(
'Email'
),
validator
=
email_validator
)
user_name
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
_
(
'Username'
),
user_name
=
colander
.
SchemaNode
(
colander
.
String
(),
title
=
_
(
'Username tetst'
),
validator
=
username_validator
)
groups
=
colander
.
SchemaNode
(
colander
.
Set
(),
widget
=
group_widget
,
title
=
_
(
'Group'
))
colander
.
Set
(),
widget
=
group_widget
,
title
=
_
(
'Group'
))
is_api_key
=
colander
.
SchemaNode
(
colander
.
String
(),
widget
=
api_key_widget
,
title
=
_
(
'API Key'
),
colander
.
String
(),
widget
=
api_key_widget
,
title
=
_
(
'API Key'
),
missing
=
colander
.
drop
)
password
=
colander
.
SchemaNode
(
colander
.
String
(),
widget
=
widget
.
CheckedPasswordWidget
(),
colander
.
String
(),
widget
=
widget
.
CheckedPasswordWidget
(),
missing
=
colander
.
drop
)
company_id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
widget
=
company_widget
,
colander
.
Integer
(),
widget
=
company_widget
,
title
=
"Company"
,
missing
=
colander
.
drop
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment