mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
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:
committed by
Raphael Michel
parent
68967fbfda
commit
3583dde1db
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user