Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
irul
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit dda741ba
authored
Jan 24, 2025
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
init delete route
1 parent
d9c1f73a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
9 deletions
opensipkd/base/__init__.py
opensipkd/base/scripts/initializedb.py
opensipkd/base/views/routes.py
opensipkd/base/__init__.py
View file @
dda741b
...
@@ -499,9 +499,11 @@ def add_view_config(config, module, view_name):
...
@@ -499,9 +499,11 @@ def add_view_config(config, module, view_name):
renderers
=
row
.
template
renderers
=
row
.
template
else
:
else
:
renderers
=
"views/templates/"
+
row
.
template
renderers
=
"views/templates/"
+
row
.
template
config
.
add_view
(
views
.
Views
,
attr
=
f
"{attr}"
,
params
=
dict
(
attr
=
f
"{attr}"
,
route_name
=
row
.
kode
,
route_name
=
row
.
kode
,
permission
=
row
.
permission
,
renderer
=
renderers
)
renderer
=
renderers
)
if
row
.
permission
:
params
[
"permission"
]
=
row
.
permission
config
.
add_view
(
views
.
Views
,
**
params
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
error
(
str
(
e
))
log
.
error
(
str
(
e
))
log
.
error
(
dict
(
row
.
__dict__
))
log
.
error
(
dict
(
row
.
__dict__
))
...
@@ -521,7 +523,7 @@ def get_route_names(rows):
...
@@ -521,7 +523,7 @@ def get_route_names(rows):
def
get_children
(
rows
):
def
get_children
(
rows
):
# log.debug(f"Children: {rows
}")
log
.
debug
(
f
"Children: {dict(rows.__dict__)
}"
)
return
[
dict
(
return
[
dict
(
order_id
=
r
.
order_id
,
order_id
=
r
.
order_id
,
id
=
r
.
id
,
id
=
r
.
id
,
...
...
opensipkd/base/scripts/initializedb.py
View file @
dda741b
...
@@ -12,7 +12,7 @@ from opensipkd.models import (
...
@@ -12,7 +12,7 @@ from opensipkd.models import (
Menus
,
Pangkat
)
Menus
,
Pangkat
)
from
opensipkd.models.handlers
import
LogDBSession
from
opensipkd.models.handlers
import
LogDBSession
from
pyramid.paster
import
(
get_appsettings
,
setup_logging
,
)
from
pyramid.paster
import
(
get_appsettings
,
setup_logging
,
)
from
sqlalchemy
import
(
engine_from_config
,
select
,
Table
,
inspect
)
from
sqlalchemy
import
(
desc
,
engine_from_config
,
select
,
Table
,
inspect
)
from
sqlalchemy
import
text
from
sqlalchemy
import
text
from
sqlalchemy.dialects
import
oracle
from
sqlalchemy.dialects
import
oracle
from
sqlalchemy.schema
import
CreateSchema
from
sqlalchemy.schema
import
CreateSchema
...
@@ -47,7 +47,7 @@ def routes_callback(typ, **kwargs):
...
@@ -47,7 +47,7 @@ def routes_callback(typ, **kwargs):
value
=
splited_last
value
=
splited_last
elif
field
==
"class_view"
:
elif
field
==
"class_view"
:
if
data
[
"def_func"
]
==
"list"
and
not
data
[
"class_view"
]
\
if
data
[
"def_func"
]
==
"list"
and
not
data
[
"class_view"
]
\
or
splited_last
not
in
[
"add"
,
"edit"
,
"delete"
,
"view"
,
"act"
,
"report"
]:
or
splited_last
not
in
[
"add"
,
"edit"
,
"delete"
,
"view"
,
"act"
,
"report"
,
"upload"
]:
log
.
debug
(
splited
[
-
1
:])
log
.
debug
(
splited
[
-
1
:])
log
.
debug
(
data
)
log
.
debug
(
data
)
return
"_"
.
join
(
splited
[
1
:])
return
"_"
.
join
(
splited
[
1
:])
...
@@ -80,6 +80,7 @@ def routes_callback(typ, **kwargs):
...
@@ -80,6 +80,7 @@ def routes_callback(typ, **kwargs):
return
value
return
value
def
usage
(
argv
):
def
usage
(
argv
):
cmd
=
os
.
path
.
basename
(
argv
[
0
])
cmd
=
os
.
path
.
basename
(
argv
[
0
])
print
(
'usage:
%
s <config_uri>
\n
'
print
(
'usage:
%
s <config_uri>
\n
'
...
@@ -213,7 +214,8 @@ def append_csv(table, filename, keys, get_file_func=get_file,
...
@@ -213,7 +214,8 @@ def append_csv(table, filename, keys, get_file_func=get_file,
insp
=
inspect
(
DBSession
.
connection
())
insp
=
inspect
(
DBSession
.
connection
())
# print(dir(table.__table__))
# print(dir(table.__table__))
# print("____")
# print("____")
schema
=
hasattr
(
table
.
__table__
,
"schema"
)
and
table
.
__table__
.
schema
or
"public"
schema
=
hasattr
(
table
.
__table__
,
"schema"
)
and
table
.
__table__
.
schema
or
"public"
columns_table
=
insp
.
get_columns
(
table
.
__tablename__
,
schema
)
columns_table
=
insp
.
get_columns
(
table
.
__tablename__
,
schema
)
fields
=
{}
fields
=
{}
for
c
in
columns_table
:
for
c
in
columns_table
:
...
@@ -316,7 +318,8 @@ def append_csv(table, filename, keys, get_file_func=get_file,
...
@@ -316,7 +318,8 @@ def append_csv(table, filename, keys, get_file_func=get_file,
password
=
val
password
=
val
else
:
else
:
if
fname_orig
in
fields
and
type
(
fields
[
fname_orig
])
is
BOOLEAN
:
if
fname_orig
in
fields
and
type
(
fields
[
fname_orig
])
is
BOOLEAN
:
val
=
(
val
==
'true'
or
val
==
'1'
or
val
==
1
)
and
True
or
False
val
=
(
val
==
'true'
or
val
==
'1'
or
val
==
1
)
and
True
or
False
setattr
(
row
,
fname_orig
,
val
)
setattr
(
row
,
fname_orig
,
val
)
# Penambahan checking field nullable false wajib ada datanya 2024-09-05
# Penambahan checking field nullable false wajib ada datanya 2024-09-05
...
@@ -438,3 +441,20 @@ def main(argv=sys.argv):
...
@@ -438,3 +441,20 @@ def main(argv=sys.argv):
restore_csv
(
ResKecamatan
,
'kecamatan.csv'
)
restore_csv
(
ResKecamatan
,
'kecamatan.csv'
)
transaction
.
commit
()
transaction
.
commit
()
restore_csv
(
ResDesa
,
'desa.csv'
)
restore_csv
(
ResDesa
,
'desa.csv'
)
def
delete_route
(
module
):
try
:
routes
=
Route
.
query
()
.
filter
(
Route
.
module
==
module
)
.
\
order_by
(
desc
(
Route
.
parent_id
),
desc
(
Route
.
order_id
),
)
.
limit
(
100
)
for
route
in
routes
:
try
:
Route
.
query_id
(
route
.
id
)
.
delete
()
transaction
.
commit
()
except
Exception
as
e
:
# print(str(e))
# print(route.nama, route.id, route.parent_id, )
# print("Error")
transaction
.
abort
()
except
Exception
as
e
:
print
(
str
(
e
))
opensipkd/base/views/routes.py
View file @
dda741b
...
@@ -72,7 +72,7 @@ class EditSchema(colander.Schema):
...
@@ -72,7 +72,7 @@ class EditSchema(colander.Schema):
missing
=
colander
.
drop
,
missing
=
colander
.
drop
,
description
=
"Nama file tanpa extension yang berisi class Views"
,
description
=
"Nama file tanpa extension yang berisi class Views"
,
default
=
""
default
=
""
)
,
)
def_func
=
colander
.
SchemaNode
(
def_func
=
colander
.
SchemaNode
(
colander
.
String
(),
colander
.
String
(),
...
...
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