mirror of
https://github.com/pretix/pretix.git
synced 2026-05-15 16:54:00 +00:00
refactor: move some utils into core
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
import json
|
||||
|
||||
from django import forms
|
||||
from django.forms import formset_factory
|
||||
@@ -76,7 +77,9 @@ class PropertyMappingFormSet(formset_factory(
|
||||
)):
|
||||
template_name = "pretixcontrol/datasync/property_mapping_formset.html"
|
||||
|
||||
def __init__(self, pretix_fields, external_fields, available_modes, prefix, *args, **kwargs):
|
||||
def __init__(self, pretix_fields, external_fields, available_modes, prefix, *args, initial_json=None, **kwargs):
|
||||
if initial_json:
|
||||
kwargs["initial"] = json.loads(initial_json)
|
||||
super().__init__(
|
||||
form_kwargs={
|
||||
"pretix_fields": pretix_fields,
|
||||
@@ -93,6 +96,10 @@ class PropertyMappingFormSet(formset_factory(
|
||||
ctx["external_fields_id"] = self.prefix + "external-fields"
|
||||
return ctx
|
||||
|
||||
def to_property_mapping_json(self):
|
||||
mappings = [f.cleaned_data for f in self.ordered_forms]
|
||||
return json.dumps(mappings)
|
||||
|
||||
|
||||
def pretix_fields_choices(pretix_fields, initial_choice):
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user