diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-03-08 13:00:40 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-03-08 13:00:40 +0100 |
commit | 5ec494564251e27e3f802e6c1aec3c6aa1890488 (patch) | |
tree | bbaa2a0f15ea7552672f6ec9c4a5fa03c487420f /archaeological_operations/views.py | |
parent | f447bbebea851eb7014815351dc69e03d0aff47f (diff) | |
download | Ishtar-5ec494564251e27e3f802e6c1aec3c6aa1890488.tar.bz2 Ishtar-5ec494564251e27e3f802e6c1aec3c6aa1890488.zip |
Site: quick action for creation of virtual operation from site with many operations (refs #3935)
Diffstat (limited to 'archaeological_operations/views.py')
-rw-r--r-- | archaeological_operations/views.py | 22 |
1 files changed, 22 insertions, 0 deletions
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( [ ( |