bereinigt, umbenannt

This commit is contained in:
lars 2012-06-08 14:34:00 +00:00
parent 08727955e9
commit 0300339326

View file

@ -65,7 +65,8 @@ POLL_SETTINGS = {
"public": (bool, False),
"expose_date": (datetime.datetime, DEFAULT_DATE),
"close_date": (datetime.datetime, DEFAULT_DATE),
"vote_open": (bool, False),
"vote_enabled": (bool, False),
"vote_closed": (bool, False),
}
POLL_SETTING_TEMPLATES = {
@ -98,10 +99,7 @@ class ContentSubmission(sqlobject.SQLObject):
def get_delete_url(self, absolute=False):
return self.poll_id.get_admin_url(absolute=absolute,
suffix="/delete/%s" % self.get_obfuscated_digest())
def get_vote_toggle_url(self, absolute=False):
return self.poll_id.get_admin_url(absolute=absolute,
suffix="/vote_toggle/%s" % self.get_obfuscated_digest())
def get_obfuscated_digest(self):
return hashlib.md5(str(self.id)).hexdigest()
@ -246,10 +244,9 @@ class Poll(sqlobject.SQLObject):
def get_submit_url(self, absolute=False):
return get_url_string("%s%s/submit" % (BASE_DICT["base_url"], self.hash_key), absolute)
#TODO vote: Diese Funktion ist noch falsch, aber erstmal als Platzhalter noetig
def get_vote_url(self, absolute=False):
return get_url_string("%s%s/submit" % (BASE_DICT["base_url"], self.hash_key), absolute)
#TODO vote: Diese Funktion ist noch falsch, aber erstmal als Platzhalter noetig
return ""
def get_admin_url(self, absolute=False, suffix=""):
return get_url_string("%s%s%s" % (BASE_DICT["base_url"], self.admin_hash_key, suffix), absolute)
@ -260,14 +257,14 @@ class Poll(sqlobject.SQLObject):
def get_delete_url(self, absolute=False):
return get_url_string("%s%s/delete" % (BASE_DICT["base_url"], self.admin_hash_key), absolute)
def get_vote_toggle_url(self, absolute=False):
return get_url_string("%s%s/vote_toggle" % (BASE_DICT["base_url"], self.admin_hash_key), absolute)
def get_vote_enable_url(self, absolute=False):
return get_url_string("%s%s/vote_enable" % (BASE_DICT["base_url"], self.admin_hash_key), absolute)
def get_creation_time_string(self):
return str(self.timestamp_creation)
def is_vote_open(self):
return self.get_settings()["vote_open"]
def is_vote_enabled(self):
return self.get_settings()["vote_enabled"]
def get_submissions_visibility(self):
settings = self.get_settings()
@ -787,14 +784,13 @@ def delete_poll(bobo_request, admin_hash_key=None):
poll.delete_poll()
return bobo.redirect(BASE_DICT["base_url"])
@bobo.query('/:admin_hash_key/vote_toggle')
def vote_toggle_poll(bobo_request, admin_hash_key=None, vote_select=None):
## vote_radio: open/closed
# vote_select: open/closed
@bobo.query('/:admin_hash_key/vote_enable')
def vote_enable_poll(bobo_request, admin_hash_key=None, vote_select=None):
# vote_select: on/off
admin_poll_id = get_poll_admin_id(admin_hash_key)
if not admin_poll_id is None:
poll = Poll.get(admin_poll_id)
poll.change_setting("vote_open", vote_select == "open")
poll.change_setting("vote_enabled", vote_select == "on")
return bobo.redirect(poll.get_admin_url())
else:
return bobo.redirect(BASE_DICT["base_url"])