From d08dc7adc3c9f5b7c8e0965c21d9c4c165efa519 Mon Sep 17 00:00:00 2001 From: Mira Weller Date: Tue, 1 Apr 2025 16:50:19 +0200 Subject: [PATCH] add license headers, formatting --- src/pretix/base/datasync/datasync.py | 34 +++++++++++++++++++----- src/pretix/base/datasync/sourcefields.py | 23 ++++++++++++++++ src/pretix/control/datasync.py | 22 +++++++++++++++ src/pretix/control/forms/mapping.py | 22 +++++++++++++++ src/pretix/control/logdisplay.py | 1 + 5 files changed, 96 insertions(+), 6 deletions(-) diff --git a/src/pretix/base/datasync/datasync.py b/src/pretix/base/datasync/datasync.py index 6aba0304ba..4376c6f0ba 100644 --- a/src/pretix/base/datasync/datasync.py +++ b/src/pretix/base/datasync/datasync.py @@ -1,3 +1,25 @@ +# +# This file is part of pretix (Community Edition). +# +# Copyright (C) 2014-2020 Raphael Michel and contributors +# Copyright (C) 2020-2025 rami.io GmbH and contributors +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General +# Public License as published by the Free Software Foundation in version 3 of the License. +# +# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are +# applicable granting you additional permissions and placing additional restrictions on your usage of this software. +# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive +# this file, see . +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. +# +# You should have received a copy of the GNU Affero General Public License along with this program. If not, see +# . +# + import json import logging from collections import namedtuple @@ -146,9 +168,9 @@ class OutboundSyncProvider: """ Adds an order to the sync queue. May only be called on derived classes which define an "identifier" attribute. - + Should be called in the appropriate signal receivers, e.g.: - + @receiver(order_placed, dispatch_uid="mysync_order_placed") def on_order_placed(sender, order, **kwargs): MySyncProvider.enqueue_order(order, "order_placed") @@ -261,12 +283,12 @@ class OutboundSyncProvider: """ This method is called for each object that needs to be created/updated in the external system -- which these are is determined by the implementation of the `mapping` property. - + TODO: describe the parameters - + This method needs to be idempotent, i.e. calling it multiple times with the same input values should create - only a single object in the target system. - + only a single object in the target system. + Subsequent calls with the same mapping and pk_value should update the existing object, instead of creating a new one. In a SQL database, you might use an "INSERT OR UPDATE" or "UPSERT" statement; many REST APIs provide an equivalent API call. """ diff --git a/src/pretix/base/datasync/sourcefields.py b/src/pretix/base/datasync/sourcefields.py index f698a1c4ae..ae167097ab 100644 --- a/src/pretix/base/datasync/sourcefields.py +++ b/src/pretix/base/datasync/sourcefields.py @@ -1,3 +1,25 @@ +# +# This file is part of pretix (Community Edition). +# +# Copyright (C) 2014-2020 Raphael Michel and contributors +# Copyright (C) 2020-2025 rami.io GmbH and contributors +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General +# Public License as published by the Free Software Foundation in version 3 of the License. +# +# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are +# applicable granting you additional permissions and placing additional restrictions on your usage of this software. +# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive +# this file, see . +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. +# +# You should have received a copy of the GNU Affero General Public License along with this program. If not, see +# . +# + import json from collections import namedtuple from functools import partial @@ -66,6 +88,7 @@ def first_checkin_on_list(list_pk, position): if checkin: return isoformat_or_none(checkin.datetime) + def split_name_on_last_space(name, part): name_parts = name.rsplit(" ", 1) return name_parts[part] if len(name_parts) > part else "" diff --git a/src/pretix/control/datasync.py b/src/pretix/control/datasync.py index d5800458eb..a0de91b514 100644 --- a/src/pretix/control/datasync.py +++ b/src/pretix/control/datasync.py @@ -1,3 +1,25 @@ +# +# This file is part of pretix (Community Edition). +# +# Copyright (C) 2014-2020 Raphael Michel and contributors +# Copyright (C) 2020-2025 rami.io GmbH and contributors +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General +# Public License as published by the Free Software Foundation in version 3 of the License. +# +# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are +# applicable granting you additional permissions and placing additional restrictions on your usage of this software. +# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive +# this file, see . +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. +# +# You should have received a copy of the GNU Affero General Public License along with this program. If not, see +# . +# + from itertools import groupby from django.contrib import messages diff --git a/src/pretix/control/forms/mapping.py b/src/pretix/control/forms/mapping.py index 8f9a35b835..794052e375 100644 --- a/src/pretix/control/forms/mapping.py +++ b/src/pretix/control/forms/mapping.py @@ -1,3 +1,25 @@ +# +# This file is part of pretix (Community Edition). +# +# Copyright (C) 2014-2020 Raphael Michel and contributors +# Copyright (C) 2020-2025 rami.io GmbH and contributors +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General +# Public License as published by the Free Software Foundation in version 3 of the License. +# +# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are +# applicable granting you additional permissions and placing additional restrictions on your usage of this software. +# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive +# this file, see . +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. +# +# You should have received a copy of the GNU Affero General Public License along with this program. If not, see +# . +# + from django import forms from django.forms import formset_factory from django.utils.translation import gettext_lazy as _ diff --git a/src/pretix/control/logdisplay.py b/src/pretix/control/logdisplay.py index 4160c716bc..153af8984d 100644 --- a/src/pretix/control/logdisplay.py +++ b/src/pretix/control/logdisplay.py @@ -43,6 +43,7 @@ from django.dispatch import receiver from django.urls import reverse from django.utils.formats import date_format from django.utils.html import escape, format_html +from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _, pgettext_lazy from i18nfield.strings import LazyI18nString