diff --git a/apis_core/apis_entities/edit_generic.py b/apis_core/apis_entities/edit_generic.py index 7f5e54fc1..f8633ef9e 100644 --- a/apis_core/apis_entities/edit_generic.py +++ b/apis_core/apis_entities/edit_generic.py @@ -22,7 +22,7 @@ get_generic_triple_table, LabelTableEdit, ) -from .forms import get_entities_form, GenericEntitiesStanbolForm +from .forms import get_entities_form from .views import set_session_variables from ..apis_vocabularies.models import TextType from apis_core.utils import caching @@ -120,8 +120,6 @@ def get(self, request, *args, **kwargs): "object_lod": object_lod, "apis_bibsonomy": apis_bibsonomy, } - form_merge_with = GenericEntitiesStanbolForm(self.entity, ent_merge_pk=self.pk) - context["form_merge_with"] = form_merge_with return HttpResponse(template.render(request=request, context=context)) def post(self, request, *args, **kwargs): @@ -142,12 +140,6 @@ def post(self, request, *args, **kwargs): "entity_type": self.entity, "instance": self.instance, } - if self.entity.lower() != "place": - form_merge_with = GenericEntitiesStanbolForm( - self.entity, ent_merge_pk=self.pk - ) - context["form_merge_with"] = form_merge_with - return TemplateResponse(request, template, context=context) return HttpResponse(template.render(request=request, context=context)) @@ -200,41 +192,6 @@ def post(self, request, *args, **kwargs): ) -@method_decorator(login_required, name="dispatch") -class GenericEntitiesCreateStanbolView(EntityMixin, View): - def post(self, request, *args, **kwargs): - ent_merge_pk = kwargs.get("ent_merge_pk", False) - if ent_merge_pk: - form = GenericEntitiesStanbolForm( - self.entity, request.POST, ent_merge_pk=ent_merge_pk - ) - else: - form = GenericEntitiesStanbolForm(self.entity, request.POST) - # form = form(request.POST) - if form.is_valid(): - entity_2 = form.save() - if ent_merge_pk: - entity_2.merge_with(int(ent_merge_pk)) - return redirect( - reverse( - "apis:apis_entities:generic_entities_edit_view", - kwargs={"pk": entity_2.pk, "entity": self.entity}, - ) - ) - else: - permissions = { - "create": request.user.has_perm( - "apis_entities.add_{}".format(self.entity) - ) - } - template = get_template("apis_entities/create_generic.html") - return HttpResponse( - template.render( - request=request, context={"permissions": permissions, "form": form} - ) - ) - - @method_decorator(login_required, name="dispatch") class GenericEntitiesDeleteView(EntityInstanceMixin, DeleteView): # model = ContentType.objects.get( diff --git a/apis_core/apis_entities/forms.py b/apis_core/apis_entities/forms.py index 4a77e1abb..8d45d3977 100644 --- a/apis_core/apis_entities/forms.py +++ b/apis_core/apis_entities/forms.py @@ -242,50 +242,6 @@ def save(self, *args, **kwargs): return GenericEntitiesForm -class GenericEntitiesStanbolForm(forms.Form): - def save(self, *args, **kwargs): - form_uri = self.cleaned_data["entity"] - uri, _ = Uri.objects.get_or_create(uri=form_uri) - return uri.root_object - - def __init__(self, entity, *args, **kwargs): - - attrs = { - "data-placeholder": "Type to get suggestions", - "data-minimum-input-length": getattr(settings, "APIS_MIN_CHAR", 3), - "data-html": True, - "style": "width: auto", - } - ent_merge_pk = kwargs.pop("ent_merge_pk", False) - super(GenericEntitiesStanbolForm, self).__init__(*args, **kwargs) - self.entity = entity - self.helper = FormHelper() - form_kwargs = {"entity": entity} - url = reverse( - "apis:apis_entities:generic_entities_autocomplete", - args=[entity.title(), "remove"], - ) - label = "Create {} from reference resources".format(entity.title()) - button_label = "Create" - if ent_merge_pk: - form_kwargs["ent_merge_pk"] = ent_merge_pk - url = reverse( - "apis:apis_entities:generic_entities_autocomplete", - args=[entity.title(), ent_merge_pk], - ) - label = "Search for {0} in reference resources or db".format(entity.title()) - button_label = "Merge" - self.helper.form_action = reverse( - "apis:apis_entities:generic_entities_stanbol_create", kwargs=form_kwargs - ) - self.helper.add_input(Submit("submit", button_label)) - self.fields["entity"] = autocomplete.Select2ListCreateChoiceField( - label=label, - widget=ListSelect2(url=url, attrs=attrs), - validators=[URLValidator], - ) - - class PersonResolveUriForm(forms.Form): # person = forms.CharField(label=False, widget=al.TextWidget('PersonAutocomplete')) person = forms.CharField(label=False) diff --git a/apis_core/apis_entities/urls.py b/apis_core/apis_entities/urls.py index 8cad18e68..ba648f284 100644 --- a/apis_core/apis_entities/urls.py +++ b/apis_core/apis_entities/urls.py @@ -7,7 +7,6 @@ ) # from .views import ReversionCompareView TODO: add again when import is fixed -from .edit_generic import GenericEntitiesCreateStanbolView from .api_views import GetOrCreateEntity app_name = "apis_entities" @@ -46,16 +45,6 @@ ] autocomplete_patterns = [ - path( - "createstanbol///", - GenericEntitiesCreateStanbolView.as_view(), - name="generic_entities_stanbol_create", - ), - path( - "createstanbol//", - GenericEntitiesCreateStanbolView.as_view(), - name="generic_entities_stanbol_create", - ), path( "//", GenericEntitiesAutocomplete.as_view(), diff --git a/apis_core/apis_entities/views.py b/apis_core/apis_entities/views.py index 0d0b5264b..7a69770bc 100644 --- a/apis_core/apis_entities/views.py +++ b/apis_core/apis_entities/views.py @@ -27,7 +27,6 @@ from .forms import ( GenericFilterFormHelper, PersonResolveUriForm, - GenericEntitiesStanbolForm, ) from .tables import get_entities_table from apis_core.utils.helpers import get_member_for_entity @@ -158,8 +157,6 @@ def get_context_data(self, **kwargs): context["app_name"] = "apis_entities" context["docstring"] = f"{model.__doc__}" - context["entity_create_stanbol"] = GenericEntitiesStanbolForm(self.entity) - if "browsing" in settings.INSTALLED_APPS: from browsing.models import BrowsConf diff --git a/apis_core/apis_metainfo/templates/generic_list.html b/apis_core/apis_metainfo/templates/generic_list.html index 89cc3a2e0..eb30ff499 100644 --- a/apis_core/apis_metainfo/templates/generic_list.html +++ b/apis_core/apis_metainfo/templates/generic_list.html @@ -359,17 +359,5 @@

{{ data.title }}

{% if 'entities' in APPS %}{% endif %} -{% if user.is_authenticated %} - - {% if entity_create_stanbol %} -
-
-

Import new {{ entity|title }} from GND

-
-
{% crispy entity_create_stanbol entity_create_stanbol.helper %}
-
- {% endif %} -{% endif %} - {% endblock %}