Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/webapp/polls/models.py
diff options
context:
space:
mode:
authorRogelio Mita <rogeliomita@activitycentral.com>2013-10-02 20:45:16 (GMT)
committer Rogelio Mita <rogeliomita@activitycentral.com>2013-10-02 20:57:53 (GMT)
commitb59642c202eb607e566c9bf1f82d3869c9b611e3 (patch)
treeea93781c19caa325f1e37d96ef3f11ee554ad1cb /webapp/polls/models.py
parentb24ae656ea377212be96b5d2d6969f94306fca9d (diff)
Add validate method for PollResultFile: Validates only if exists some result file with same content
Diffstat (limited to 'webapp/polls/models.py')
-rw-r--r--webapp/polls/models.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/webapp/polls/models.py b/webapp/polls/models.py
index a44cf94..d53d578 100644
--- a/webapp/polls/models.py
+++ b/webapp/polls/models.py
@@ -1551,6 +1551,13 @@ class PollResultFile(object):
file_path = self.file_path
os.remove(file_path)
+ def validate(self):
+ poll_id = self.data['poll_id']
+ poll = Poll.get(poll_id)
+ results = poll.get_result_files()
+ hashes = [result.hash for result in results]
+ return self.hash not in hashes
+
@property
def hash(self):
data = self.get_data()