Rename property_mapping -> property_mappings, association_mapping -> association_mappings

This commit is contained in:
Mira Weller
2025-07-01 13:43:19 +02:00
parent c3833f8883
commit 17c1d75780
6 changed files with 38 additions and 21 deletions

View File

@@ -88,8 +88,7 @@ def sync_all():
if not target_cls:
# sync plugin not found (plugin deactivated or uninstalled) -> drop outstanding jobs
for sq in queued_orders:
sq.delete()
OrderSyncQueue.objects.filter(pk__in=[sq.pk for sq in queued_orders]).delete()
with scope(organizer=event.organizer):
with target_cls(event=event) as p:
@@ -125,7 +124,7 @@ class RecoverableSyncError(BaseSyncError):
pass
StaticMapping = namedtuple('StaticMapping', ('id', 'pretix_model', 'external_object_type', 'pretix_id_field', 'external_id_field', 'property_mapping'))
StaticMapping = namedtuple('StaticMapping', ('id', 'pretix_model', 'external_object_type', 'pretix_id_field', 'external_id_field', 'property_mappings'))
class OutboundSyncProvider:
@@ -216,7 +215,7 @@ class OutboundSyncProvider:
- `pretix_id_field`: Which pretix data field should be used to identify the mapped object. Any ``DataFieldInfo.key``
returned by ``sourcefields.get_data_fields()`` for the combination of ``Event`` and ``pretix_model``.
- `external_id_field`: Destination identifier field in the target system.
- `property_mapping`: Mapping configuration as generated by ``PropertyMappingFormSet.to_property_mapping_json()``.
- `property_mappings`: Mapping configuration as generated by ``PropertyMappingFormSet.to_property_mappings_json()``.
"""
raise NotImplementedError
@@ -291,11 +290,11 @@ class OutboundSyncProvider:
val = ",".join(val)
return val
def get_properties(self, inputs: dict, property_mapping: str):
property_mapping = json.loads(property_mapping)
def get_properties(self, inputs: dict, property_mappings: str):
property_mappings = json.loads(property_mappings)
return [
(m["external_field"], self.get_field_value(inputs, m), m["overwrite"])
for m in property_mapping
for m in property_mappings
]
def sync_object_with_properties(
@@ -315,7 +314,7 @@ class OutboundSyncProvider:
:param external_id_field: Identifier field in the external system as provided in ``mapping.external_identifier``
:param id_value: Identifier contents as retrieved from the property specified by ``mapping.pretix_identifier`` of the model
specified by ``mapping.pretix_model``
:param properties: All properties defined in ``mapping.property_mapping``, as list of three-tuples
:param properties: All properties defined in ``mapping.property_mappings``, as list of three-tuples
``(external_field, value, overwrite)``
:param inputs: All pretix model instances from which data can be retrieved for this mapping
:param mapping: The mapping object as returned by ``self.mappings``
@@ -356,7 +355,7 @@ class OutboundSyncProvider:
mapped_objects: dict,
):
logger.debug("Syncing object %r, %r, %r", inputs, mapping, mapped_objects)
properties = self.get_properties(inputs, mapping.property_mapping)
properties = self.get_properties(inputs, mapping.property_mappings)
logger.debug("Properties: %r", properties)
id_value = self.get_field_value(inputs, {"pretix_field": mapping.pretix_id_field})

View File

@@ -514,8 +514,8 @@ def get_data_fields(event, for_model=None):
return src_fields
def translate_property_mappings(property_mapping, checkin_list_map):
mappings = json.loads(property_mapping)
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_"):