diff options
-rw-r--r-- | archaeological_finds/models_finds.py | 11 | ||||
-rw-r--r-- | archaeological_finds/urls.py | 14 | ||||
-rw-r--r-- | archaeological_finds/views.py | 14 |
3 files changed, 39 insertions, 0 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index ec54570db..e1c4e2f71 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1036,6 +1036,17 @@ class FindBasket(Basket, MainItem, ValueGetter): False, ), ] + if self.can_do(request, "archaeological_finds.add_exhibition"): + actions += [ + ( + reverse("findbasket-add-exhibition", args=[self.pk]), + _("Create exhibition"), + "fa fa-calendar", + "", + "", + False, + ), + ] if can_edit_find: duplicate = self.get_quick_action_by_url("findbasket-qa-duplicate") diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index b99140e00..e8935511f 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -183,6 +183,13 @@ urlpatterns = [ name="findbasket-add-treatmentfile", ), url( + r"^findbasket-add-exhibition/(?P<pk>[0-9-]+)/$", + check_permissions( + ["archaeological_finds.add_exhibition"] + )(views.findbasket_exhibition_add), + name="findbasket-add-exhibition", + ), + url( r"^find-add-treatment/(?P<pk>[0-9-]+)/$", check_permissions( ["archaeological_finds.add_treatment"] @@ -444,6 +451,13 @@ urlpatterns = [ name="exhibition-search", ), path( + "exhibition/create/<int:basket_id>/", + check_permissions( + ["archaeological_finds.add_exhibition"] + )(views.ExhibitionCreateView.as_view()), + name="exhibition-create-from-basket", + ), + path( "exhibition/create/", check_permissions( ["archaeological_finds.add_exhibition"] diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 7fdc83197..35e61ddef 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -665,6 +665,12 @@ class ExhibitionFormMixin(IshtarMixin, LoginRequiredMixin): class ExhibitionCreateView(ExhibitionFormMixin, CreateView): page_name = _("Exhibition creation") + def get_form_kwargs(self): + kwargs = super().get_form_kwargs() + if "basket_id" in self.kwargs: + kwargs["initial"] = {"associated_basket_id": self.kwargs["basket_id"]} + return kwargs + def get_context_data(self, **kwargs): data = super().get_context_data(**kwargs) # data["extra_form_modals"] = self.form_class.extra_form_modals @@ -889,6 +895,14 @@ def findbasket_treatmentfile_add(request, pk, current_right=None): return treatmentfile_add(request, basket_pk=basket.pk) +def findbasket_exhibition_add(request, pk, current_right=None): + try: + basket = models.FindBasket.objects.get(pk=pk) + except models.FindBasket.DoesNotExist: + raise Http404() + return ExhibitionCreateView.as_view()(request, basket_id=basket.pk) + + def container_treatment_add(request, pk, current_right=None): try: basket = models.FindBasket.objects.get(pk=pk) |