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 f48dca80
authored
Mar 19, 2025
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perbaikan route from csv
1 parent
fa22d5af
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
8 deletions
opensipkd/base/__init__.py
opensipkd/base/__init__.py
View file @
f48dca8
...
@@ -512,10 +512,16 @@ def _add_view_config(config, paket, route):
...
@@ -512,10 +512,16 @@ def _add_view_config(config, paket, route):
views
=
getattr
(
_views
,
class_name
)
views
=
getattr
(
_views
,
class_name
)
template
=
route
.
get
(
"template"
,
"form.pt"
)
template
=
route
.
get
(
"template"
,
"form.pt"
)
if
not
template
:
if
not
template
:
template
=
"form.pt"
if
route
.
get
(
"func_name"
)
==
"view_list"
:
template
=
"list.pt"
elif
route
.
get
(
"func_name"
)
==
"view_act"
:
template
=
"json"
else
:
template
=
"form.pt"
if
template
!=
"json"
:
if
template
!=
"json"
:
template
=
"views/templates/"
+
template
template
=
"views/templates/"
+
template
params
=
dict
(
attr
=
f
"{attr}"
,
params
=
dict
(
attr
=
f
"{attr}"
,
route_name
=
route
.
get
(
"kode"
),
route_name
=
route
.
get
(
"kode"
),
renderer
=
template
)
renderer
=
template
)
...
@@ -620,7 +626,6 @@ def get_config(settings):
...
@@ -620,7 +626,6 @@ def get_config(settings):
config
.
set_default_csrf_options
(
require_csrf
=
False
)
config
.
set_default_csrf_options
(
require_csrf
=
False
)
config
.
set_security_policy
(
MySecurityPolicy
(
settings
[
"session.secret"
]))
config
.
set_security_policy
(
MySecurityPolicy
(
settings
[
"session.secret"
]))
config
.
add_subscriber
(
add_cors_headers_response_callback
,
NewRequest
)
config
.
add_subscriber
(
add_cors_headers_response_callback
,
NewRequest
)
config
.
add_request_method
(
get_user
,
'user'
,
reify
=
True
)
config
.
add_request_method
(
get_user
,
'user'
,
reify
=
True
)
config
.
add_request_method
(
get_title
,
'title'
,
reify
=
True
)
config
.
add_request_method
(
get_title
,
'title'
,
reify
=
True
)
config
.
add_request_method
(
get_company
,
'company'
,
reify
=
True
)
config
.
add_request_method
(
get_company
,
'company'
,
reify
=
True
)
...
@@ -751,7 +756,8 @@ class BaseApp():
...
@@ -751,7 +756,8 @@ class BaseApp():
for
route
in
route_menus
:
for
route
in
route_menus
:
if
not
int
(
route
.
get
(
"status"
,
0
)):
if
not
int
(
route
.
get
(
"status"
,
0
)):
continue
continue
route
[
"route_names"
]
=
[
route
[
"kode"
]]
route
[
"route_name"
]
=
[
route
[
"kode"
]]
route
[
"permission"
]
=
route
.
get
(
"permission"
,
""
)
route
[
"permission"
]
=
route
.
get
(
"permission"
,
""
)
route
[
"icon"
]
=
route
.
get
(
"icon"
,
None
)
route
[
"icon"
]
=
route
.
get
(
"icon"
,
None
)
route_typ
=
route
.
get
(
"typ"
,
0
)
route_typ
=
route
.
get
(
"typ"
,
0
)
...
@@ -759,12 +765,25 @@ class BaseApp():
...
@@ -759,12 +765,25 @@ class BaseApp():
route_typ
=
0
route_typ
=
0
else
:
else
:
route_typ
=
int
(
route_typ
)
route_typ
=
int
(
route_typ
)
route
[
"typ"
]
=
route_typ
route
[
"typ"
]
=
route_typ
route
[
"is_menu"
]
=
route
.
get
(
"is_menu"
,
0
)
is_menu
=
route
.
get
(
"is_menu"
,
0
)
route
[
"is_menu"
]
=
is_menu
and
int
(
is_menu
)
or
0
url_path
=
route
.
get
(
"path"
,
None
)
url_path
=
route
.
get
(
"path"
,
None
)
if
not
url_path
:
if
not
url_path
:
url_path
=
"/"
+
route
[
"kode"
]
.
replace
(
"-"
,
"/"
)
path_split
=
route
.
get
(
"kode"
)
.
split
(
"-"
)
path_last
=
path_split
[
len
(
path_split
)
-
1
]
if
path_last
in
[
"edit"
,
"view"
,
"delete"
]:
path
=
"/"
.
join
(
path_split
[:
-
1
])
path
+=
"/{id}/"
+
path_last
elif
path_last
in
[
"act"
]:
path
=
"/"
.
join
(
path_split
[:
-
1
])
path
+=
"/{act}/"
+
path_last
else
:
path
=
"/"
.
join
(
path_split
)
url_path
=
'/'
+
path
route
[
"path"
]
=
url_path
route
[
"path"
]
=
url_path
children
=
route
.
get
(
"children"
,
[])
children
=
route
.
get
(
"children"
,
[])
...
@@ -780,11 +799,21 @@ class BaseApp():
...
@@ -780,11 +799,21 @@ class BaseApp():
else
:
else
:
parent
[
"children"
]
.
append
(
route
)
parent
[
"children"
]
.
append
(
route
)
if
children
:
if
children
:
route
[
"route_name
s
"
]
.
extend
(
route
[
"route_name"
]
.
extend
(
self
.
add_menu
(
config
,
children
,
route
,
paket
)
self
.
add_menu
(
config
,
children
,
route
,
paket
)
)
)
route_names
.
append
(
route
[
"kode"
])
route_names
.
append
(
route
[
"kode"
])
return
route_names
return
route_names
def
route_children
(
self
,
parent
,
row
):
for
p
in
parent
:
parent_id
=
row
.
get
(
"parent_id"
)
or
row
.
get
(
"parent_id/routes.kode"
)
if
p
[
"kode"
]
==
parent_id
:
p
[
"children"
]
.
append
(
row
)
else
:
if
p
[
"children"
]:
self
.
route_children
(
p
[
"children"
],
row
)
def
route_from_csv
(
self
,
config
,
get_file
=
get_route_file
,
paket
=
"opensipkd.base.views"
):
def
route_from_csv
(
self
,
config
,
get_file
=
get_route_file
,
paket
=
"opensipkd.base.views"
):
with
get_file
(
"routes.csv"
)
as
f
:
with
get_file
(
"routes.csv"
)
as
f
:
...
@@ -794,8 +823,9 @@ class BaseApp():
...
@@ -794,8 +823,9 @@ class BaseApp():
if
not
int
(
row
.
get
(
"status"
,
0
)):
if
not
int
(
row
.
get
(
"status"
,
0
)):
continue
continue
row
[
"children"
]
=
[]
row
[
"children"
]
=
[]
if
row
.
get
(
"parent_id"
)
or
row
.
get
(
"parent_id/routes.kode"
):
parent_id
=
row
.
get
(
"parent_id"
)
or
row
.
get
(
"parent_id/routes.kode"
)
new_routes
[
len
(
new_routes
)
-
1
][
"children"
]
.
append
(
row
)
if
parent_id
:
self
.
route_children
(
new_routes
,
row
)
else
:
else
:
new_routes
.
append
(
row
)
new_routes
.
append
(
row
)
...
...
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