summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.md2
-rw-r--r--archaeological_operations/models.py14
-rw-r--r--archaeological_operations/urls.py7
-rw-r--r--archaeological_operations/views.py22
4 files changed, 45 insertions, 0 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 3cd5cc0d8..9f1f717c6 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -43,6 +43,8 @@ Ishtar changelog
- Explicit message on associated container deletion when a warehouse is deleted
- Administrative act: add a warning when associated item is deleted
- Imports: register automatically type models for export
+- Site: quick action for creation of virtual operation from site with many operations
+
- Sheet:
- fix treatment and file treatment sheet display (bad QR code link)
- Operation - statistics number of parcels fix
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index a7a9823b8..091e1e60c 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -619,6 +619,19 @@ class ArchaeologicalSite(
if can_add_geo:
actions.append(self.get_add_geo_action())
+ can_create_operation = self.can_do(request, "change_operation")
+ if can_create_operation and self.operations.count():
+ actions.append(
+ (
+ reverse("site-qa-top-operation", args=[self.pk]),
+ _("Create a cluster operation for site associated to many operations"),
+ "fa fa-plus",
+ _("top ope."),
+ "",
+ False
+ )
+ )
+
can_edit_site = self.can_do(request, "change_archaeologicalsite")
if can_edit_site:
actions += [
@@ -797,6 +810,7 @@ class ArchaeologicalSite(
right_record=value,
relation_type=rel_type,
)
+ return top_operation
def site_post_save(sender, **kwargs):
diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py
index e4965d171..cf4ab6489 100644
--- a/archaeological_operations/urls.py
+++ b/archaeological_operations/urls.py
@@ -356,6 +356,13 @@ urlpatterns = [
kwargs={"confirm": True},
),
url(
+ r"^site-qa-top-operation/(?P<pks>\d+)?/$",
+ check_rights(["change_operation"])(
+ views.site_add_top_operation
+ ),
+ name="site-qa-top-operation",
+ ),
+ url(
r"generate-stats-operation/(?P<pk>.+)/",
views.GenerateStatsOperation.as_view(),
name="generate-stats-operation",
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(
[
(