Skip to content

Commit

Permalink
allow not selected
Browse files Browse the repository at this point in the history
  • Loading branch information
gjelsas authored and Pierre-Sassoulas committed Oct 29, 2024
1 parent 5b76cd7 commit 9973f15
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions survey/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ def clean_choices(self, s):
value = self.cleaned_data
print(value)
for q in s.questions.all():
if q.type in ["select-multiple"]:
# Only for SELECT_MULTIPlE
if q.type in ["select-multiple"] and q.maximum_choices:
# Only for SELECT_MULTIPlE and if maximum_choices is set
question = q
max = question.maximum_choices
if value.get(f"question_{question.id}"):
Expand Down
2 changes: 1 addition & 1 deletion survey/models/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Question(models.Model):
survey = models.ForeignKey(Survey, on_delete=models.CASCADE, verbose_name=_("Survey"), related_name="questions")
type = models.CharField(_("Type"), max_length=200, choices=QUESTION_TYPES, default=TEXT)
choices = models.TextField(_("Choices"), blank=True, null=True, help_text=CHOICES_HELP_TEXT)
maximum_choices = models.IntegerField(_("Maximum possible Answers"))
maximum_choices = models.IntegerField(_("Maximum possible Answers"), blank=True, null=True)

class Meta:
verbose_name = _("question")
Expand Down

0 comments on commit 9973f15

Please sign in to comment.