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 083dd4d3
authored
Jul 26, 2022
by
aagusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
list act
1 parent
09f1ee33
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
23 deletions
opensipkd/base/views/base_views.py
opensipkd/base/views/base_views_api.py
opensipkd/base/views/common.py
opensipkd/base/views/base_views.py
View file @
083dd4d
...
...
@@ -5,6 +5,7 @@ from datetime import datetime
from
datatables
import
ColumnDT
from
dateutil.relativedelta
import
relativedelta
from
opensipkd.pbb.eta
import
nik_url
from
opensipkd.tools.api
import
JsonRpcInvalidLoginError
from
opensipkd.tools.form_api
import
formfield2dict
...
...
@@ -15,7 +16,8 @@ from pyramid.httpexceptions import HTTPFound
from
.common
import
DataTables
from
..
import
DBSession
,
get_params
from
opensipkd.tools
import
dmy
,
dmy_to_date
,
get_settings
,
get_ext
from
opensipkd.tools
import
dmy
,
dmy_to_date
,
get_settings
,
get_ext
,
\
date_from_str
import
colander
from
deform
import
(
widget
,
Form
,
ValidationFailure
,
Button
,
)
from
email.utils
import
parseaddr
...
...
@@ -85,9 +87,6 @@ class BaseView(object):
except
:
self
.
dt_akhir
=
dmy_to_date
(
self
.
akhir
)
self
.
ses
[
'akhir'
]
=
self
.
akhir
self
.
ses
[
'dt_akhir'
]
=
self
.
dt_akhir
self
.
tahun_awal
=
'tahun_awal'
in
self
.
ses
and
self
.
ses
[
'tahun_awal'
]
or
self
.
tahun
self
.
tahun_awal
=
'tahun_awal'
in
self
.
params
and
self
.
params
[
...
...
@@ -237,13 +236,18 @@ class BaseView(object):
def
list_join
(
self
,
query
):
return
query
def
view_act
(
self
):
def
list_filter
(
self
,
query
):
return
query
def
view_act
(
self
,
**
kwargs
):
url_dict
=
self
.
req
.
matchdict
if
url_dict
[
'act'
]
==
'grid'
:
url
=
[]
columns
=
[]
for
d
in
self
.
list_schema
():
global_search
=
hasattr
(
d
,
"searchable"
)
and
hasattr
(
d
,
"searchable"
)
==
False
and
False
or
True
global_search
=
hasattr
(
d
,
"searchable"
)
and
\
hasattr
(
d
,
"searchable"
)
==
False
and
False
\
or
True
if
hasattr
(
d
,
"field"
):
if
type
(
d
.
field
)
==
str
:
columns
.
append
(
...
...
@@ -254,15 +258,23 @@ class BaseView(object):
else
:
columns
.
append
(
ColumnDT
(
getattr
(
self
.
table
,
d
.
name
),
mData
=
d
.
name
))
if
hasattr
(
d
,
"url"
):
url
.
append
(
d
.
name
)
query
=
DBSession
.
query
()
.
select_from
(
self
.
table
)
query
=
self
.
list_join
(
query
)
if
self
.
req
.
user
and
self
.
req
.
user
.
company_id
and
hasattr
(
self
.
table
,
"company_id"
):
query
=
query
.
filter
(
self
.
table
.
company_id
==
self
.
req
.
user
.
company_id
)
query
=
self
.
list_filter
(
query
)
row_table
=
DataTables
(
self
.
req
.
GET
,
query
,
columns
)
return
row_table
.
output_result
()
result
=
row_table
.
output_result
()
for
d
in
result
[
"data"
]:
for
k
,
v
in
d
.
items
():
if
k
in
url
and
v
:
link
=
"/"
.
join
([
self
.
home
,
nik_url
,
v
])
d
[
k
]
=
f
'<a href="{link}" target="_blank">View</a>'
return
result
else
:
return
self
.
next_act
()
...
...
@@ -290,7 +302,7 @@ class BaseView(object):
elif
"cancel"
in
self
.
req
.
POST
or
'batal'
in
self
.
req
.
POST
:
self
.
cancel_act
()
else
:
return
self
.
next_add
(
form
)
return
self
.
next_add
(
form
,
table
=
table
,
resources
=
resources
)
return
self
.
route_list
()
values
=
self
.
before_add
()
...
...
@@ -424,8 +436,6 @@ class BaseView(object):
return
self
.
route_list
()
@colander.deferred
def
deferred_status
(
node
,
kw
):
values
=
kw
.
get
(
'daftar_status'
,
[])
...
...
opensipkd/base/views/base_views_api.py
View file @
083dd4d
...
...
@@ -82,17 +82,16 @@ class BaseApi(object):
def
_view_add
(
self
,
**
kwargs
):
form
=
self
.
get_form
(
self
.
add_schema
,
**
kwargs
)
if
"action"
in
self
.
data
:
self
.
action
=
self
.
data
[
"action"
]
if
'save'
==
self
.
action
:
values
=
self
.
validate_field
(
form
)
row
=
self
.
save_request
(
values
)
elif
"cancel"
==
self
.
action
or
'batal'
==
self
.
action
:
self
.
cancel_act
()
else
:
return
self
.
next_add
(
form
)
return
self
.
route_list
()
self
.
action
=
self
.
data
.
get
(
"action"
,
""
)
if
'save'
==
self
.
action
:
values
=
self
.
validate_field
(
form
)
row
=
self
.
save_request
(
values
)
elif
"cancel"
==
self
.
action
or
'batal'
==
self
.
action
:
self
.
cancel_act
()
else
:
return
self
.
next_add
(
form
)
return
self
.
route_list
()
values
=
self
.
before_add
()
form
.
set_appstruct
(
values
)
return
form
...
...
opensipkd/base/views/common.py
View file @
083dd4d
...
...
@@ -9,6 +9,9 @@ from opensipkd.base import log
class
DataTables
(
BaseDataTables
):
def
__init__
(
self
,
request
,
query
,
columns
,
allow_regex_searches
=
False
):
super
()
.
__init__
(
request
,
query
,
columns
,
allow_regex_searches
)
def
_set_global_filter_expression
(
self
):
# global search filter
global_search
=
self
.
params
.
get
(
'search[value]'
,
''
)
...
...
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