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 0bf5ddb1
authored
Nov 18, 2024
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Route order children
1 parent
b54f3f1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
opensipkd/base/__init__.py
opensipkd/models/common.py
opensipkd/base/__init__.py
View file @
0bf5ddb
...
@@ -8,6 +8,7 @@ try:
...
@@ -8,6 +8,7 @@ try:
from
urllib
import
(
urlencode
,
quote
,
quote_plus
,
)
from
urllib
import
(
urlencode
,
quote
,
quote_plus
,
)
except
ImportError
:
except
ImportError
:
from
urllib.parse
import
(
urlencode
,
quote
,
quote_plus
,
)
from
urllib.parse
import
(
urlencode
,
quote
,
quote_plus
,
)
from
collections
import
OrderedDict
from
pyramid.events
import
NewRequest
from
pyramid.events
import
NewRequest
from
pyramid.config
import
Configurator
from
pyramid.config
import
Configurator
from
pyramid_beaker
import
session_factory_from_settings
from
pyramid_beaker
import
session_factory_from_settings
...
@@ -428,7 +429,7 @@ def get_home(request):
...
@@ -428,7 +429,7 @@ def get_home(request):
def
_set_routes1
(
config
,
app_id
):
def
_set_routes1
(
config
,
app_id
):
q
=
DBSession
.
query
(
Route
)
.
filter
(
Route
.
path
!=
None
,
Route
.
module
==
None
,
Route
.
status
==
1
)
q
=
DBSession
.
query
(
Route
)
.
filter
(
Route
.
path
!=
None
,
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
:
...
@@ -445,7 +446,7 @@ def _set_routes1(config, app_id):
...
@@ -445,7 +446,7 @@ def _set_routes1(config, app_id):
def
_set_routes2
(
config
,
module
=
"base"
):
def
_set_routes2
(
config
,
module
=
"base"
):
q
=
DBSession
.
query
(
Route
)
.
filter
(
Route
.
module
==
module
,
Route
.
status
==
1
)
q
=
DBSession
.
query
(
Route
)
.
filter
(
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
)
...
@@ -469,13 +470,16 @@ def get_route_names(rows):
...
@@ -469,13 +470,16 @@ def get_route_names(rows):
def
get_children
(
rows
):
def
get_children
(
rows
):
return
[{
"id"
:
r
.
id
,
"path"
:
r
.
path
,
"nama"
:
r
.
nama
,
"is_menu"
:
r
.
is_menu
,
log
.
debug
(
f
"Children: {rows}"
)
"icon"
:
r
.
icon
,
return
[
dict
(
"route_names"
:
[
r
.
kode
]
+
get_route_names
(
r
.
children
),
order_id
=
r
.
order_id
,
"children"
:
get_children
(
r
.
children
),
id
=
r
.
id
,
"has_sub"
:
r
.
path
.
find
(
"/"
)
==
-
1
path
=
r
.
path
,
nama
=
r
.
nama
,
is_menu
=
r
.
is_menu
,
}
icon
=
r
.
icon
,
for
r
in
rows
if
r
.
is_menu
and
r
.
status
==
1
]
route_names
=
[
r
.
kode
]
+
get_route_names
(
r
.
children
),
children
=
get_children
(
r
.
children
),
has_sub
=
r
.
path
.
find
(
"/"
)
==
-
1
)
for
r
in
rows
if
r
.
is_menu
and
r
.
status
==
1
]
def
get_module_menus
(
module
):
def
get_module_menus
(
module
):
...
...
opensipkd/models/common.py
View file @
0bf5ddb
...
@@ -26,7 +26,8 @@ class Route(Base, NamaModel):
...
@@ -26,7 +26,8 @@ class Route(Base, NamaModel):
template
=
Column
(
String
(
256
))
template
=
Column
(
String
(
256
))
icon
=
Column
(
String
(
256
))
icon
=
Column
(
String
(
256
))
children
=
relationship
(
children
=
relationship
(
"Route"
,
backref
=
backref
(
'parent'
,
remote_side
=
[
id
]))
"Route"
,
backref
=
backref
(
'parent'
,
remote_side
=
[
id
]),
order_by
=
"Route.order_id"
)
class
Parameter
(
Base
,
NamaModel
):
class
Parameter
(
Base
,
NamaModel
):
...
...
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