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
8752fdaf
Commit
8752fdaf
authored
8 years ago
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarify debug elements
parent
b7459b4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
comex_merci_pour_les_infos.py.cgi
cgi-bin/comex_merci_pour_les_infos.py.cgi
+29
-14
thank_you.html
templates/thank_you.html
+2
-2
No files found.
cgi-bin/comex_merci_pour_les_infos.py.cgi
View file @
8752fdaf
...
@@ -3,6 +3,14 @@
...
@@ -3,6 +3,14 @@
Package: Registration page for comex app
Package: Registration page for comex app
File: CGI script for collecting form
File: CGI script for collecting form
Context:
- static input form validated fields and checked if all were present
(base_form.html + static/js/comex_reg_form_controllers.js)
- Doors recorded the email + password combination
- POSSIBLE Doors validated the email was new ??
"""
"""
__author__
=
"CNRS"
__author__
=
"CNRS"
__copyright__
=
"Copyright 2016 ISCPIF-CNRS"
__copyright__
=
"Copyright 2016 ISCPIF-CNRS"
...
@@ -18,11 +26,12 @@ from jinja2 import Template, Environment, FileSystemLoader
...
@@ -18,11 +26,12 @@ from jinja2 import Template, Environment, FileSystemLoader
from
sys
import
stdout
# for direct buffer write of utf-8 bytes
from
sys
import
stdout
# for direct buffer write of utf-8 bytes
from
sqlite3
import
connect
from
sqlite3
import
connect
# debug
# debug
# £TODO comment before prod -------------------8<--------------------
import
cgitb
import
cgitb
cgitb
.
enable
()
cgitb
.
enable
()
from
glob
import
glob
from
glob
import
glob
# --------------------------------------------------------8<--------------------
# templating setup
# templating setup
templating_env
=
Environment
(
loader
=
FileSystemLoader
(
'../templates'
),
templating_env
=
Environment
(
loader
=
FileSystemLoader
(
'../templates'
),
...
@@ -99,6 +108,11 @@ def save_to_db(safe_records):
...
@@ -99,6 +108,11 @@ def save_to_db(safe_records):
- team/lab if applicable
- team/lab if applicable
- organization type
- organization type
"""
"""
# £TODO check if email exists first
# yes =>propose login via doors + overwrite ?)
# no => proceed
reg_db
=
connect
(
'../data/registered.db'
)
reg_db
=
connect
(
'../data/registered.db'
)
reg_db_c
=
reg_db
.
cursor
()
reg_db_c
=
reg_db
.
cursor
()
reg_db_c
.
execute
(
'INSERT INTO test_table VALUES (?,?)'
,
safe_records
)
reg_db_c
.
execute
(
'INSERT INTO test_table VALUES (?,?)'
,
safe_records
)
...
@@ -132,15 +146,13 @@ if __name__ == "__main__":
...
@@ -132,15 +146,13 @@ if __name__ == "__main__":
captcha_accepted
=
(
captcha_userhash
==
captcha_verifhash
)
captcha_accepted
=
(
captcha_userhash
==
captcha_verifhash
)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# for debug
captcha_accepted
=
True
if
captcha_accepted
:
if
captcha_accepted
:
expected
=
[
'email'
,
'hon_title'
,
'first_name'
,
'middle_name'
,
expected
=
[
'email'
,
'hon_title'
,
'first_name'
,
'middle_name'
,
'last_name'
,
'initials'
,
'keywords'
,
'country'
,
'last_name'
,
'initials'
,
'keywords'
,
'country'
,
'organization'
]
'organization'
]
columns
=
[
'email'
,
'initials'
]
# read in + sanitize values
# read in + sanitize values
# =========================
# =========================
...
@@ -152,9 +164,6 @@ if __name__ == "__main__":
...
@@ -152,9 +164,6 @@ if __name__ == "__main__":
else
:
else
:
missing_fields
.
append
(
field
)
missing_fields
.
append
(
field
)
# keywordsss = incoming_data['keywords'].value # single string but ','-separated
# keywordzzz = incoming_data.getlist(keywords) # array
# --------- todo ------>8--------------
# --------- todo ------>8--------------
# optional
# optional
# picture = form["user_picture"]
# picture = form["user_picture"]
...
@@ -165,21 +174,27 @@ if __name__ == "__main__":
...
@@ -165,21 +174,27 @@ if __name__ == "__main__":
# debug data keys
# debug data keys
# print([k for k in incoming_data])
# print([k for k in incoming_data])
# NB will be done in js
got_them_all
=
True
for
k
in
columns
:
if
k
in
missing_fields
:
got_them_all
=
False
break
# sanitize & save to DB
# sanitize & save to DB
# =====================
# =====================
save_to_db
([
save_to_db
([
clean_records
[
k
]
for
k
in
columns
])
clean_records
[
'email'
],
clean_records
[
'initials'
]
])
# show received values in template
# show received values in template
# ================================
# ================================
print_to_buffer
(
print_to_buffer
(
template_thanks
.
render
(
template_thanks
.
render
(
form_accepted
=
captcha_accepted
,
form_accepted
=
captcha_accepted
,
# for debug
# for debug
records
=
clean_records
,
records
=
clean_records
,
globp
=
glob
(
'../data/*'
)
message
=
"got_them_all:"
+
str
(
got_them_all
)
)
)
)
)
...
...
This diff is collapsed.
Click to expand it.
templates/thank_you.html
View file @
8752fdaf
...
@@ -80,8 +80,8 @@
...
@@ -80,8 +80,8 @@
<p>
{{key}} {{records[key]}}
</p>
<p>
{{key}} {{records[key]}}
</p>
{% endfor %}
{% endfor %}
<h3>
glob(.)
</h3>
<h3>
debug message
</h3>
{{
globp
}}
{{
message
}}
</div>
</div>
<div
class=
"spacer col-sm-2 col-md-2"
>
</div>
<div
class=
"spacer col-sm-2 col-md-2"
>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
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