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 0d449543
authored
Nov 13, 2024
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
penambahan view_buttons
1 parent
4df4d77c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
opensipkd/base/views/base_views.py
opensipkd/base/views/widget_os.py
opensipkd/models/base.py
opensipkd/base/views/base_views.py
View file @
0d44954
...
@@ -10,8 +10,6 @@ from dateutil.relativedelta import relativedelta
...
@@ -10,8 +10,6 @@ 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
opensipkd.base.views.upload
import
tmpstore
from
opensipkd.base.views.upload
import
tmpstore
from
pyramid.httpexceptions
import
HTTPFound
,
HTTPNotFound
from
opensipkd.tools
import
dmy
,
get_settings
,
get_ext
,
\
from
opensipkd.tools
import
dmy
,
get_settings
,
get_ext
,
\
date_from_str
,
get_random_string
date_from_str
,
get_random_string
from
opensipkd.tools.buttons
import
btn_save
,
btn_cancel
,
btn_close
,
btn_delete
,
\
from
opensipkd.tools.buttons
import
btn_save
,
btn_cancel
,
btn_close
,
btn_delete
,
\
...
@@ -19,6 +17,8 @@ from opensipkd.tools.buttons import btn_save, btn_cancel, btn_close, btn_delete,
...
@@ -19,6 +17,8 @@ from opensipkd.tools.buttons import btn_save, btn_cancel, btn_close, btn_delete,
btn_pdf
,
btn_unpost
,
btn_post
btn_pdf
,
btn_unpost
,
btn_post
from
opensipkd.tools.captcha
import
get_captcha
from
opensipkd.tools.captcha
import
get_captcha
from
opensipkd.tools.report
import
csv_response
,
file_response
from
opensipkd.tools.report
import
csv_response
,
file_response
from
pyramid.httpexceptions
import
HTTPFound
,
HTTPNotFound
from
.common
import
DataTables
from
.common
import
DataTables
from
..
import
DBSession
,
get_params
,
get_urls
from
..
import
DBSession
,
get_params
,
get_urls
from
..scripts.initializedb
import
append_csv
from
..scripts.initializedb
import
append_csv
...
@@ -266,7 +266,7 @@ class BaseView(object):
...
@@ -266,7 +266,7 @@ class BaseView(object):
return
{}
return
{}
def
next_view
(
self
,
form
,
**
kwargs
):
def
next_view
(
self
,
form
,
**
kwargs
):
return
self
.
route_list
()
return
def
next_edit
(
self
,
form
,
**
kwargs
):
def
next_edit
(
self
,
form
,
**
kwargs
):
return
self
.
route_list
(
**
kwargs
)
return
self
.
route_list
(
**
kwargs
)
...
@@ -292,13 +292,20 @@ class BaseView(object):
...
@@ -292,13 +292,20 @@ class BaseView(object):
**
kwargs
**
kwargs
)
)
def
view_buttons
(
self
,
row
):
result
=
(
btn_close
,)
return
result
def
view_view
(
self
,
**
kwargs
):
# row = query_id(request).first()
def
view_view
(
self
,
**
kwargs
):
# row = query_id(request).first()
request
=
self
.
req
request
=
self
.
req
row
=
self
.
query_id
()
.
first
()
row
=
self
.
query_id
()
.
first
()
if
not
row
:
if
not
row
:
return
self
.
id_not_found
()
return
self
.
id_not_found
()
bindings
=
self
.
get_bindings
(
row
)
bindings
=
self
.
get_bindings
(
row
)
buttons
=
kwargs
.
get
(
"buttons"
,
(
btn_close
,))
buttons
=
kwargs
.
get
(
"buttons"
,
None
)
if
not
buttons
:
buttons
=
self
.
view_buttons
(
row
)
form
=
self
.
get_form
(
self
.
edit_schema
,
buttons
=
buttons
,
form
=
self
.
get_form
(
self
.
edit_schema
,
buttons
=
buttons
,
bindings
=
bindings
)
bindings
=
bindings
)
if
request
.
POST
:
if
request
.
POST
:
...
@@ -609,6 +616,9 @@ class BaseView(object):
...
@@ -609,6 +616,9 @@ class BaseView(object):
"""
"""
return
form
return
form
def
edit_restrict
(
self
,
row
):
return
False
def
view_edit
(
self
,
**
kwargs
):
def
view_edit
(
self
,
**
kwargs
):
request
=
self
.
req
request
=
self
.
req
row
=
self
.
query_id
()
.
first
()
row
=
self
.
query_id
()
.
first
()
...
@@ -616,6 +626,9 @@ class BaseView(object):
...
@@ -616,6 +626,9 @@ class BaseView(object):
if
not
row
:
if
not
row
:
return
self
.
id_not_found
(
**
kwargs
)
return
self
.
id_not_found
(
**
kwargs
)
if
self
.
edit_restrict
(
row
):
return
self
.
route_list
(
**
kwargs
)
if
not
self
.
bindings
:
if
not
self
.
bindings
:
self
.
bindings
=
self
.
get_bindings
(
row
)
self
.
bindings
=
self
.
get_bindings
(
row
)
...
...
opensipkd/base/views/widget_os.py
View file @
0d44954
...
@@ -585,6 +585,7 @@ class BootStrapDateInputWidget(Widget):
...
@@ -585,6 +585,7 @@ class BootStrapDateInputWidget(Widget):
if
pstruct
in
(
""
,
null
):
if
pstruct
in
(
""
,
null
):
return
null
return
null
try
:
try
:
_logging
.
debug
(
f
"Date:{self._pstruct_schema}"
)
validated
=
self
.
_pstruct_schema
.
deserialize
(
pstruct
)
validated
=
self
.
_pstruct_schema
.
deserialize
(
pstruct
)
except
Invalid
as
exc
:
except
Invalid
as
exc
:
raise
Invalid
(
field
.
schema
,
"Invalid pstruct:
%
s"
%
exc
)
raise
Invalid
(
field
.
schema
,
"Invalid pstruct:
%
s"
%
exc
)
...
...
opensipkd/models/base.py
View file @
0d44954
...
@@ -9,6 +9,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
...
@@ -9,6 +9,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
from
sqlalchemy.orm
import
(
scoped_session
,
sessionmaker
,
Session
)
from
sqlalchemy.orm
import
(
scoped_session
,
sessionmaker
,
Session
)
from
zope.sqlalchemy
import
register
from
zope.sqlalchemy
import
register
_logging
=
logging
.
getLogger
(
__name__
)
class
MySession
(
Session
):
class
MySession
(
Session
):
def
execute
(
self
,
clause
,
params
=
None
,
mapper
=
None
,
**
kw
):
def
execute
(
self
,
clause
,
params
=
None
,
mapper
=
None
,
**
kw
):
...
@@ -67,8 +68,8 @@ class CommonModel(object):
...
@@ -67,8 +68,8 @@ class CommonModel(object):
def
from_dict
(
self
,
values
,
date_format
=
"
%
d-
%
m-
%
Y"
):
def
from_dict
(
self
,
values
,
date_format
=
"
%
d-
%
m-
%
Y"
):
for
column
in
self
.
__table__
.
columns
:
for
column
in
self
.
__table__
.
columns
:
if
column
.
name
in
values
:
if
column
.
name
in
values
:
_logging
.
debug
(
f
"{column.name}: {column.type}: {values[column.name]}"
)
if
type
(
column
.
type
)
is
DateTime
and
date_format
:
if
type
(
column
.
type
)
is
DateTime
and
date_format
:
if
values
[
column
.
name
]
and
type
(
values
[
column
.
name
])
is
String
:
if
values
[
column
.
name
]
and
type
(
values
[
column
.
name
])
is
String
:
setattr
(
self
,
column
.
name
,
setattr
(
self
,
column
.
name
,
datetime
.
strptime
(
values
[
column
.
name
],
date_format
))
datetime
.
strptime
(
values
[
column
.
name
],
date_format
))
...
...
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