translate_property_mappings: docstring with example, move to utils, add reference to docs

This commit is contained in:
Mira Weller
2025-07-17 14:01:25 +02:00
parent 22b011594a
commit 1c3bdf56f9
2 changed files with 37 additions and 17 deletions

View File

@@ -20,7 +20,6 @@
# <https://www.gnu.org/licenses/>.
#
import json
from collections import namedtuple
from functools import partial
@@ -514,21 +513,6 @@ def get_data_fields(event, for_model=None):
return src_fields
def translate_property_mappings(property_mappings, checkin_list_map):
mappings = json.loads(property_mappings)
for mapping in mappings:
if mapping["pretix_field"].startswith("checkin_date_"):
old_id = int(mapping["pretix_field"][len("checkin_date_"):])
if old_id not in checkin_list_map:
# old_id might not be in checkin_list_map, because copying of an event series only copies check-in
# lists covering the whole series, not individual dates.
mapping["pretix_field"] = "_invalid_" + mapping["pretix_field"]
else:
mapping["pretix_field"] = "checkin_date_%d" % checkin_list_map[old_id].pk
return json.dumps(mappings)
def get_enum_opts(q):
if q.type in (Question.TYPE_CHOICE, Question.TYPE_CHOICE_MULTIPLE):
return [(opt.identifier, opt.answer) for opt in q.options.all()]