diff --git a/doc/api/resources/questions.rst b/doc/api/resources/questions.rst index 727d8f089b..512a8ec0d2 100644 --- a/doc/api/resources/questions.rst +++ b/doc/api/resources/questions.rst @@ -38,6 +38,8 @@ identifier string An arbitrary st ask_during_checkin boolean If ``true``, this question will not be asked while buying the ticket, but will show up when redeeming the ticket instead. +hidden boolean If ``true``, the question will only be shown in the + backend. options list of objects In case of question type ``C`` or ``M``, this lists the available objects. Only writable during creation, use separate endpoint to modify this later. @@ -68,6 +70,10 @@ dependency_value string The value ``dep Write methods have been added. The attribute ``identifier`` has been added to both the resource itself and the options resource. The ``position`` attribute has been added to the options resource. +.. versionchanged:: 2.7 + + The attribute ``hidden`` has been added. + Endpoints --------- @@ -110,6 +116,7 @@ Endpoints "position": 1, "identifier": "WY3TP9SL", "ask_during_checkin": false, + "hidden": false, "dependency_question": null, "dependency_value": null, "options": [ @@ -177,6 +184,7 @@ Endpoints "position": 1, "identifier": "WY3TP9SL", "ask_during_checkin": false, + "hidden": false, "dependency_question": null, "dependency_value": null, "options": [ @@ -228,6 +236,7 @@ Endpoints "items": [1, 2], "position": 1, "ask_during_checkin": false, + "hidden": false, "dependency_question": null, "dependency_value": null, "options": [ @@ -261,6 +270,7 @@ Endpoints "position": 1, "identifier": "WY3TP9SL", "ask_during_checkin": false, + "hidden": false, "dependency_question": null, "dependency_value": null, "options": [ @@ -332,6 +342,7 @@ Endpoints "position": 2, "identifier": "WY3TP9SL", "ask_during_checkin": false, + "hidden": false, "dependency_question": null, "dependency_value": null, "options": [ diff --git a/src/pretix/api/serializers/item.py b/src/pretix/api/serializers/item.py index 092c0b6fe2..5dd2ab168e 100644 --- a/src/pretix/api/serializers/item.py +++ b/src/pretix/api/serializers/item.py @@ -207,7 +207,8 @@ class QuestionSerializer(I18nAwareModelSerializer): class Meta: model = Question fields = ('id', 'question', 'type', 'required', 'items', 'options', 'position', - 'ask_during_checkin', 'identifier', 'dependency_question', 'dependency_value') + 'ask_during_checkin', 'identifier', 'dependency_question', 'dependency_value', + 'hidden') def validate_identifier(self, value): Question._clean_identifier(self.context['event'], value, self.instance) diff --git a/src/pretix/base/migrations/0119_auto_20190509_0654.py b/src/pretix/base/migrations/0119_auto_20190509_0654.py new file mode 100644 index 0000000000..5329eace69 --- /dev/null +++ b/src/pretix/base/migrations/0119_auto_20190509_0654.py @@ -0,0 +1,21 @@ +# Generated by Django 2.2 on 2019-05-09 06:54 + +from django.db import migrations, models +import django.db.models.deletion +import jsonfallback.fields +import pretix.base.models.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('pretixbase', '0118_auto_20190423_0839'), + ] + + operations = [ + migrations.AddField( + model_name='question', + name='hidden', + field=models.BooleanField(default=False, help_text='This question will only show up in the backend.', verbose_name='Hidden question'), + ), + ] diff --git a/src/pretix/base/models/items.py b/src/pretix/base/models/items.py index 62e4535a4f..7bd5b894bd 100644 --- a/src/pretix/base/models/items.py +++ b/src/pretix/base/models/items.py @@ -893,6 +893,8 @@ class Question(LoggedModel): :param items: A set of ``Items`` objects that this question should be applied to :param ask_during_checkin: Whether to ask this question during check-in instead of during check-out. :type ask_during_checkin: bool + :param hidden: Whether to only show the question in the backend + :type hidden: bool :param identifier: An arbitrary, internal identifier :type identifier: str :param dependency_question: This question will only show up if the referenced question is set to `dependency_value`. @@ -968,6 +970,11 @@ class Question(LoggedModel): 'pretixdesk 0.2 or newer.'), default=False ) + hidden = models.BooleanField( + verbose_name=_('Hidden question'), + help_text=_('This question will only show up in the backend.'), + default=False + ) dependency_question = models.ForeignKey( 'Question', null=True, blank=True, on_delete=models.SET_NULL, related_name='dependent_questions' ) diff --git a/src/pretix/base/models/orders.py b/src/pretix/base/models/orders.py index 7bc730d053..7c2b8e75d8 100644 --- a/src/pretix/base/models/orders.py +++ b/src/pretix/base/models/orders.py @@ -976,7 +976,8 @@ class AbstractPosition(models.Model): if hasattr(self.item, 'questions_to_ask'): questions = list(copy.copy(q) for q in self.item.questions_to_ask) else: - questions = list(copy.copy(q) for q in self.item.questions.filter(ask_during_checkin=False)) + questions = list(copy.copy(q) for q in self.item.questions.filter(ask_during_checkin=False, + hidden=False)) else: questions = list(copy.copy(q) for q in self.item.questions.all()) diff --git a/src/pretix/control/forms/item.py b/src/pretix/control/forms/item.py index e217081a6e..4968ea6407 100644 --- a/src/pretix/control/forms/item.py +++ b/src/pretix/control/forms/item.py @@ -82,6 +82,7 @@ class QuestionForm(I18nModelForm): 'type', 'required', 'ask_during_checkin', + 'hidden', 'identifier', 'items', 'dependency_question', diff --git a/src/pretix/control/templates/pretixcontrol/items/question_edit.html b/src/pretix/control/templates/pretixcontrol/items/question_edit.html index 5039324e34..93b7505127 100644 --- a/src/pretix/control/templates/pretixcontrol/items/question_edit.html +++ b/src/pretix/control/templates/pretixcontrol/items/question_edit.html @@ -109,6 +109,7 @@ {% bootstrap_field form.help_text layout="control" %} {% bootstrap_field form.identifier layout="control" %} {% bootstrap_field form.ask_during_checkin layout="control" %} + {% bootstrap_field form.hidden layout="control" %}