diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-10-03 14:50:05 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-10-03 14:50:05 (GMT) |
commit | 6726b1a581f5483ed8512fdd2aa91af9e3a69d9a (patch) | |
tree | ca0598274a459d32ea903bdfbfddf5cdbec24065 /webapp/polls/models.py | |
parent | f18e20e4a22eb5e5f31bc22602a2950ced294af9 (diff) |
Remove validate method and move the logic to exists method
Diffstat (limited to 'webapp/polls/models.py')
-rw-r--r-- | webapp/polls/models.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/webapp/polls/models.py b/webapp/polls/models.py index f4689ed..103feee 100644 --- a/webapp/polls/models.py +++ b/webapp/polls/models.py @@ -1551,13 +1551,6 @@ 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() @@ -1572,4 +1565,10 @@ class PollResultFile(object): poll = Poll.get(poll_id) result_path = os.path.join(poll.results_path, self.get_file_name()) exists = os.path.exists(result_path) + + if not exists: + results = poll.get_result_files() + hashes = [result.hash for result in results] + exists = self.hash in hashes + return exists |