summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models_finds.py15
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html9
-rw-r--r--archaeological_finds/urls.py24
-rw-r--r--archaeological_finds/views.py7
4 files changed, 50 insertions, 5 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index b79c21c69..5eed32772 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -2711,7 +2711,7 @@ class Find(
return lst
def m2m_listing_datings(self) -> list:
- return [dating.full_serialize() for dating in self.datings.all()]
+ return [dating.full_serialize(keep_id=True) for dating in self.datings.all()]
DOC_VALUES = [
("base_finds", _("List of associated base finds")),
@@ -2851,12 +2851,23 @@ class Find(
is_locked = hasattr(self, "is_locked") and self.is_locked(request.user)
profile = get_current_profile()
+ can_edit_find = self.can_do(request, "archaeological_finds.change_find")
+ if can_edit_find and not is_locked:
+ actions += [
+ (
+ reverse("find-dating-add", args=[self.pk]),
+ _("Add period"),
+ "fa fa-plus",
+ _("period"),
+ "",
+ True,
+ ),
+ ]
can_add_geo = profile.mapping and self.can_do(request,
"ishtar_common.add_geovectordata")
if can_add_geo:
if self.base_finds.count() == 1:
actions.append(self.base_finds.all()[0].get_add_geo_action())
- can_edit_find = self.can_do(request, "archaeological_finds.change_find")
if can_edit_find and not is_locked:
actions += [
(
diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html
index 34c442542..6b557bc55 100644
--- a/archaeological_finds/templates/ishtar/sheet_find.html
+++ b/archaeological_finds/templates/ishtar/sheet_find.html
@@ -29,6 +29,7 @@
{% with can_view_container=permission_view_own_container|or_:permission_view_container %}
{% with display_warehouse_treatments=item.container|or_:item.container_ref|or_:item.upstream_treatment|or_:item.downstream_treatment|or_:non_modif_treatments_count|or_:associated_treatment_files_count %}
{% with can_view_documents=permission_view_own_document|or_:permission_view_document %}
+{% with can_change=permission_change_own_find|or_:permission_change_find %}
{% with has_documents=item|safe_or:"documents.count|documents_list"|safe_and_not:"documents_not_available" %}
{% with display_documents=can_view_documents|and_:has_documents %}
{% with has_image=item.images_number %}
@@ -252,7 +253,7 @@
{% endif %}
{% with dating_list=item|m2m_listing:"datings" %}
- {% if dating_list or item.dating_comment or item.cultural_attributions_count or item.periods_count %}
+ {% if can_change or dating_list or item.dating_comment or item.cultural_attributions_count or item.periods_count %}
<h3>{% trans "Periods / Datings" %}</h3>
{% if item.cultural_attributions_count or item.periods_count %}
<div class='row'>
@@ -260,8 +261,10 @@
{% field_flex_multiple_obj "Cultural attributions" item 'cultural_attributions' %}
</div>
{% endif %}
- {% if dating_list %}
+ {% if can_change or dating_list %}
+ {% with url_dating="find-dating" %}
{% include "ishtar/blocks/sheet_dating_list.html" %}
+ {% endwith %}
{% endif %}
<div class='row'>
{% field_flex_full "Comment on dating" item.dating_comment "<pre>" "</pre>" %}
@@ -321,7 +324,7 @@
{% endif %}
</div>
-{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}
+{% endwith %} {% endwith %} {% endwith %} {% endwith %} {% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %}{% endwith %} {% endwith %}
{% endblock %}
diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py
index a690b8698..345043c12 100644
--- a/archaeological_finds/urls.py
+++ b/archaeological_finds/urls.py
@@ -75,6 +75,30 @@ urlpatterns = [
)(views.QAFindDuplicateFormView.as_view()),
name="find-qa-duplicate",
),
+ path(
+ "find-dating/<int:pk>/",
+ check_permissions(["archaeological_finds.change_find",
+ "archaeological_finds.change_own_find"])(
+ views.find_dating_add
+ ),
+ name="find-dating-add",
+ ),
+ path(
+ "find-dating/<int:pk>/<int:dating_pk>/",
+ check_permissions(["archaeological_finds.change_find",
+ "archaeological_finds.change_own_find"])(
+ views.find_dating_modify
+ ),
+ name="find-dating-modify",
+ ),
+ path(
+ "find-dating-delete/<int:dating_pk>/",
+ check_permissions(["archaeological_finds.change_find",
+ "archaeological_finds.change_own_find"])(
+ views.find_dating_delete
+ ),
+ name="find-dating-delete",
+ ),
re_path(r"get-findbasket/$", views.get_find_basket, name="get-findbasket"),
re_path(
r"get-findbasket-write/$",
diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py
index 6b612af43..bbde421ab 100644
--- a/archaeological_finds/views.py
+++ b/archaeological_finds/views.py
@@ -61,6 +61,7 @@ from ishtar_common.views_item import (
get_autocomplete_queries,
get_autocomplete_query
)
+from archaeological_context_records.views import get_dating_delete, get_dating_form
from archaeological_operations.wizards import AdministrativeActDeletionWizard
from archaeological_finds import wizards
@@ -1426,6 +1427,12 @@ class QAFindLockView(QABaseLockView):
base_url = "find-qa-lock"
+find_dating_add = get_dating_form(models.Find, models.FindDating, "find-dating-add")
+find_dating_modify = get_dating_form(models.Find, models.FindDating, "find-dating-modify")
+find_dating_delete = get_dating_delete(
+ models.Find, models.FindDating, "find-dating-delete")
+
+
def get_geo_items(request, current_right=None):
operation_pk = request.GET.get("operation_id")
context_record_pk = request.GET.get("context_record_id")