diff --git a/apis_bibsonomy/templates/apis_bibsonomy/partials/autofill_bibsonomy.html b/apis_bibsonomy/templates/apis_bibsonomy/partials/autofill_bibsonomy.html new file mode 100644 index 0000000..34f079c --- /dev/null +++ b/apis_bibsonomy/templates/apis_bibsonomy/partials/autofill_bibsonomy.html @@ -0,0 +1,23 @@ +{% comment %} +iterate through the `last_bibsonomy_reference` that is set in +the session and use it to fill out the `bibs_url` form field +{% endcomment %} + + diff --git a/apis_bibsonomy/templates/apis_bibsonomy/partials/reference_list.html b/apis_bibsonomy/templates/apis_bibsonomy/partials/reference_list.html index 7b97793..bb35905 100644 --- a/apis_bibsonomy/templates/apis_bibsonomy/partials/reference_list.html +++ b/apis_bibsonomy/templates/apis_bibsonomy/partials/reference_list.html @@ -30,4 +30,5 @@ {% include "apis_bibsonomy/partials/reinit_select2.html" %} {% include "apis_bibsonomy/partials/fix_select2_bootstrap_focus.html" %} +{% include "apis_bibsonomy/partials/autofill_bibsonomy.html" %} diff --git a/apis_bibsonomy/views.py b/apis_bibsonomy/views.py index ee03718..5b463da 100644 --- a/apis_bibsonomy/views.py +++ b/apis_bibsonomy/views.py @@ -63,7 +63,12 @@ def get_success_url(self): def form_valid(self, form): args = form.cleaned_data + # we store the data about the last entered entry in the session + # so we can automatically fill the form with the last reference + self.request.session["last_bibsonomy_reference"] = form.cleaned_data.copy() + args['content_type'] = ContentType.objects.get_for_id(self.request.resolver_match.kwargs['contenttype']) args['object_id'] = self.request.resolver_match.kwargs['pk'] ref = Reference.objects.create(**args) + self.request.session["last_bibsonomy_reference_title"] = ref.bibtexjson.get("title") return super().form_valid(form)