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 c67ff093
authored
Mar 25, 2025
by
iqbal
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Penambahan alamat pada jasper dan perbaikan menu user area
1 parent
8373a07c
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
131 additions
and
36 deletions
opensipkd/base/reports/Group.jrxml
opensipkd/base/reports/desa.jrxml
opensipkd/base/reports/eselon.jrxml
opensipkd/base/reports/kabupaten.jrxml
opensipkd/base/reports/partner1.jrxml
opensipkd/base/reports/user_area.jrxml
opensipkd/base/views/dati2.py
opensipkd/base/views/desa.py
opensipkd/base/views/eselon.py
opensipkd/base/views/groups.py
opensipkd/base/views/partner.py
opensipkd/base/views/user_area.py
opensipkd/base/reports/Group.jrxml
View file @
c67ff09
...
...
@@ -7,6 +7,7 @@
<defaultValueExpression>
<![CDATA["PEMERINTAH KABUPATEN KUNINGAN"]]>
</defaultValueExpression>
</parameter>
<parameter
name=
"logo"
class=
"java.lang.String"
/>
<parameter
name=
"alamat_lengkap"
class=
"java.lang.String"
/>
<queryString>
<![CDATA[select * FROM groups]]>
</queryString>
...
...
@@ -34,9 +35,9 @@
<band
splitType=
"Stretch"
/>
</background>
<title>
<band
height=
"10
0
"
splitType=
"Stretch"
>
<band
height=
"10
1
"
splitType=
"Stretch"
>
<staticText>
<reportElement
x=
"14
3"
y=
"49
"
width=
"269"
height=
"30"
uuid=
"5b7637d7-75f9-4fcb-83f0-3199ee657145"
/>
<reportElement
x=
"14
0"
y=
"32
"
width=
"269"
height=
"30"
uuid=
"5b7637d7-75f9-4fcb-83f0-3199ee657145"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"14"
isBold=
"true"
/>
</textElement>
...
...
@@ -53,12 +54,19 @@
<imageExpression>
<![CDATA[$P{logo}]]>
</imageExpression>
</image>
<textField>
<reportElement
x=
"
230"
y=
"19"
width=
"100
"
height=
"30"
uuid=
"32f184cc-d09f-44cc-9637-84400c055f5e"
/>
<reportElement
x=
"
140"
y=
"2"
width=
"269
"
height=
"30"
uuid=
"32f184cc-d09f-44cc-9637-84400c055f5e"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"16"
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{judul}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"10"
y=
"62"
width=
"551"
height=
"30"
uuid=
"eac58289-71ef-45cd-8d35-17d219ef7847"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{alamat_lengkap}]]>
</textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
...
...
opensipkd/base/reports/desa.jrxml
View file @
c67ff09
...
...
@@ -5,6 +5,7 @@
<property
name=
"com.jaspersoft.studio.data.sql.tables"
value=
""
/>
<parameter
name=
"logo"
class=
"java.lang.String"
/>
<parameter
name=
"judul"
class=
"java.lang.String"
/>
<parameter
name=
"alamat_lengkap"
class=
"java.lang.String"
/>
<queryString>
<![CDATA[select * FROM res_desa JOIN res_kecamatan ON res_desa.kecamatan_id = res_kecamatan.id;]]>
</queryString>
...
...
@@ -112,9 +113,9 @@
<band
splitType=
"Stretch"
/>
</background>
<title>
<band
height=
"9
5
"
splitType=
"Stretch"
>
<band
height=
"9
6
"
splitType=
"Stretch"
>
<staticText>
<reportElement
x=
"1
43"
y=
"30"
width=
"26
9"
height=
"30"
uuid=
"458b62a6-e929-4690-a8a0-c260967c1d92"
/>
<reportElement
x=
"1
10"
y=
"30"
width=
"31
9"
height=
"30"
uuid=
"458b62a6-e929-4690-a8a0-c260967c1d92"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"14"
isBold=
"true"
/>
</textElement>
...
...
@@ -137,6 +138,13 @@
</textElement>
<textFieldExpression>
<![CDATA[$P{judul}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"0"
y=
"50"
width=
"551"
height=
"30"
uuid=
"a1b164d9-0cd8-4f6f-807b-506312e81fd9"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{alamat_lengkap}]]>
</textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
...
...
@@ -198,14 +206,19 @@
<textFieldExpression>
<![CDATA[$F{kode}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"161"
y=
"0"
width=
"210"
height=
"21"
uuid=
"e07771a9-7326-46ef-b09c-e0b5a02dad3c"
/>
<reportElement
x=
"161"
y=
"0"
width=
"210"
height=
"21"
uuid=
"e07771a9-7326-46ef-b09c-e0b5a02dad3c"
>
<property
name=
"com.jaspersoft.studio.unit.rightIndent"
value=
"pixel"
/>
<property
name=
"com.jaspersoft.studio.unit.leftIndent"
value=
"px"
/>
</reportElement>
<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"
/>
<textElement
textAlignment=
"Left"
verticalAlignment=
"Middle"
>
<paragraph
leftIndent=
"10"
/>
</textElement>
<textFieldExpression>
<![CDATA[$F{nama}]]>
</textFieldExpression>
</textField>
<textField>
...
...
opensipkd/base/reports/eselon.jrxml
View file @
c67ff09
...
...
@@ -5,6 +5,7 @@
<property
name=
"com.jaspersoft.studio.data.sql.tables"
value=
""
/>
<parameter
name=
"logo"
class=
"java.lang.String"
/>
<parameter
name=
"judul"
class=
"java.lang.String"
/>
<parameter
name=
"alamat_lengkap"
class=
"java.lang.String"
/>
<queryString>
<![CDATA[select * FROM eselon]]>
</queryString>
...
...
@@ -67,7 +68,7 @@
<band
splitType=
"Stretch"
/>
</background>
<title>
<band
height=
"
89
"
splitType=
"Stretch"
>
<band
height=
"
95
"
splitType=
"Stretch"
>
<staticText>
<reportElement
x=
"143"
y=
"30"
width=
"269"
height=
"30"
uuid=
"8be6d74b-7953-470f-8fbb-799d55a1f230"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
...
...
@@ -92,6 +93,13 @@
</textElement>
<textFieldExpression>
<![CDATA[$P{judul}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"0"
y=
"50"
width=
"551"
height=
"30"
uuid=
"1b5edd70-0a69-437b-8d36-d5fe76327040"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{alamat_lengkap}]]>
</textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
...
...
opensipkd/base/reports/kabupaten.jrxml
View file @
c67ff09
...
...
@@ -5,6 +5,7 @@
<property
name=
"com.jaspersoft.studio.data.sql.tables"
value=
""
/>
<parameter
name=
"logo"
class=
"java.lang.String"
/>
<parameter
name=
"judul"
class=
"java.lang.String"
/>
<parameter
name=
"alamat_lengkap"
class=
"java.lang.String"
/>
<queryString>
<![CDATA[select * FROM res_dati2 join res_provinsi ON res_dati2.provinsi_id = res_provinsi.id]]>
</queryString>
...
...
@@ -136,12 +137,19 @@
<imageExpression>
<![CDATA[$P{logo}]]>
</imageExpression>
</image>
<textField>
<reportElement
x=
"
240"
y=
"0"
width=
"100
"
height=
"30"
uuid=
"caa2d5c9-f7f6-4c74-a52b-8014d519c5c3"
/>
<reportElement
x=
"
143"
y=
"0"
width=
"269
"
height=
"30"
uuid=
"caa2d5c9-f7f6-4c74-a52b-8014d519c5c3"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"16"
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{judul}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"2"
y=
"48"
width=
"550"
height=
"30"
uuid=
"4cabc0db-0c35-4c0f-8e53-5723054d06af"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{alamat_lengkap}]]>
</textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
...
...
@@ -203,25 +211,33 @@
<textFieldExpression>
<![CDATA[$F{kode}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"161"
y=
"0"
width=
"210"
height=
"21"
uuid=
"042939e5-65d9-4170-b4d3-67f999964030"
/>
<reportElement
x=
"161"
y=
"0"
width=
"210"
height=
"21"
uuid=
"042939e5-65d9-4170-b4d3-67f999964030"
>
<property
name=
"com.jaspersoft.studio.unit.leftIndent"
value=
"px"
/>
</reportElement>
<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=
"Left"
verticalAlignment=
"Middle"
/>
<textElement
textAlignment=
"Left"
verticalAlignment=
"Middle"
>
<paragraph
leftIndent=
"10"
/>
</textElement>
<textFieldExpression>
<![CDATA[$F{nama}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"371"
y=
"0"
width=
"181"
height=
"21"
uuid=
"2db6a1ee-202a-4714-a0b6-ab4545981f01"
/>
<reportElement
x=
"371"
y=
"0"
width=
"181"
height=
"21"
uuid=
"2db6a1ee-202a-4714-a0b6-ab4545981f01"
>
<property
name=
"com.jaspersoft.studio.unit.leftIndent"
value=
"px"
/>
</reportElement>
<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=
"Left"
verticalAlignment=
"Middle"
/>
<textElement
textAlignment=
"Left"
verticalAlignment=
"Middle"
>
<paragraph
leftIndent=
"10"
/>
</textElement>
<textFieldExpression>
<![CDATA[$F{COLUMN_14}]]>
</textFieldExpression>
</textField>
</band>
...
...
opensipkd/base/reports/partner1.jrxml
View file @
c67ff09
...
...
@@ -5,6 +5,7 @@
<property
name=
"com.jaspersoft.studio.data.sql.tables"
value=
""
/>
<parameter
name=
"logo"
class=
"java.lang.String"
/>
<parameter
name=
"judul"
class=
"java.lang.String"
/>
<parameter
name=
"alamat_lengkap"
class=
"java.lang.String"
/>
<queryString>
<![CDATA[select * FROM partner]]>
</queryString>
...
...
@@ -209,8 +210,8 @@
<title>
<band
height=
"91"
splitType=
"Stretch"
>
<staticText>
<reportElement
x=
"
204"
y=
"40"
width=
"130"
height=
"2
0"
uuid=
"404cb1e0-9e9b-4d9e-9f12-7ae4ee60561f"
/>
<textElement>
<reportElement
x=
"
0"
y=
"30"
width=
"552"
height=
"3
0"
uuid=
"404cb1e0-9e9b-4d9e-9f12-7ae4ee60561f"
/>
<textElement
textAlignment=
"Center"
>
<font
size=
"14"
isBold=
"true"
/>
</textElement>
<text>
<![CDATA[DAFTAR PARTNER]]>
</text>
...
...
@@ -226,12 +227,19 @@
<imageExpression>
<![CDATA[$P{logo}]]>
</imageExpression>
</image>
<textField>
<reportElement
x=
"
220"
y=
"0"
width=
"100
"
height=
"30"
uuid=
"167de0fa-238f-4d7c-9bb8-8b282cb08dbd"
/>
<reportElement
x=
"
0"
y=
"0"
width=
"552
"
height=
"30"
uuid=
"167de0fa-238f-4d7c-9bb8-8b282cb08dbd"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"14"
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{judul}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"-6"
y=
"50"
width=
"551"
height=
"30"
uuid=
"d9376b77-97ac-43f7-8837-7cedc45a38a4"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{alamat_lengkap}]]>
</textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
...
...
@@ -306,14 +314,18 @@
<textFieldExpression>
<![CDATA[$F{kode}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"110"
y=
"0"
width=
"160"
height=
"21"
uuid=
"5eae21bc-8f4a-44e4-9e8a-66da6ee9de99"
/>
<reportElement
x=
"110"
y=
"0"
width=
"160"
height=
"21"
uuid=
"5eae21bc-8f4a-44e4-9e8a-66da6ee9de99"
>
<property
name=
"com.jaspersoft.studio.unit.leftIndent"
value=
"px"
/>
</reportElement>
<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"
/>
<textElement
textAlignment=
"Left"
verticalAlignment=
"Middle"
>
<paragraph
leftIndent=
"10"
/>
</textElement>
<textFieldExpression>
<![CDATA[$F{nama}]]>
</textFieldExpression>
</textField>
<textField>
...
...
@@ -330,6 +342,7 @@
<textField>
<reportElement
x=
"270"
y=
"0"
width=
"160"
height=
"21"
uuid=
"b00fbbe6-e991-4a59-837e-601a2462aebf"
>
<property
name=
"com.jaspersoft.studio.spreadsheet.connectionID"
value=
"add93502-c54f-4ef3-912a-338d7f0ff64b"
/>
<property
name=
"com.jaspersoft.studio.unit.leftIndent"
value=
"px"
/>
</reportElement>
<box>
<topPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
...
...
@@ -337,7 +350,9 @@
<bottomPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
<rightPen
lineWidth=
"1.0"
lineStyle=
"Solid"
lineColor=
"#000000"
/>
</box>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
/>
<textElement
textAlignment=
"Left"
verticalAlignment=
"Middle"
>
<paragraph
leftIndent=
"10"
/>
</textElement>
<textFieldExpression>
<![CDATA[$F{email}]]>
</textFieldExpression>
</textField>
</band>
...
...
opensipkd/base/reports/user_area.jrxml
View file @
c67ff09
...
...
@@ -5,7 +5,7 @@
<property
name=
"com.jaspersoft.studio.data.defaultdataadapter"
value=
"POSTGRES"
/>
<parameter
name=
"logo"
class=
"java.lang.String"
/>
<parameter
name=
"judul"
class=
"java.lang.String"
/>
<parameter
name=
"alamat"
class=
"java.lang.String"
/>
<parameter
name=
"alamat
_lengkap
"
class=
"java.lang.String"
/>
<queryString
language=
"SQL"
>
<![CDATA[select * from user_area join res_desa on user_area.desa_id = res_desa.id join users on user_area.user_id = users.id;]]>
</queryString>
...
...
@@ -157,12 +157,19 @@
<imageExpression>
<![CDATA[$P{logo}]]>
</imageExpression>
</image>
<textField>
<reportElement
x=
"
220"
y=
"0"
width=
"100
"
height=
"30"
uuid=
"f3b018df-9d30-4be3-837b-db47a83dfadc"
/>
<reportElement
x=
"
143"
y=
"0"
width=
"269
"
height=
"30"
uuid=
"f3b018df-9d30-4be3-837b-db47a83dfadc"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
size=
"16"
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{judul}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement
x=
"0"
y=
"50"
width=
"551"
height=
"30"
uuid=
"9d916137-3fc4-4759-b377-4b95c1bbfafc"
/>
<textElement
textAlignment=
"Center"
verticalAlignment=
"Middle"
>
<font
isBold=
"true"
/>
</textElement>
<textFieldExpression>
<![CDATA[$P{alamat_lengkap}]]>
</textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
...
...
opensipkd/base/views/dati2.py
View file @
c67ff09
...
...
@@ -93,6 +93,7 @@ class ViewDati2(BaseView):
logo
=
os
.
path
.
join
(
logo
,
'static'
,
'img'
,
'logo.png'
)
parameters
=
{
"judul"
:
get_params
(
'company'
,
"openSIPKD"
),
"alamat_lengkap"
:
get_params
(
'address'
,
"Bekasi"
),
"logo"
:
logo
}
print
(
parameters
)
...
...
opensipkd/base/views/desa.py
View file @
c67ff09
...
...
@@ -112,6 +112,7 @@ class ViewDesa(BaseView):
logo
=
os
.
path
.
join
(
logo
,
'static'
,
'img'
,
'logo.png'
)
parameters
=
{
"judul"
:
get_params
(
'company'
,
"openSIPKD"
),
"alamat_lengkap"
:
get_params
(
'address'
,
"Bekasi"
),
"logo"
:
logo
}
print
(
parameters
)
...
...
opensipkd/base/views/eselon.py
View file @
c67ff09
...
...
@@ -90,6 +90,7 @@ class Views(BaseView):
logo
=
os
.
path
.
join
(
logo
,
'static'
,
'img'
,
'logo.png'
)
parameters
=
{
"judul"
:
get_params
(
'company'
,
"openSIPKD"
),
"alamat_lengkap"
:
get_params
(
'address'
,
"Bekasi"
),
"logo"
:
logo
}
print
(
parameters
)
...
...
opensipkd/base/views/groups.py
View file @
c67ff09
...
...
@@ -83,6 +83,7 @@ class Views(BaseView):
logo
=
os
.
path
.
join
(
logo
,
'static'
,
'img'
,
'logo.png'
)
parameters
=
{
"judul"
:
get_params
(
'company'
,
"openSIPKD"
),
"alamat_lengkap"
:
get_params
(
'address'
,
"Bekasi"
),
"logo"
:
logo
}
print
(
parameters
)
...
...
opensipkd/base/views/partner.py
View file @
c67ff09
...
...
@@ -130,6 +130,7 @@ class ViewPartner(BaseView):
logo
=
os
.
path
.
join
(
logo
,
'static'
,
'img'
,
'logo.png'
)
parameters
=
{
"judul"
:
get_params
(
'company'
,
"openSIPKD"
),
"alamat_lengkap"
:
get_params
(
'address'
,
"Bekasi"
),
"logo"
:
logo
}
print
(
parameters
)
...
...
opensipkd/base/views/user_area.py
View file @
c67ff09
...
...
@@ -36,7 +36,7 @@ class ListSchema(colander.Schema):
@colander.deferred
def
desa_checkbox_widget
(
node
,
kw
):
values
=
kw
.
get
(
'desa_list'
,
[])
return
widget
.
CheckboxChoiceWidget
(
values
=
values
)
# Tetap menggunakan CheckboxChoiceWidget
return
widget
.
CheckboxChoiceWidget
(
values
=
values
)
def
single_choice_validator
(
node
,
value
):
"""Validator untuk memastikan hanya satu opsi yang dipilih."""
...
...
@@ -51,17 +51,26 @@ class AddSchema(colander.Schema):
title
=
"User"
,
)
desa_id
=
colander
.
SchemaNode
(
colander
.
Set
(),
# Kembali ke colander.Set()
colander
.
Set
(),
widget
=
desa_checkbox_widget
,
validator
=
single_choice_validator
,
# Tambahkan validator
validator
=
single_choice_validator
,
oid
=
"desa_id"
,
title
=
"Kelurahan/Desa"
,
)
class
EditSchema
(
AddSchema
):
id
=
colander
.
SchemaNode
(
colander
.
String
(),
id
=
colander
.
SchemaNode
(
colander
.
String
(),
missing
=
colander
.
drop
,
widget
=
widget
.
HiddenWidget
(
readonly
=
True
)
)
user_id
=
colander
.
SchemaNode
(
colander
.
Integer
(),
missing
=
colander
.
drop
,
widget
=
widget
.
HiddenWidget
(
readonly
=
True
))
widget
=
widget
.
SelectWidget
(
values
=
User
.
get_list
(),
readonly
=
True
),
# Ditampilkan, tetapi readonly
oid
=
"user_id"
,
title
=
"User"
,
)
class
Views
(
BaseView
):
def
__init__
(
self
,
request
):
...
...
@@ -76,7 +85,6 @@ class Views(BaseView):
path
=
os
.
path
.
dirname
(
path
)
self
.
report_file
=
os
.
path
.
join
(
path
,
'reports'
,
'user_area.jrxml'
)
# Mendapatkan path gambar
def
get_module_path
(
self
,
module_name
):
a
=
AssetResolver
(
module_name
)
resolver
=
a
.
resolve
(
''
)
...
...
@@ -88,6 +96,7 @@ class Views(BaseView):
logo
=
os
.
path
.
join
(
logo
,
'static'
,
'img'
,
'logo.png'
)
parameters
=
{
"judul"
:
get_params
(
'company'
,
"openSIPKD"
),
"alamat_lengkap"
:
get_params
(
'address'
,
"Bekasi"
),
"logo"
:
logo
}
filename
=
jasper_export
(
self
.
report_file
,
parameters
=
parameters
)
...
...
@@ -98,9 +107,9 @@ class Views(BaseView):
return
DBSession
.
query
(
UserArea
.
user_id
,
UserArea
.
desa_id
)
.
order_by
(
UserArea
.
user_id
)
def
csv_response
(
self
,
**
kwargs
):
query
=
self
.
query_register
()
# Panggil sebagai metode instance
query
=
self
.
query_register
()
row
=
query
.
first
()
header
=
row
.
_mapping
.
keys
()
if
row
else
[
'user_id'
,
'desa_id'
]
# Tambahkan fallback jika query kosong
header
=
row
.
_mapping
.
keys
()
if
row
else
[
'user_id'
,
'desa_id'
]
rows
=
[
list
(
item
)
for
item
in
query
.
all
()]
filename
=
f
"{get_random_string(16)}.csv"
value
=
{
...
...
@@ -155,6 +164,18 @@ class Views(BaseView):
return
super
(
Views
,
self
)
.
view_edit
()
def
save_request
(
self
,
values
,
row
=
None
):
if
row
:
# Mode Edit: Perbarui entri yang ada
desa_ids
=
values
.
get
(
"desa_id"
)
if
desa_ids
:
desa_id
=
next
(
iter
(
desa_ids
))
if
desa_ids
else
None
if
desa_id
is
not
None
:
row
.
desa_id
=
int
(
desa_id
)
# Perbarui desa_id pada row yang ada
# user_id tidak diubah, tetap dari row.user_id
DBSession
.
add
(
row
)
DBSession
.
flush
()
return
row
return
None
else
:
# Mode Tambah: Buat entri baru tanpa menghapus entri lama
user_id
=
values
.
get
(
"user_id"
)
if
not
user_id
:
return
None
...
...
@@ -162,17 +183,14 @@ class Views(BaseView):
if
desa_ids
:
desa_id
=
next
(
iter
(
desa_ids
))
if
desa_ids
else
None
if
desa_id
is
not
None
:
existing_desa
=
self
.
get_existing_desa
(
user_id
)
desa_id_str
=
str
(
desa_id
)
if
desa_id_str
not
in
existing_desa
:
DBSession
.
query
(
UserArea
)
.
filter_by
(
user_id
=
user_id
)
.
delete
(
synchronize_session
=
False
)
new_row
=
UserArea
(
user_id
=
user_id
,
desa_id
=
int
(
desa_id
)
)
DBSession
.
add
(
new_row
)
DBSession
.
flush
()
return
row
return
new_row
return
None
def
get_existing_desa
(
self
,
user_id
):
q
=
DBSession
.
query
(
UserArea
)
.
filter_by
(
user_id
=
user_id
)
...
...
@@ -182,7 +200,12 @@ class Views(BaseView):
return
set
(
r
)
def
get_values
(
self
,
row
,
istime
=
False
):
# Call the parent class's get_values to get the base dictionary
d
=
super
(
Views
,
self
)
.
get_values
(
row
,
istime
)
existing_desa
=
self
.
get_existing_desa
(
row
.
user_id
)
d
[
"desa_id"
]
=
{
next
(
iter
(
existing_desa
))}
if
existing_desa
else
set
()
# Populate the form with the existing data from the selected row
d
[
"id"
]
=
str
(
row
.
id
)
# Hidden field for the row ID
d
[
"user_id"
]
=
row
.
user_id
# Pre-fill user_id (readonly in edit form)
d
[
"desa_id"
]
=
{
str
(
row
.
desa_id
)}
# Pre-fill desa_id as a single-item set
return
d
\ No newline at end of file
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