From ba7ad4c2b450e83069b960d012ff4e3f544306e8 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Tue, 24 Sep 2024 11:33:31 +0200 Subject: [PATCH] feat(apis_entities): adapt merge form to use new enrich view --- apis_core/apis_entities/forms.py | 15 +++------------ apis_core/apis_entities/models.py | 7 ------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/apis_core/apis_entities/forms.py b/apis_core/apis_entities/forms.py index 42a269ee1..fa22d8c9d 100644 --- a/apis_core/apis_entities/forms.py +++ b/apis_core/apis_entities/forms.py @@ -5,8 +5,6 @@ from django.contrib.contenttypes.models import ContentType from django.urls import reverse -from apis_core.generic.forms.fields import ModelImportChoiceField - class EntitiesMergeForm(forms.Form): def __init__(self, *args, **kwargs): @@ -14,7 +12,7 @@ def __init__(self, *args, **kwargs): instance = kwargs.pop("instance") super().__init__(*args, **kwargs) ct = ContentType.objects.get_for_model(instance) - self.fields["uri"] = ModelImportChoiceField( + self.fields["uri"] = forms.ModelChoiceField( queryset=ct.model_class().objects.all() ) uri = reverse("apis_core:generic:autocomplete", args=[ct]) @@ -25,15 +23,8 @@ def __init__(self, *args, **kwargs): } self.fields["uri"].widget = autocomplete.ModelSelect2(uri, attrs=attrs) self.fields["uri"].widget.choices = self.fields["uri"].choices - entitytype = instance._meta.verbose_name - help_text = f"""The attributes of the source {entitytype} you - choose will be copied/moved to this one and the source - {entitytype} will then be deleted.""" - self.fields["uri"].help_text = help_text self.fields["uri"].label = "Merge with..." self.helper = FormHelper() + self.helper.form_method = "GET" self.helper.add_input(Submit("submit", "Submit")) - self.helper.form_action = reverse( - "apis_core:apis_entities:generic_entities_merge_view", - args=[instance.__class__.__name__.lower(), instance.pk], - ) + self.helper.form_action = instance.get_enrich_url() diff --git a/apis_core/apis_entities/models.py b/apis_core/apis_entities/models.py index e077cea54..a28d78cd8 100644 --- a/apis_core/apis_entities/models.py +++ b/apis_core/apis_entities/models.py @@ -85,13 +85,6 @@ def get_duplicate_url(self): kwargs={"contenttype": entity, "pk": self.id}, ) - def get_merge_url(self): - entity = self.__class__.__name__.lower() - return reverse( - "apis_core:apis_entities:generic_entities_merge_view", - kwargs={"contenttype": entity, "pk": self.id}, - ) - def merge_start_date_written(self, other): self.start_date_written = self.start_date_written or other.start_date_written