added the variable 'authlevel' to make providing context-relevant links in the templates easier.

This commit is contained in:
phear 2013-01-13 12:55:05 +00:00
parent 68bc594184
commit 4b089f4494

View file

@ -48,6 +48,7 @@ BASE_DICT = {
"base_url": "/", # the trailing slash is necessary "base_url": "/", # the trailing slash is necessary
"show_navbar": True, "show_navbar": True,
"errors": {}, "errors": {},
"authlevel": "public", #authentiction level of template: one of "public" (e.g. frontpage), "poll_public" (e.g. poll_details),"poll_admin" (poll_admin_details","admin" (admin interface)
} }
# used as the default setting for expose/close dates # used as the default setting for expose/close dates
@ -815,8 +816,9 @@ def vote_submission_order(bobo_request, hash_key=None, submitter=None,
vote_order=None): vote_order=None):
value_dict = get_default_values(bobo_request) value_dict = get_default_values(bobo_request)
value_dict["errors"] = {} value_dict["errors"] = {}
value_dict["authlevel"] = "poll_public"
data = {} data = {}
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.strip() data["submitter"] = submitter.strip()
if not vote_order: if not vote_order:
vote_order = "" vote_order = ""
@ -862,6 +864,7 @@ def vote_submission_order(bobo_request, hash_key=None, submitter=None,
def submit_content(bobo_request, hash_key=None, submitter=None, content=None): 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"] = {}
value_dict["authlevel"] = "poll_public"
data = {} data = {}
if content and (not is_spam_content(content, value_dict["errors"])): if content and (not is_spam_content(content, value_dict["errors"])):
data["content"] = content data["content"] = content
@ -970,6 +973,7 @@ def admin_poll(bobo_request, cancel=False, submit=None, admin_hash_key=None, aut
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 value_dict["poll"] = poll
value_dict["authlevel"] = "poll_admin"
# 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())
@ -1169,6 +1173,7 @@ def render_poll_admin(bobo_request, poll, add_related, del_related, count, page,
value_dict["count"] = count value_dict["count"] = count
value_dict["show_delete"] = show_delete value_dict["show_delete"] = show_delete
value_dict["errors"] = errors value_dict["errors"] = errors
value_dict["authlevel"] = "poll_admin"
return render("poll_admin_details.html", **value_dict) return render("poll_admin_details.html", **value_dict)
@bobo.query('/admin') @bobo.query('/admin')
@ -1221,6 +1226,7 @@ def show_one_poll(bobo_request, poll_hash_for_admin=None, poll_hash=None,
value_dict["poll"] = poll value_dict["poll"] = poll
value_dict["page"] = page value_dict["page"] = page
value_dict["count"] = count value_dict["count"] = count
value_dict["authlevel"] = "poll_public"
return render("poll_details.html", **value_dict) return render("poll_details.html", **value_dict)
else: else:
admin_poll_id = get_poll_admin_id(poll_hash) admin_poll_id = get_poll_admin_id(poll_hash)