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 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
from
deform
import
(
widget
,
Form
,
ValidationFailure
,
FileData
,
)
from
deform.widget
import
SelectWidget
from
opensipkd.base.views.upload
import
tmpstore
from
pyramid.httpexceptions
import
HTTPFound
,
HTTPNotFound
from
opensipkd.tools
import
dmy
,
get_settings
,
get_ext
,
\
date_from_str
,
get_random_string
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
from
opensipkd.tools.captcha
import
get_captcha
from
opensipkd.tools.report
import
csv_response
,
file_response
from
pyramid.httpexceptions
import
HTTPFound
,
HTTPNotFound
from
.common
import
DataTables
from
..
import
DBSession
,
get_params
,
get_urls
from
..scripts.initializedb
import
append_csv
...
...
@@ -266,7 +266,7 @@ class BaseView(object):
return
{}
def
next_view
(
self
,
form
,
**
kwargs
):
return
self
.
route_list
()
return
def
next_edit
(
self
,
form
,
**
kwargs
):
return
self
.
route_list
(
**
kwargs
)
...
...
@@ -292,13 +292,20 @@ class BaseView(object):
**
kwargs
)
def
view_buttons
(
self
,
row
):
result
=
(
btn_close
,)
return
result
def
view_view
(
self
,
**
kwargs
):
# row = query_id(request).first()
request
=
self
.
req
row
=
self
.
query_id
()
.
first
()
if
not
row
:
return
self
.
id_not_found
()
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
,
bindings
=
bindings
)
if
request
.
POST
:
...
...
@@ -609,6 +616,9 @@ class BaseView(object):
"""
return
form
def
edit_restrict
(
self
,
row
):
return
False
def
view_edit
(
self
,
**
kwargs
):
request
=
self
.
req
row
=
self
.
query_id
()
.
first
()
...
...
@@ -616,6 +626,9 @@ class BaseView(object):
if
not
row
:
return
self
.
id_not_found
(
**
kwargs
)
if
self
.
edit_restrict
(
row
):
return
self
.
route_list
(
**
kwargs
)
if
not
self
.
bindings
:
self
.
bindings
=
self
.
get_bindings
(
row
)
...
...
opensipkd/base/views/widget_os.py
View file @
0d44954
...
...
@@ -585,6 +585,7 @@ class BootStrapDateInputWidget(Widget):
if
pstruct
in
(
""
,
null
):
return
null
try
:
_logging
.
debug
(
f
"Date:{self._pstruct_schema}"
)
validated
=
self
.
_pstruct_schema
.
deserialize
(
pstruct
)
except
Invalid
as
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
from
sqlalchemy.orm
import
(
scoped_session
,
sessionmaker
,
Session
)
from
zope.sqlalchemy
import
register
_logging
=
logging
.
getLogger
(
__name__
)
class
MySession
(
Session
):
def
execute
(
self
,
clause
,
params
=
None
,
mapper
=
None
,
**
kw
):
...
...
@@ -67,8 +68,8 @@ class CommonModel(object):
def
from_dict
(
self
,
values
,
date_format
=
"
%
d-
%
m-
%
Y"
):
for
column
in
self
.
__table__
.
columns
:
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
values
[
column
.
name
]
and
type
(
values
[
column
.
name
])
is
String
:
setattr
(
self
,
column
.
name
,
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