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 2202f042
authored
Feb 26, 2025
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
penambahan routes
1 parent
37c7afb0
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
47 deletions
opensipkd/base/__init__.py
opensipkd/base/routes.py
opensipkd/base/views/departemen.py
opensipkd/base/__init__.py
View file @
2202f04
...
@@ -3,14 +3,12 @@ import importlib
...
@@ -3,14 +3,12 @@ import importlib
import
inspect
import
inspect
import
locale
import
locale
import
logging
import
logging
from
sqlalchemy
import
or_
import
re
import
re
import
urllib
from
.routes
import
routes
from
.routes
import
routes
# from opensipkd.tools.captcha import get_captcha_url
try
:
try
:
from
urllib
import
(
urlencode
,
quote
,
quote_plus
,
)
from
urllib
import
(
urlencode
,
quote
,
quote_plus
,
)
except
ImportError
:
except
ImportError
:
...
@@ -24,13 +22,13 @@ from pyramid.renderers import JSON
...
@@ -24,13 +22,13 @@ from pyramid.renderers import JSON
from
pyramid_mailer
import
mailer_factory_from_settings
from
pyramid_mailer
import
mailer_factory_from_settings
import
datetime
import
datetime
import
decimal
import
decimal
from
sqlalchemy
import
engine_from_config
,
or_
from
sqlalchemy
import
engine_from_config
from
.security
import
(
from
.security
import
(
g
roup_finder
,
g
et_user
,
MySecurityPolicy
,)
get_user
,
MySecurityPolicy
,)
from
pyramid.csrf
import
get_csrf_token
from
pyramid.csrf
import
get_csrf_token
from
opensipkd.models
import
(
from
opensipkd.models
import
(
DBSession
,
Base
,
Parameter
,
init_model
,)
DBSession
,
Base
,
Parameter
,
init_model
,
Route
,
)
# Route,
from
opensipkd.tools
import
(
from
opensipkd.tools
import
(
DefaultTimeZone
,
money
,
should_int
,
thousand
,
as_timezone
,
split
,
DefaultTimeZone
,
money
,
should_int
,
thousand
,
as_timezone
,
split
,
get_settings
,
dmy
,
dmyhms
,)
get_settings
,
dmy
,
dmyhms
,)
...
@@ -444,36 +442,43 @@ def get_home(request):
...
@@ -444,36 +442,43 @@ def get_home(request):
return
request
.
route_url
(
'home'
)[:
-
1
]
return
request
.
route_url
(
'home'
)[:
-
1
]
#
def _set_routes1(config, app_id):
def
_set_routes1
(
config
,
app_id
):
#
q = DBSession.query(Route).filter(Route.path != None,
q
=
DBSession
.
query
(
Route
)
.
filter
(
Route
.
path
!=
None
,
#
Route.module == None, Route.status == 1)
Route
.
module
==
None
,
Route
.
status
==
1
)
#
if not app_id:
if
not
app_id
:
#
q.filter(or_(Route.app_id == 0, None == Route.app_id))
q
.
filter
(
or_
(
Route
.
app_id
==
0
,
None
==
Route
.
app_id
))
#
else:
else
:
#
q.filter(Route.app_id == app_id)
q
.
filter
(
Route
.
app_id
==
app_id
)
#
for route in q:
for
route
in
q
:
#
if route.type == 0:
if
route
.
type
==
0
:
#
config.add_route(route.kode, route.path)
config
.
add_route
(
route
.
kode
,
route
.
path
)
#
if route.nama:
if
route
.
nama
:
#
titles[route.kode] = route.nama
titles
[
route
.
kode
]
=
route
.
nama
#
elif route.type == 1:
elif
route
.
type
==
1
:
#
config.add_jsonrpc_endpoint(route.kode, route.path,
config
.
add_jsonrpc_endpoint
(
route
.
kode
,
route
.
path
,
#
default_renderer="json_rpc")
default_renderer
=
"json_rpc"
)
# def _set_routes2(config, module="base"):
def
_set_routes2
(
config
,
module
=
"base"
):
# q = DBSession.query(Route).filter(
q
=
DBSession
.
query
(
Route
)
.
filter
(
# Route.module == module, Route.status == 1)
Route
.
module
==
module
,
Route
.
status
==
1
)
# for route in q:
for
route
in
q
:
# if route.type == 0:
if
route
.
type
==
0
:
# config.add_route(route.kode, route.path)
config
.
add_route
(
route
.
kode
,
route
.
path
)
# if route.nama:
if
route
.
nama
:
# titles[route.kode] = route.nama
titles
[
route
.
kode
]
=
route
.
nama
# elif route.type == 1:
elif
route
.
type
==
1
:
# config.add_jsonrpc_endpoint(
config
.
add_jsonrpc_endpoint
(
# route.kode, route.path, default_renderer="json_rpc")
route
.
kode
,
route
.
path
,
default_renderer
=
"json_rpc"
)
# return q
return
q
def
set_routes
(
config
,
app_id
=
None
):
if
app_id
and
type
(
app_id
)
==
str
:
return
_set_routes2
(
config
,
app_id
)
else
:
return
_set_routes1
(
config
,
app_id
)
def
_add_route
(
config
,
route
):
def
_add_route
(
config
,
route
):
...
@@ -553,13 +558,6 @@ def _add_view_config(config, view_name, route):
...
@@ -553,13 +558,6 @@ def _add_view_config(config, view_name, route):
# config.scan('.')
# config.scan('.')
# def set_routes(config, app_id=None):
# if app_id and type(app_id) == str:
# return _set_routes2(config, app_id)
# else:
# return _set_routes1(config, app_id)
def
get_route_names
(
rows
):
def
get_route_names
(
rows
):
return
[
r
.
kode
for
r
in
rows
if
not
r
.
is_menu
]
return
[
r
.
kode
for
r
in
rows
if
not
r
.
is_menu
]
...
@@ -724,6 +722,10 @@ def get_route_file(filename):
...
@@ -724,6 +722,10 @@ def get_route_file(filename):
return
open
(
fullpath
)
return
open
(
fullpath
)
def
routes_by_array
(
config
,
routs
):
BaseApp
()
.
route_from_list
(
config
,
routs
)
class
BaseApp
():
class
BaseApp
():
def
__init__
(
self
):
def
__init__
(
self
):
self
.
menus
=
[]
self
.
menus
=
[]
...
@@ -768,8 +770,8 @@ class BaseApp():
...
@@ -768,8 +770,8 @@ class BaseApp():
route
[
"is_menu"
]
=
route
.
get
(
"is_menu"
,
0
)
route
[
"is_menu"
]
=
route
.
get
(
"is_menu"
,
0
)
url_path
=
route
.
get
(
"path"
,
None
)
url_path
=
route
.
get
(
"path"
,
None
)
if
not
url_path
:
if
not
url_path
:
# pjdl /pjdl pjdl-add /pjdl/add
url_path
=
"/"
+
route
[
"kode"
]
.
replace
(
"-"
,
"/"
)
url_path
=
"/"
+
route
[
"kode"
]
.
replace
(
"-"
,
"/"
)
route
[
"path"
]
=
url_path
route
[
"path"
]
=
url_path
children
=
route
.
get
(
"children"
,
[])
children
=
route
.
get
(
"children"
,
[])
...
...
opensipkd/base/routes.py
View file @
2202f04
# kode, path, nama
routes
=
[
routes
=
[
(
"user-area"
,
"/user/area"
,
"User Area"
),
(
"user-area"
,
"/user/area"
,
"User Area"
),
(
"user-area-add"
,
"/user/area/add"
,
"Tambah User Area"
),
(
"user-area-add"
,
"/user/area/add"
,
"Tambah User Area"
),
...
@@ -8,9 +9,13 @@ routes = [
...
@@ -8,9 +9,13 @@ routes = [
(
"user-area-upload"
,
"/user/area/upload"
,
"Upload User Area"
),
(
"user-area-upload"
,
"/user/area/upload"
,
"Upload User Area"
),
(
"user-departemen"
,
"/user/departemen"
,
"User Departemen"
),
(
"user-departemen"
,
"/user/departemen"
,
"User Departemen"
),
(
"user-departemen-add"
,
"/user/departemen/add"
,
"Tambah User Departemen"
),
(
"user-departemen-add"
,
"/user/departemen/add"
,
"Tambah User Departemen"
),
(
"user-departemen-edit"
,
"/user/departemen/{id}/edit"
,
"Edit User Departemen"
),
(
"user-departemen-edit"
,
(
"user-departemen-delete"
,
"/user/departemen/{id}/delete"
,
"Hapus User Departemen"
),
"/user/departemen/{id}/edit"
,
"Edit User Departemen"
),
(
"user-departemen-view"
,
"/user/departemen/{id}/view"
,
"Lihat User Departemen"
),
(
"user-departemen-delete"
,
(
"user-departemen-act"
,
"/user/departemen/{act}/act"
,
"Action User Departemen"
),
"/user/departemen/{id}/delete"
,
"Hapus User Departemen"
),
(
"user-departemen-view"
,
"/user/departemen/{id}/view"
,
"Lihat User Departemen"
),
(
"user-departemen-act"
,
"/user/departemen/{act}/act"
,
"Action User Departemen"
),
(
"user-departemen-upload"
,
"/user/departemen/upload"
,
"Upload User Departemen"
),
(
"user-departemen-upload"
,
"/user/departemen/upload"
,
"Upload User Departemen"
),
]
]
opensipkd/base/views/departemen.py
View file @
2202f04
This diff is collapsed.
Click to expand it.
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