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 3d6d139c
authored
May 12, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add form_validation method to handle form submission and validation logic
1 parent
f42dcdf5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
opensipkd/base/views/base_views.py
opensipkd/base/views/register.py
opensipkd/base/views/base_views.py
View file @
3d6d139
...
@@ -929,6 +929,50 @@ class BaseView(object):
...
@@ -929,6 +929,50 @@ class BaseView(object):
value
[
k
]
=
cstruct
.
get
(
k
)
value
[
k
]
=
cstruct
.
get
(
k
)
return
value
return
value
def
form_validation
(
self
,
form
,
**
kwargs
):
table
=
kwargs
.
get
(
"table"
,
None
)
controls
=
self
.
req
.
POST
.
items
()
if
self
.
req
.
is_xhr
:
cloned
=
self
.
req
.
POST
.
items
()
control
=
[]
for
ctrl
in
cloned
:
if
isinstance
(
ctrl
[
1
],
FieldStorage
):
control
.
append
(
(
"__start__"
,
f
"{ctrl[0]}:mapping"
))
control
.
append
((
"upload"
,
ctrl
[
1
]))
control
.
append
((
"uid"
,
""
))
control
.
append
((
"__end__"
,
f
"{ctrl[0]}:mapping"
))
log
.
debug
(
"Control:
%
s"
,
ctrl
)
else
:
control
.
append
(
ctrl
)
controls
=
iter
(
control
)
try
:
c
=
form
.
validate
(
controls
)
except
ValidationFailure
as
e
:
log
.
error
(
f
"Add cstruct: {e.cstruct}"
)
log
.
error
(
f
"Add Error: {str(e.error)}"
)
# log.error(f"Add Error: {str(e.asdict)}")
value
=
self
.
before_add
()
if
self
.
req
.
is_xhr
:
error
=
e
.
error
.
asdict
()
# error.update(value)
# return self.resp_xhr({"error": error})
form
.
set_appstruct
(
e
.
cstruct
)
return
self
.
returned_form
(
form
,
error
=
error
)
for
f
in
e
.
field
.
children
:
if
isinstance
(
f
.
typ
,
colander
.
Date
):
e
.
cstruct
[
f
.
name
]
=
date_from_str
(
e
.
cstruct
[
f
.
name
])
# if f.name == "captcha":
# e.cstruct[f.name] = self.get_captcha_url()
value
=
self
.
update_value
(
value
,
e
.
cstruct
)
form
.
set_appstruct
(
value
)
kwargs
[
"table"
]
=
table
return
self
.
returned_form
(
form
,
**
kwargs
)
return
dict
(
c
)
def
view_add
(
self
,
**
kwargs
):
def
view_add
(
self
,
**
kwargs
):
# bindings = self.get_bindings()
# bindings = self.get_bindings()
form
=
self
.
get_form
(
self
.
add_schema
,
**
kwargs
)
form
=
self
.
get_form
(
self
.
add_schema
,
**
kwargs
)
...
...
opensipkd/base/views/register.py
View file @
3d6d139
...
@@ -360,6 +360,7 @@ class Views(BaseView):
...
@@ -360,6 +360,7 @@ class Views(BaseView):
value
[
"idcard"
]
=
upload
.
save_fp
(
idcard
)
value
[
"idcard"
]
=
upload
.
save_fp
(
idcard
)
else
:
else
:
value
.
pop
(
"idcard"
)
value
.
pop
(
"idcard"
)
if
not
self
.
req
.
user
:
value
[
"groups"
]
=
"Guest"
value
[
"groups"
]
=
"Guest"
super
()
.
form_validator
(
form
,
value
)
super
()
.
form_validator
(
form
,
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