added stubs for user management. the spam check functions seemed to give inconsistent results, fixed now.
This commit is contained in:
parent
424d2d5603
commit
68bc594184
1 changed files with 45 additions and 4 deletions
|
@ -584,9 +584,9 @@ def is_spam_submitter_name(name, errors_dict):
|
||||||
(len(lower_text) > 3) and (len(upper_text) > 3) and \
|
(len(lower_text) > 3) and (len(upper_text) > 3) and \
|
||||||
(len(name) >= 8) and (not name.startswith(upper_text)):
|
(len(name) >= 8) and (not name.startswith(upper_text)):
|
||||||
errors_dict["submitter"] = "Spam-Verdacht: bitte den Namen korrigieren"
|
errors_dict["submitter"] = "Spam-Verdacht: bitte den Namen korrigieren"
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def is_spam_content(text, errors_dict):
|
def is_spam_content(text, errors_dict):
|
||||||
if re.search(r"(<a\s|\shref=|</a>)", text.lower()):
|
if re.search(r"(<a\s|\shref=|</a>)", text.lower()):
|
||||||
|
@ -771,6 +771,45 @@ def new_poll(bobo_request, submit=None, cancel=None, author=None, title=None,
|
||||||
new_poll.change_setting(key, value)
|
new_poll.change_setting(key, value)
|
||||||
return bobo.redirect(new_poll.get_admin_url())
|
return bobo.redirect(new_poll.get_admin_url())
|
||||||
|
|
||||||
|
|
||||||
|
@bobo.query('/login')
|
||||||
|
@bobo.query('/login/')
|
||||||
|
def show_login(bobo_request):
|
||||||
|
""" shows a form for logging in and creating an account"""
|
||||||
|
value_dict = get_default_values(bobo_request)
|
||||||
|
return render("login.html", **value_dict)
|
||||||
|
|
||||||
|
|
||||||
|
@bobo.query('/newprofile')
|
||||||
|
@bobo.query('/newprofile/')
|
||||||
|
def show_newprofile(bobo_request):
|
||||||
|
""" Show polls and account data of this user and allows for changing the password. """
|
||||||
|
value_dict = get_default_values(bobo_request)
|
||||||
|
return render("profile.html", **value_dict)
|
||||||
|
|
||||||
|
@bobo.query('/:hash_key/vote_result.csv')
|
||||||
|
def vote_result(bobo_request, hash_key=None):
|
||||||
|
value_dict = get_default_values(bobo_request)
|
||||||
|
value_dict["errors"] = {}
|
||||||
|
data = {}
|
||||||
|
poll_id = get_poll_id(hash_key)
|
||||||
|
preorder = ["Paintball", "Billard", "Eislaufen", "Kegeln", "Kneipengang", "Karaoke", "Tischtennis", "Bowling", "Geek-out", "Go-Kart", "Dart"]
|
||||||
|
if not poll_id is None:
|
||||||
|
poll = Poll.get(poll_id)
|
||||||
|
voters = []
|
||||||
|
for submission in ContentSubmission.selectBy(poll_id=poll.id):
|
||||||
|
for vote in VoteOrder.selectBy(content_submission_id=submission):
|
||||||
|
if not vote.submitter in voters:
|
||||||
|
voters.append(vote.submitter)
|
||||||
|
lines = []
|
||||||
|
for voter in voters:
|
||||||
|
sorting = poll.get_ordered_submissions(voter)
|
||||||
|
items = [str(preorder.index(submission.content) + 1) for submission in sorting]
|
||||||
|
lines.append(" ".join(items))
|
||||||
|
return os.linesep.join(lines)
|
||||||
|
else:
|
||||||
|
return bobo.redirect(BASE_DICT["base_url"])
|
||||||
|
|
||||||
@bobo.query('/:hash_key/vote')
|
@bobo.query('/:hash_key/vote')
|
||||||
def vote_submission_order(bobo_request, hash_key=None, submitter=None,
|
def vote_submission_order(bobo_request, hash_key=None, submitter=None,
|
||||||
vote_order=None):
|
vote_order=None):
|
||||||
|
@ -824,9 +863,9 @@ def submit_content(bobo_request, hash_key=None, submitter=None, content=None):
|
||||||
value_dict = get_default_values(bobo_request)
|
value_dict = get_default_values(bobo_request)
|
||||||
value_dict["errors"] = {}
|
value_dict["errors"] = {}
|
||||||
data = {}
|
data = {}
|
||||||
if content and is_spam_content(content, value_dict["errors"]):
|
if content and (not is_spam_content(content, value_dict["errors"])):
|
||||||
data["content"] = content
|
data["content"] = content
|
||||||
if submitter and is_spam_submitter_name(submitter, value_dict["errors"]):
|
if submitter and (not is_spam_submitter_name(submitter, value_dict["errors"])):
|
||||||
data["submitter"] = submitter
|
data["submitter"] = submitter
|
||||||
poll_id = get_poll_id(hash_key)
|
poll_id = get_poll_id(hash_key)
|
||||||
if not poll_id is None:
|
if not poll_id is None:
|
||||||
|
@ -930,6 +969,7 @@ def admin_poll(bobo_request, cancel=False, submit=None, admin_hash_key=None, aut
|
||||||
if poll_id is None:
|
if poll_id is None:
|
||||||
return bobo.redirect(BASE_DICT["base_url"])
|
return bobo.redirect(BASE_DICT["base_url"])
|
||||||
poll = Poll.get(poll_id)
|
poll = Poll.get(poll_id)
|
||||||
|
value_dict["poll"] = poll
|
||||||
# cancel: return to (non-edit) admin page
|
# cancel: return to (non-edit) admin page
|
||||||
if cancel:
|
if cancel:
|
||||||
return bobo.redirect(poll.get_admin_url())
|
return bobo.redirect(poll.get_admin_url())
|
||||||
|
@ -1194,6 +1234,7 @@ def show_one_poll(bobo_request, poll_hash_for_admin=None, poll_hash=None,
|
||||||
else:
|
else:
|
||||||
return bobo.redirect(BASE_DICT["base_url"])
|
return bobo.redirect(BASE_DICT["base_url"])
|
||||||
|
|
||||||
|
|
||||||
@bobo.query('/node/:pagename')
|
@bobo.query('/node/:pagename')
|
||||||
def show_static_nodes(bobo_request, pagename=None):
|
def show_static_nodes(bobo_request, pagename=None):
|
||||||
""" meant for serving hand-changed, automatically styled content. """
|
""" meant for serving hand-changed, automatically styled content. """
|
||||||
|
|
Loading…
Reference in a new issue