Fix access to old fields

This commit is contained in:
Mira Weller
2026-09-30 21:03:27 +02:00
parent 485ec5f262
commit 703aeee776
6 changed files with 25 additions and 22 deletions
+16 -13
View File
@@ -1680,10 +1680,11 @@ class Question(LoggedModel):
choices=FieldType.choices,
verbose_name=_("Question type")
)
#required = models.BooleanField( # TODO(questionnaires) : to be removed, -> QuestionnaireChild
# default=False,
# verbose_name=_("Required question")
#)
tbd_required = models.BooleanField( # TODO(questionnaires) : to be removed, -> QuestionnaireChild
default=False,
verbose_name=_("Required question"),
db_column="required",
)
#items = models.ManyToManyField( # TODO(questionnaires) : to be removed, -> Questionnaire
# Item,
# related_name='questions',
@@ -1691,15 +1692,17 @@ class Question(LoggedModel):
# blank=True,
# help_text=_('This question will be asked to buyers of the selected products')
#)
#position = models.PositiveIntegerField( # TODO(questionnaires) : to be removed, -> Questionnaire + QuestionnaireChild
# default=0,
# verbose_name=_("Position")
#)
#ask_during_checkin = models.BooleanField( # TODO(questionnaires) : to be removed
# verbose_name=_('Ask during check-in instead of in the ticket buying process'),
# help_text=_('Not supported by all check-in apps for all question types.'),
# default=False
#)
tbd_position = models.PositiveIntegerField( # TODO(questionnaires) : to be removed, -> Questionnaire + QuestionnaireChild
default=0,
verbose_name=_("Position"),
db_column="position",
)
tbd_ask_during_checkin = models.BooleanField( # TODO(questionnaires) : to be removed
verbose_name=_('Ask during check-in instead of in the ticket buying process'),
help_text=_('Not supported by all check-in apps for all question types.'),
default=False,
db_column="ask_during_checkin",
)
show_during_checkin = models.BooleanField(
verbose_name=_('Show answer during check-in'),
help_text=_('Not supported by all check-in apps for all question types.'),
+4 -4
View File
@@ -918,7 +918,7 @@ class Order(LockModel, LoggedModel):
positions = list(
self.positions.all().annotate(
has_checkin=Exists(Checkin.objects.filter(position_id=OuterRef('pk'), list__consider_tickets_used=True))
).select_related('item').prefetch_related('item__questions')
).select_related('item').prefetch_related('item__questionnaires')
)
if not self.event.settings.allow_modifications_after_checkin:
for cp in positions:
@@ -929,7 +929,7 @@ class Order(LockModel, LoggedModel):
return True
ask_names = self.event.settings.get('attendee_names_asked', as_type=bool)
for cp in positions:
if (cp.item.ask_attendee_data and ask_names) or cp.item.questions.all():
if (cp.item.ask_attendee_data and ask_names) or cp.item.questionnaires.all(): # TODO(questionnaires) : filter to only QuestionnaireType.ORDER_POSITION_SALE
return True
return False # nothing there to modify
@@ -2780,7 +2780,7 @@ class OrderPosition(AbstractPosition):
positions = list(
self.order.positions.all().annotate(
has_checkin=Exists(Checkin.objects.filter(position_id=OuterRef('pk'), list__consider_tickets_used=True))
).select_related('item').prefetch_related('item__questions')
).select_related('item').prefetch_related('item__questionnaires')
)
if not self.event.settings.allow_modifications_after_checkin:
for cp in positions:
@@ -2790,7 +2790,7 @@ class OrderPosition(AbstractPosition):
ask_names = self.event.settings.get('attendee_names_asked', as_type=bool)
for cp in positions:
if cp.pk == self.pk or cp.addon_to_id == self.pk:
if (cp.item.ask_attendee_data and ask_names) or cp.item.questions.all():
if (cp.item.ask_attendee_data and ask_names) or cp.item.questionnaires.all(): # TODO(questionnaires) : filter to only QuestionnaireType.ORDER_POSITION_SALE
return True
return False # nothing there to modify
@@ -6,7 +6,7 @@
<h1>{% trans "Delete question" %}</h1>
<form action="" method="post" class="form-horizontal">
{% csrf_token %}
<p>{% blocktrans %}Are you sure you want to delete the question <strong>{{ question }}</strong>?{% endblocktrans %}</p>
<p>{% blocktrans %}Are you sure you want to delete the data field <strong>{{ question }}</strong>?{% endblocktrans %}</p>
{% if dependent|length > 0 %}
<div class="alert alert-warning">
<p>{% blocktrans %}All answers to the question given by the buyers of the following products will be <strong>lost</strong>.{% endblocktrans %}
+1 -1
View File
@@ -456,7 +456,7 @@ class QuestionDelete(EventPermissionRequiredMixin, CompatDeleteView):
def get_context_data(self, *args, **kwargs) -> dict:
context = super().get_context_data(*args, **kwargs)
context['dependent'] = list(self.get_object().items.all())
# TODO(questionnaires) context['dependent'] = list(self.get_object().items.all())
context['edit_url'] = reverse('control:event.items.questions.edit', kwargs={
'organizer': self.request.event.organizer.slug,
'event': self.request.event.slug,
+1 -1
View File
@@ -600,7 +600,7 @@ class OrderDetail(OrderView):
'item', 'variation', 'addon_to', 'tax_rule', 'used_membership', 'used_membership__membership_type',
'discount',
).prefetch_related(
'item__questions', 'issued_gift_cards', 'owned_gift_cards', 'linked_media',
'item__questions', 'issued_gift_cards', 'owned_gift_cards', 'linked_media', # TODO(questionnaires) : item__questions gibts nicht mehr
Prefetch('answers', queryset=QuestionAnswer.objects.prefetch_related('options').select_related('question')),
Prefetch('all_checkins', queryset=Checkin.all.select_related('list', 'gate').order_by('datetime')),
Prefetch('print_logs', queryset=PrintLog.objects.select_related('device').order_by('datetime')),
+2 -2
View File
@@ -136,7 +136,7 @@ class CartMixin:
if queryset is not None:
prefetch = []
if answers:
prefetch.append('item__questions')
prefetch.append('item__questionnaires')
prefetch.append(Prefetch('answers', queryset=QuestionAnswer.objects.prefetch_related('options')))
cartpos = queryset.order_by(
@@ -213,7 +213,7 @@ class CartMixin:
# Never group if the position has add-ons
pos.pk not in has_addons and
# Never group if we have answers to show
(not answers or (not has_attendee_data and not bool(pos.item.questions.all()))) and # do not use .exists() to re-use prefetch cache
(not answers or (not has_attendee_data and not bool(pos.item.questionnaires.all()))) and # do not use .exists() to re-use prefetch cache
# Never group when we have a final order and a gift card code
(isinstance(pos, CartPosition) or not pos.item.issue_giftcard)
)