help to print votes and questions
This commit is contained in:
15
utils.py
15
utils.py
@@ -173,7 +173,7 @@ def is_voter(key, token):
|
||||
)
|
||||
return len(cur.fetchall()) > 0
|
||||
|
||||
def parse_form(key):
|
||||
def parse_form(key, questions = None, debug = None):
|
||||
form = {
|
||||
'expires': None,
|
||||
'opens': None,
|
||||
@@ -188,7 +188,9 @@ def parse_form(key):
|
||||
key = secure_filename(key)
|
||||
try:
|
||||
current_question = 0
|
||||
with open(os.path.join(app.config['QUESTIONS'], key + ".txt"), "rt", encoding = "UTF-8") as fp:
|
||||
if questions == None:
|
||||
questions = app.config['QUESTIONS']
|
||||
with open(os.path.join(questions, key + ".txt"), "rt", encoding = "UTF-8") as fp:
|
||||
for row in fp:
|
||||
if row.strip() == "":
|
||||
continue
|
||||
@@ -197,7 +199,10 @@ def parse_form(key):
|
||||
continue
|
||||
if rowsl.startswith("title: "):
|
||||
form['title'] = row[6:].strip()
|
||||
g.title = row[6:].strip()
|
||||
try:
|
||||
g.title = row[6:].strip()
|
||||
except RuntimeError:
|
||||
pass
|
||||
continue
|
||||
if rowsl.startswith("expires: "):
|
||||
form['expires'] = parse_row_date(row)
|
||||
@@ -242,7 +247,9 @@ def parse_form(key):
|
||||
})
|
||||
return form
|
||||
except Exception as err:
|
||||
if app.config['DEBUG']:
|
||||
if debug == None:
|
||||
debug = app.config['DEBUG']
|
||||
if debug:
|
||||
raise err
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user