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 ae0b0fdb
authored
Dec 07, 2024
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Penambahan callback list_join dan list_filter
1 parent
7f38fee3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
opensipkd/base/views/base_views.py
opensipkd/base/views/base_views.py
View file @
ae0b0fd
...
@@ -10,6 +10,7 @@ from dateutil.relativedelta import relativedelta
...
@@ -10,6 +10,7 @@ from dateutil.relativedelta import relativedelta
from
deform
import
(
widget
,
Form
,
ValidationFailure
,
FileData
,
)
from
deform
import
(
widget
,
Form
,
ValidationFailure
,
FileData
,
)
from
deform.widget
import
SelectWidget
from
deform.widget
import
SelectWidget
from
pyramid.httpexceptions
import
HTTPFound
,
HTTPNotFound
from
pyramid.httpexceptions
import
HTTPFound
,
HTTPNotFound
from
sqlalchemy
import
Table
from
opensipkd.base.views.upload
import
tmpstore
from
opensipkd.base.views.upload
import
tmpstore
from
opensipkd.tools
import
dmy
,
get_settings
,
get_ext
,
\
from
opensipkd.tools
import
dmy
,
get_settings
,
get_ext
,
\
...
@@ -160,7 +161,7 @@ class BaseView(object):
...
@@ -160,7 +161,7 @@ class BaseView(object):
self
.
upload_exts
=
(
".csv"
,
".tsv"
)
self
.
upload_exts
=
(
".csv"
,
".tsv"
)
self
.
upload_keys
=
[
"kode"
]
self
.
upload_keys
=
[
"kode"
]
self
.
table
=
""
self
.
table
=
Table
self
.
home
=
self
.
req
.
_host
self
.
home
=
self
.
req
.
_host
self
.
buttons
=
None
self
.
buttons
=
None
self
.
headers
=
None
self
.
headers
=
None
...
@@ -249,9 +250,10 @@ class BaseView(object):
...
@@ -249,9 +250,10 @@ class BaseView(object):
if
not
list_url
:
if
not
list_url
:
list_url
=
self
.
req
.
route_url
(
self
.
list_route
)
list_url
=
self
.
req
.
route_url
(
self
.
list_route
)
action_suffix
=
kwargs
.
get
(
"action_suffix"
,
"/grid/act"
)
table
=
DeTable
(
schema
,
table
=
DeTable
(
schema
,
action
=
list_url
,
action
=
list_url
,
action_suffix
=
"/grid/act"
,
action_suffix
=
action_suffix
,
buttons
=
self
.
list_buttons
,
buttons
=
self
.
list_buttons
,
request
=
self
.
req
,
request
=
self
.
req
,
allow_view
=
allow_view
,
allow_view
=
allow_view
,
...
@@ -496,11 +498,21 @@ class BaseView(object):
...
@@ -496,11 +498,21 @@ class BaseView(object):
columns
=
self
.
columns
columns
=
self
.
columns
query
=
self
.
db_session
.
query
()
.
select_from
(
self
.
table
)
query
=
self
.
db_session
.
query
()
.
select_from
(
self
.
table
)
query
=
self
.
list_join
(
query
,
**
kwargs
)
table_join
=
kwargs
.
get
(
'table_join'
)
if
table_join
is
not
None
:
query
=
table_join
(
query
,
**
kwargs
)
else
:
query
=
self
.
list_join
(
query
,
**
kwargs
)
if
self
.
req
.
user
and
self
.
req
.
user
.
company_id
and
hasattr
(
self
.
table
,
"company_id"
):
if
self
.
req
.
user
and
self
.
req
.
user
.
company_id
and
hasattr
(
self
.
table
,
"company_id"
):
query
=
query
.
filter
(
query
=
query
.
filter
(
self
.
table
.
company_id
==
self
.
req
.
user
.
company_id
)
self
.
table
.
company_id
==
self
.
req
.
user
.
company_id
)
query
=
self
.
list_filter
(
query
,
**
kwargs
)
table_filter
=
kwargs
.
get
(
'table_filter'
)
if
table_filter
is
not
None
:
query
=
table_filter
(
query
,
**
kwargs
)
else
:
query
=
self
.
list_filter
(
query
,
**
kwargs
)
# log.debug(str(columns))
# log.debug(str(columns))
# qry = query.add_columns(*[c.sqla_expr for c in columns])
# qry = query.add_columns(*[c.sqla_expr for c in columns])
# log.debug(str(qry))
# log.debug(str(qry))
...
@@ -609,6 +621,7 @@ class BaseView(object):
...
@@ -609,6 +621,7 @@ class BaseView(object):
# row.status = status
# row.status = status
self
.
db_session
.
add
(
row
)
self
.
db_session
.
add
(
row
)
self
.
db_session
.
flush
()
self
.
db_session
.
flush
()
return
row
return
row
def
save_request
(
self
,
values
,
row
=
None
):
def
save_request
(
self
,
values
,
row
=
None
):
...
...
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