Skip to content

Commit

Permalink
chore(apis_entities): drop merge view, route and form
Browse files Browse the repository at this point in the history
It is not needed anymore, now that the SelectMergeOrEnrich view exists
in the generic app.
  • Loading branch information
b1rger committed Nov 29, 2024
1 parent b30cf8a commit 420a4ba
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 75 deletions.
31 changes: 0 additions & 31 deletions apis_core/apis_entities/forms.py

This file was deleted.

7 changes: 0 additions & 7 deletions apis_core/apis_entities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ def get_duplicate_url(self):
kwargs={"contenttype": entity, "pk": self.id},
)

def get_merge_view_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

Expand Down
6 changes: 0 additions & 6 deletions apis_core/apis_entities/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from apis_core.apis_entities.views import (
EntitiesAutocomplete,
EntitiesDuplicate,
EntitiesMerge,
)

api_routes = [
Expand Down Expand Up @@ -61,11 +60,6 @@ def to_url(self, value):
EntitiesDuplicate.as_view(),
name="generic_entities_duplicate_view",
),
path(
"<int:pk>/merge/",
EntitiesMerge.as_view(),
name="generic_entities_merge_view",
),
]

urlpatterns = [
Expand Down
31 changes: 0 additions & 31 deletions apis_core/apis_entities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from django.shortcuts import get_object_or_404, redirect
from django.utils.html import format_html
from django.views import View
from django.views.generic.edit import FormView

from apis_core.apis_entities.forms import EntitiesMergeForm
from apis_core.apis_metainfo.models import RootObject
from apis_core.generic.helpers import generate_search_filter
from apis_core.generic.views import GenericModelMixin
Expand All @@ -32,35 +30,6 @@ def get(self, request, *args, **kwargs):
return redirect(newobj.get_edit_url())


class EntitiesMerge(GenericModelMixin, PermissionRequiredMixin, FormView):
permission_action_required = "create"
form_class = EntitiesMergeForm
template_name = "entity_merge.html"
template_name_suffix = "_merge"

def get_object(self, *args, **kwargs):
return get_object_or_404(self.model, pk=self.kwargs.get("pk"))

def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context["object"] = self.get_object()
return context

def get_form_kwargs(self, *args, **kwargs):
kwargs = super().get_form_kwargs(*args, **kwargs)
kwargs["instance"] = self.get_object()
return kwargs

def form_valid(self, form):
obj = self.get_object()
other = form.cleaned_data["uri"]
obj.merge_with([other])
return super().form_valid(form)

def get_success_url(self):
return self.get_object().get_edit_url()


class EntitiesAutocomplete(autocomplete.Select2QuerySetView):
"""
This endpoint allows us to use autocomplete over multiple model classes.
Expand Down

0 comments on commit 420a4ba

Please sign in to comment.