From 366b11d73379c239c13449b23c3e7acf0b589fdc Mon Sep 17 00:00:00 2001 From: lars Date: Thu, 15 Apr 2010 10:58:36 +0000 Subject: [PATCH] added poll deletion --- wortschlucker/database.sqlite | Bin 4096 -> 4096 bytes .../templates/poll_admin_details.html | 1 + wortschlucker/wortschlucker.py | 20 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/wortschlucker/database.sqlite b/wortschlucker/database.sqlite index 04c9929b4c1fc1ffbcddb3b705250e6c76e5ac6d..3cfa91c95600f9cc5bebb7f67343a0384568ebab 100644 GIT binary patch delta 56 zcmZorXi%6S&1k(*<^?kk0}BHKvpTanlO>boW?_Q3lISSmE#Z9 delta 492 zcmaLTJxT*n5C`yNH^mk<0eB{AT7cf6Si_hUV??Bi$J#Zje5wr^##L-gif5$+{V3gK=4&jOCSI zv|3>e;0)I6h&8$xq_2D}4ESgQX=WBq_`33%YNLX5jE)Q$i%==OjO|k9t2yUwGjFOX z3J?=P6Hqx|fv!;IA${key}: ${value}
  • Edit this poll
  • +
  • Delete this poll
  • diff --git a/wortschlucker/wortschlucker.py b/wortschlucker/wortschlucker.py index 8bca1cf..88f990a 100755 --- a/wortschlucker/wortschlucker.py +++ b/wortschlucker/wortschlucker.py @@ -77,6 +77,15 @@ class Poll(sqlobject.SQLObject): def get_num_of_submissions(self): return WordSubmission.selectBy(poll_id=self.id).count() + def delete_poll(self): + submissions = WordSubmission.selectBy(poll_id=self.id) + settings = PollSetting.selectBy(poll_id=self.id) + for submission in submissions: + submission.destroySelf() + for setting in settings: + setting.destroySelf() + self.destroySelf() + def get_url(self): return "%spolls/%s" % (BASE_DICT["base_url"], self.hash_key) @@ -86,6 +95,9 @@ class Poll(sqlobject.SQLObject): def get_edit_url(self): return "%spolls/%s/admin" % (BASE_DICT["base_url"], self.admin_hash_key) + def get_delete_url(self): + return "%spolls/%s/delete" % (BASE_DICT["base_url"], self.admin_hash_key) + def get_creation_time_string(self): return str(self.timestamp_creation) @@ -171,6 +183,14 @@ def new_poll(submit=None, cancel=None, author=None, title=None, description=None new_poll = Poll(hash_key=hash_key, admin_hash_key=admin_hash_key, timestamp_creation=now, **data) return bobo.redirect(new_poll.get_admin_url()) +@bobo.query('/polls/:admin_hash_key/delete') +def delete_poll(admin_hash_key=None): + admin_poll_id = get_poll_admin_id(admin_hash_key) + if not admin_poll_id is None: + poll = Poll.get(admin_poll_id) + poll.delete_poll() + return bobo.redirect(BASE_DICT["base_url"]) + @bobo.query('/polls/:admin_hash_key/admin') def admin_poll(cancel=False, submit=None, admin_hash_key=None, author=None, title=None, description=None, **kwargs): value_dict = get_default_values()