Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
c4c42a6c
Commit
c4c42a6c
authored
Nov 17, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug dbwrite (wip:TODO re-enable doors)
parent
b6071676
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
5 deletions
+28
-5
base_form.html
base_form.html
+4
-0
comex_merci_pour_les_infos.py.cgi
cgi-bin/comex_merci_pour_les_infos.py.cgi
+18
-5
comex_reg_form_controllers.js
static/js/comex_reg_form_controllers.js
+6
-0
No files found.
base_form.html
View file @
c4c42a6c
...
...
@@ -353,6 +353,10 @@
<input
id=
"doors_uid"
name=
"doors_uid"
type=
"text"
hidden
>
</input>
<!-- hidden input for captcha verification hash -->
<input
id=
"my-captchaHash"
name=
"my-captchaHash"
type=
"text"
hidden
>
</input>
<div
class=
"row spacerrow"
>
</div><div
class=
"row spacerrow"
>
</div>
<!-- CAPTCHA & SUBMIT BTN + INFOS-->
...
...
cgi-bin/comex_merci_pour_les_infos.py.cgi
View file @
c4c42a6c
...
...
@@ -105,7 +105,9 @@ def sanitize(value):
"""
vtype
=
type
(
value
)
str_val
=
str
(
value
)
san_val
=
sub
(
r'[^\w@\.-:]'
,
''
,
str_val
)
clean_val
=
sub
(
r'^\s+'
,
''
,
str_val
)
clean_val
=
sub
(
r'\s+$'
,
''
,
clean_val
)
san_val
=
sub
(
r'[^\w@\.-:]'
,
''
,
clean_val
)
if
vtype
not
in
[
int
,
str
]:
raise
ValueError
(
"Value has an incorrect type
%
s"
%
str
(
vtype
))
...
...
@@ -114,18 +116,21 @@ def sanitize(value):
san_typed_val
=
vtype
(
san_val
)
return
san_typed_val
def
save_to_db
(
safe_rec
ords
):
def
save_to_db
(
safe_rec
s_arr
):
"""
see COLS and table_specifications.md
"""
# expected number of vals (for instance 3 vals ===> "(?,?,?)" )
db_mask
=
'('
+
','
.
join
([
'?'
for
i
in
range
(
len
(
COLS
))])
+
')'
# £TODO check if email exists first
# yes =>propose login via doors + overwrite ?)
# no => proceed
reg_db
=
connect
(
'../data/registered.db'
)
reg_db_c
=
reg_db
.
cursor
()
reg_db_c
.
execute
(
'INSERT INTO
test_table VALUES (?,?)'
,
safe_records
)
reg_db_c
.
execute
(
'INSERT INTO
comex_registrations VALUES'
+
db_mask
,
safe_recs_arr
)
reg_db
.
commit
()
reg_db
.
close
()
...
...
@@ -156,7 +161,12 @@ if __name__ == "__main__":
captcha_accepted
=
(
captcha_userhash
==
captcha_verifhash
)
# ----------------------------------------------------------------------
got_them_all
=
None
# debug data keys
# print_to_buffer(str([k for k in incoming_data]))
# print_to_buffer(str(incoming_data))
# debug doors_uid
# print_to_buffer('doors_uid before clean: '+str(incoming_data['doors_uid']))
if
captcha_accepted
:
# read in + sanitize values
...
...
@@ -175,9 +185,12 @@ if __name__ == "__main__":
# picture_bytes = picture.value
# --------------------->8---------------
# debug doors_uid
# print_to_buffer('doors_uid after clean: '+clean_records['doors_uid'])
# save to DB
# ===========
save_to_db
([
clean_records
[
k
]
for
k
in
columns
])
save_to_db
([
clean_records
.
get
(
k
,
None
)
for
k
in
COLS
])
# show received values in template
...
...
static/js/comex_reg_form_controllers.js
View file @
c4c42a6c
...
...
@@ -27,6 +27,11 @@ var regTimestamp = document.getElementById('last_modified_date')
var
uidInput
=
document
.
getElementById
(
'doors_uid'
)
var
email
=
document
.
getElementById
(
'email'
)
// captchaHash should be appended by itself if normal submit,
// but we need to do it ourselves (b/c of validateSubmit ?)
var
captcha
=
document
.
getElementById
(
'my-captcha'
)
var
captchaCheck
=
document
.
getElementById
(
'my-captchaHash'
)
var
subPage1Style
=
document
.
getElementById
(
'subpage_1'
).
style
var
subPage2Style
=
document
.
getElementById
(
'subpage_2'
).
style
var
teamCityDivStyle
=
document
.
getElementById
(
'team_city_div'
).
style
...
...
@@ -59,6 +64,7 @@ var captchaStatus = false
submitButton
.
disabled
=
true
theForm
.
onkeyup
=
beTestedAsYouGo
theForm
.
onchange
=
beTestedAsYouGo
theForm
.
onblur
=
beTestedAsYouGo
// done when anything in the form changes
function
beTestedAsYouGo
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment