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 2b74d196
authored
Jan 29, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refactor: Clean up imports and adjust form validation method in ApiViews
1 parent
ac47be27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
opensipkd/base/views/api_base.py
opensipkd/base/views/api_base.py
View file @
2b74d19
from
datetime
import
datetime
,
date
from
datetime
import
datetime
,
date
import
logging
import
logging
import
colander
from
decimal
import
Decimal
from
decimal
import
Decimal
from
math
import
log
from
deform
import
Form
,
ValidationFailure
from
deform
import
Form
,
ValidationFailure
,
form
from
opensipkd.webr.models.users
import
User
from
opensipkd.webr.models.users
import
User
from
pyramid.response
import
Response
from
pyramid.response
import
Response
from
opensipkd.base.models
import
DBSession
from
opensipkd.base.models
import
DBSession
from
opensipkd.tools.buttons
import
btn_save
,
btn_cancel
from
opensipkd.tools
import
get_settings
from
opensipkd.base.views.common
import
DataTables
,
ColumnDT
from
deform.widget
import
SelectWidget
from
deform.widget
import
SelectWidget
from
pyramid.response
import
Response
from
pyramid.response
import
Response
from
pyramid.httpexceptions
import
*
from
pyramid.httpexceptions
import
*
import
colander
from
opensipkd.tools.buttons
import
btn_save
,
btn_cancel
from
opensipkd.tools
import
get_settings
from
opensipkd.base.views.common
import
DataTables
,
ColumnDT
from
.
import
api_messages
from
.
import
api_messages
from
..tools
import
obj2json
from
..tools
import
obj2json
...
@@ -241,12 +240,11 @@ class ApiViews(APIView):
...
@@ -241,12 +240,11 @@ class ApiViews(APIView):
d
=
self
.
get_custom_render
(
d
)
d
=
self
.
get_custom_render
(
d
)
return
Response
(
json
=
json
.
loads
(
json
.
dumps
(
d
,
default
=
self
.
json_adapter
)))
return
Response
(
json
=
json
.
loads
(
json
.
dumps
(
d
,
default
=
self
.
json_adapter
)))
def
form_validator
(
self
,
form
,
controls
):
"""Get Validator Form"""
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
req
=
request
self
.
req
=
request
form
=
self
.
get_form
(
self
.
add_schema
,
validator
=
self
.
form_validator
)
form
=
self
.
get_form
(
self
.
add_schema
,
validator
=
self
.
form_validator
)
# TODO: harus mengakomodir data dari json juga
controls
=
self
.
req
.
POST
.
items
()
controls
=
self
.
req
.
POST
.
items
()
try
:
try
:
data
=
self
.
form_validate
(
form
,
controls
)
data
=
self
.
form_validate
(
form
,
controls
)
...
...
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