mirror of
https://github.com/pretix/pretix.git
synced 2026-05-10 16:04:02 +00:00
Allow organizers to modify answers to check-in questions
This commit is contained in:
@@ -144,6 +144,7 @@ class BaseQuestionsViewMixin:
|
|||||||
|
|
||||||
class OrderQuestionsViewMixin(BaseQuestionsViewMixin):
|
class OrderQuestionsViewMixin(BaseQuestionsViewMixin):
|
||||||
invoice_form_class = BaseInvoiceAddressForm
|
invoice_form_class = BaseInvoiceAddressForm
|
||||||
|
only_user_visible = True
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def _positions_for_questions(self):
|
def _positions_for_questions(self):
|
||||||
@@ -151,6 +152,9 @@ class OrderQuestionsViewMixin(BaseQuestionsViewMixin):
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def positions(self):
|
def positions(self):
|
||||||
|
qqs = Question.objects.all()
|
||||||
|
if self.only_user_visible:
|
||||||
|
qqs = qqs.filter(ask_during_checkin=False)
|
||||||
return list(self.order.positions.select_related(
|
return list(self.order.positions.select_related(
|
||||||
'item', 'variation'
|
'item', 'variation'
|
||||||
).prefetch_related(
|
).prefetch_related(
|
||||||
@@ -158,7 +162,7 @@ class OrderQuestionsViewMixin(BaseQuestionsViewMixin):
|
|||||||
QuestionAnswer.objects.prefetch_related('options'),
|
QuestionAnswer.objects.prefetch_related('options'),
|
||||||
to_attr='answerlist'),
|
to_attr='answerlist'),
|
||||||
Prefetch('item__questions',
|
Prefetch('item__questions',
|
||||||
Question.objects.filter(ask_during_checkin=False).prefetch_related(
|
qqs.prefetch_related(
|
||||||
Prefetch('options', QuestionOption.objects.prefetch_related(Prefetch(
|
Prefetch('options', QuestionOption.objects.prefetch_related(Prefetch(
|
||||||
# This prefetch statement is utter bullshit, but it actually prevents Django from doing
|
# This prefetch statement is utter bullshit, but it actually prevents Django from doing
|
||||||
# a lot of queries since ModelChoiceIterator stops trying to be clever once we have
|
# a lot of queries since ModelChoiceIterator stops trying to be clever once we have
|
||||||
|
|||||||
@@ -639,6 +639,7 @@ class OrderChange(OrderView):
|
|||||||
class OrderModifyInformation(OrderQuestionsViewMixin, OrderView):
|
class OrderModifyInformation(OrderQuestionsViewMixin, OrderView):
|
||||||
permission = 'can_change_orders'
|
permission = 'can_change_orders'
|
||||||
template_name = 'pretixcontrol/order/change_questions.html'
|
template_name = 'pretixcontrol/order/change_questions.html'
|
||||||
|
only_user_visible = False
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
failed = not self.save() or not self.invoice_form.is_valid()
|
failed = not self.save() or not self.invoice_form.is_valid()
|
||||||
|
|||||||
@@ -9,9 +9,13 @@ from pretix.presale.views import get_cart
|
|||||||
|
|
||||||
class QuestionsViewMixin(BaseQuestionsViewMixin):
|
class QuestionsViewMixin(BaseQuestionsViewMixin):
|
||||||
form_class = QuestionsForm
|
form_class = QuestionsForm
|
||||||
|
only_user_visible = True
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def _positions_for_questions(self):
|
def _positions_for_questions(self):
|
||||||
|
qqs = Question.objects.all()
|
||||||
|
if self.only_user_visible:
|
||||||
|
qqs = qqs.filter(ask_during_checkin=False)
|
||||||
cart = get_cart(self.request).select_related(
|
cart = get_cart(self.request).select_related(
|
||||||
'addon_to'
|
'addon_to'
|
||||||
).prefetch_related(
|
).prefetch_related(
|
||||||
@@ -20,7 +24,7 @@ class QuestionsViewMixin(BaseQuestionsViewMixin):
|
|||||||
QuestionAnswer.objects.prefetch_related('options'),
|
QuestionAnswer.objects.prefetch_related('options'),
|
||||||
to_attr='answerlist'),
|
to_attr='answerlist'),
|
||||||
Prefetch('item__questions',
|
Prefetch('item__questions',
|
||||||
Question.objects.filter(ask_during_checkin=False).prefetch_related(
|
qqs.prefetch_related(
|
||||||
Prefetch('options', QuestionOption.objects.prefetch_related(Prefetch(
|
Prefetch('options', QuestionOption.objects.prefetch_related(Prefetch(
|
||||||
# This prefetch statement is utter bullshit, but it actually prevents Django from doing
|
# This prefetch statement is utter bullshit, but it actually prevents Django from doing
|
||||||
# a lot of queries since ModelChoiceIterator stops trying to be clever once we have
|
# a lot of queries since ModelChoiceIterator stops trying to be clever once we have
|
||||||
|
|||||||
Reference in New Issue
Block a user