diff --git a/apis_bibsonomy/templates/apis_bibsonomy/partials/reference_list.html b/apis_bibsonomy/templates/apis_bibsonomy/partials/reference_list.html index bb35905..3791f55 100644 --- a/apis_bibsonomy/templates/apis_bibsonomy/partials/reference_list.html +++ b/apis_bibsonomy/templates/apis_bibsonomy/partials/reference_list.html @@ -1,5 +1,4 @@ -
{% include "apis_bibsonomy/partials/fix_select2_bootstrap_overflow.html" %}
diff --git a/apis_bibsonomy/templates/apis_bibsonomy/reference_list.html b/apis_bibsonomy/templates/apis_bibsonomy/reference_list.html index 4a0753f..fd0b4ed 100644 --- a/apis_bibsonomy/templates/apis_bibsonomy/reference_list.html +++ b/apis_bibsonomy/templates/apis_bibsonomy/reference_list.html @@ -3,8 +3,11 @@ {% block content %}
-

References:

+

References on {{ object }}:

+
+
+{% url "apis_bibsonomy:referenceonlistpartial" contenttype.id object.id as hxpost %} +{% include "apis_bibsonomy/partials/reference_list.html" with hxpost=hxpost %}
-{% include "apis_bibsonomy/partials/reference_list.html" %}
{% endblock content %} diff --git a/apis_bibsonomy/templates/apis_bibsonomy/reference_list_modal.html b/apis_bibsonomy/templates/apis_bibsonomy/reference_list_modal.html new file mode 100644 index 0000000..7911809 --- /dev/null +++ b/apis_bibsonomy/templates/apis_bibsonomy/reference_list_modal.html @@ -0,0 +1,12 @@ + + + diff --git a/apis_bibsonomy/urls.py b/apis_bibsonomy/urls.py index b602801..00ceaab 100644 --- a/apis_bibsonomy/urls.py +++ b/apis_bibsonomy/urls.py @@ -12,4 +12,6 @@ path('references/', views.ReferenceDetailView.as_view(), name='referencedetail'), path('references//delete', views.ReferenceDeleteView.as_view(), name='referencedelete'), path('referenceson//', views.ReferenceOnListView.as_view(), name="referenceonlist"), + path('referenceson///modal', views.ReferenceOnListViewModal.as_view(), name="referenceonlistmodal"), + path('referenceson///partial', views.ReferenceOnListViewPartial.as_view(), name="referenceonlistpartial"), ] diff --git a/apis_bibsonomy/views.py b/apis_bibsonomy/views.py index 5b463da..0377d91 100644 --- a/apis_bibsonomy/views.py +++ b/apis_bibsonomy/views.py @@ -48,16 +48,10 @@ def get_queryset(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) + context["contenttype"] = self.contenttype context["object"] = self.contenttype.get_object_for_this_type(id=self.pk) return context - def get_template_names(self): - # return only a partial if the request is ajax or htmx - partial = "HX-Request" in self.request.headers or self.request.headers.get('x-requested-with') == 'XMLHttpRequest' - if partial: - return "apis_bibsonomy/partials/reference_list.html" - return super().get_template_names() - def get_success_url(self): return reverse('apis_bibsonomy:referenceonlist', kwargs=self.request.resolver_match.kwargs) @@ -72,3 +66,17 @@ def form_valid(self, form): ref = Reference.objects.create(**args) self.request.session["last_bibsonomy_reference_title"] = ref.bibtexjson.get("title") return super().form_valid(form) + + +class ReferenceOnListViewModal(ReferenceOnListView): + template_name = "apis_bibsonomy/reference_list_modal.html" + + def get_success_url(self): + return reverse('apis_bibsonomy:referenceonlistmodal', kwargs=self.request.resolver_match.kwargs) + + +class ReferenceOnListViewPartial(ReferenceOnListView): + template_name = "apis_bibsonomy/partials/reference_list.html" + + def get_success_url(self): + return reverse('apis_bibsonomy:referenceonlistpartial', kwargs=self.request.resolver_match.kwargs)