forked from CGM_Public/pretix_original
Add-Ons inhert question-answers from parent item if necessary
This commit is contained in:
@@ -266,16 +266,28 @@ DEFAULT_VARIABLES = OrderedDict((
|
|||||||
@receiver(layout_text_variables, dispatch_uid="pretix_base_layout_text_variables_questions")
|
@receiver(layout_text_variables, dispatch_uid="pretix_base_layout_text_variables_questions")
|
||||||
def variables_from_questions(sender, *args, **kwargs):
|
def variables_from_questions(sender, *args, **kwargs):
|
||||||
def get_answer(op, order, event, question_id):
|
def get_answer(op, order, event, question_id):
|
||||||
try:
|
a = None
|
||||||
|
if op.addon_to:
|
||||||
|
if 'answers' in getattr(op.addon_to, '_prefetched_objects_cache', {}):
|
||||||
|
try:
|
||||||
|
a = [a for a in op.addon_to.answers.all() if a.question_id == question_id][0]
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
a = op.addon_to.answers.filter(question_id=question_id).first()
|
||||||
|
|
||||||
if 'answers' in getattr(op, '_prefetched_objects_cache', {}):
|
if 'answers' in getattr(op, '_prefetched_objects_cache', {}):
|
||||||
a = [a for a in op.answers.all() if a.question_id == question_id][0]
|
try:
|
||||||
|
a = [a for a in op.answers.all() if a.question_id == question_id][0]
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
a = op.answers.filter(question_id=question_id).first()
|
a = op.answers.filter(question_id=question_id).first()
|
||||||
if not a:
|
|
||||||
return ""
|
if not a:
|
||||||
return str(a).replace("\n", "<br/>\n")
|
|
||||||
except IndexError:
|
|
||||||
return ""
|
return ""
|
||||||
|
else:
|
||||||
|
return str(a).replace("\n", "<br/>\n")
|
||||||
|
|
||||||
d = {}
|
d = {}
|
||||||
for q in sender.questions.all():
|
for q in sender.questions.all():
|
||||||
|
|||||||
Reference in New Issue
Block a user