Fix #202 -- Allow the manual ordering of questions

* Allow the manual ordering of questions
Update Unit Tests
Fix some typos

* Add migrations

* Minor notation change
This commit is contained in:
Enrique Saez
2016-08-29 18:36:56 +02:00
committed by Raphael Michel
parent 68967fbfda
commit 3583dde1db
8 changed files with 119 additions and 2 deletions

View File

@@ -386,10 +386,14 @@ class Question(LoggedModel):
blank=True,
help_text=_('This question will be asked to buyers of the selected products')
)
position = models.IntegerField(
default=0
)
class Meta:
verbose_name = _("Question")
verbose_name_plural = _("Questions")
ordering = ('position', 'id')
def __str__(self):
return str(self.question)
@@ -404,6 +408,13 @@ class Question(LoggedModel):
if self.event:
self.event.get_cache().clear()
@property
def sortkey(self):
return self.position, self.id
def __lt__(self, other) -> bool:
return self.sortkey < other.sortkey
class QuestionOption(models.Model):
question = models.ForeignKey('Question', related_name='options')