From 5ec494564251e27e3f802e6c1aec3c6aa1890488 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 8 Mar 2023 13:00:40 +0100 Subject: Site: quick action for creation of virtual operation from site with many operations (refs #3935) --- archaeological_operations/views.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'archaeological_operations/views.py') diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index f15e24c43..7bbc4c0b4 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -584,6 +584,28 @@ def site_delete(request, pk): return redirect(reverse(wizard_url, kwargs={"step": "final-" + wizard_url})) +def site_add_top_operation(request, pks, current_right=None): + q = models.ArchaeologicalSite.objects.filter(pk=pks) + if not q.count(): + raise Http404() + site = q.all()[0] + if not site.can_do(request, "view_archaeologicalsite") \ + or not site.operations.count(): + raise Http404() + # operation add permission checked on view call + top_operation = site.create_or_update_top_operation(create=True) + if not wizard_is_available( + operation_modification_wizard, request, models.Operation, top_operation.pk + ): + return HttpResponseRedirect("/") + + wizard_url = "operation_modification" + wizards.OperationModificationWizard.session_set_value( + request, "selec-" + wizard_url, "pk", top_operation.pk, reset=True + ) + return redirect(reverse(wizard_url, kwargs={"step": "general-" + wizard_url})) + + operation_administrativeactop_search_wizard = wizards.SearchWizard.as_view( [ ( -- cgit v1.2.3