diff options
author | etienne <etienne@07715635-78ed-41b0-aaf1-0afda6c37f35> | 2009-12-04 13:33:06 +0000 |
---|---|---|
committer | etienne <etienne@07715635-78ed-41b0-aaf1-0afda6c37f35> | 2009-12-04 13:33:06 +0000 |
commit | 442d34494354cbca1cad022290db417ae7a7aede (patch) | |
tree | 84e2371fb94945e7ac456da41ddfeb68e5f1f1e3 /polls/models.py | |
parent | 25e778bebb1804aeaf0d7716119bcbfbe967e8b2 (diff) | |
download | Papillon-442d34494354cbca1cad022290db417ae7a7aede.tar.bz2 Papillon-442d34494354cbca1cad022290db417ae7a7aede.zip |
Template cleaning - Simplification - Use of newforms
Diffstat (limited to 'polls/models.py')
-rw-r--r-- | polls/models.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/polls/models.py b/polls/models.py index 82981f7..f5b9cbb 100644 --- a/polls/models.py +++ b/polls/models.py @@ -56,7 +56,8 @@ modify the current poll")) category = models.ForeignKey(Category, null=True, blank=True) TYPE = (('P', _('Yes/No poll')), ('B', _('Yes/No/Maybe poll')), - ('O', _('One choice poll')),) + ('O', _('One choice poll')), + ('V', _('Valuable choice poll')),) type = models.CharField(max_length=1, choices=TYPE, verbose_name=_("Type of the poll"), help_text=_("""Type of the poll: @@ -64,6 +65,8 @@ modify the current poll")) - "Yes/No poll" is the appropriate type for a simple multi-choice poll - "Yes/No/Maybe poll" allows voters to stay undecided - "One choice poll" gives only one option to choose from + - "Valuable choice poll" permit users to give a note between 0 to 10 to \ +different choices """)) dated_choices = models.BooleanField(verbose_name=_("Choices are dates"), default=False, help_text=_("Check this option to choose between dates")) @@ -113,6 +116,19 @@ the poll/check the poll to reopen it")) Get choices associated to this vote""" return Choice.objects.filter(poll=self) + def reorder(self): + """ + Reorder choices of the poll""" + if not self.dated_choices: + return + choices = self.getChoices() + sort_fct = lambda x:datetime.datetime.strptime(x.name, + '%Y-%m-%d %H:%M:%S') + choices = sorted(choices, key=sort_fct) + for idx, choice in enumerate(choices): + choice.order = idx + choice.save() + class Admin: pass class Meta: |