summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-11-19 11:58:15 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-02-19 14:45:56 +0100
commite7dfaffc372292d8467da8a8be872e9ac9456618 (patch)
tree0cac7d0f5fcaf03d07062fc35a18a43b0aaa7cae
parent225f4356ca145d7f634aa8050d936de2dbd1cfec (diff)
downloadIshtar-e7dfaffc372292d8467da8a8be872e9ac9456618.tar.bz2
Ishtar-e7dfaffc372292d8467da8a8be872e9ac9456618.zip
✨ base exhibition views
-rw-r--r--archaeological_finds/forms_treatments.py13
-rw-r--r--archaeological_finds/ishtar_menu.py10
-rw-r--r--archaeological_finds/models_finds.py18
-rw-r--r--archaeological_finds/templates/ishtar/sheet_findbasket.html1
-rw-r--r--archaeological_finds/urls.py18
-rw-r--r--archaeological_finds/views.py9
-rw-r--r--archaeological_finds/wizards.py7
-rw-r--r--ishtar_common/menu_base.py2
-rw-r--r--ishtar_common/wizards.py4
9 files changed, 75 insertions, 7 deletions
diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py
index d5e353a53..88b26905d 100644
--- a/archaeological_finds/forms_treatments.py
+++ b/archaeological_finds/forms_treatments.py
@@ -705,13 +705,22 @@ class TreatmentFileFormSelectionMultiple(MultiSearchForm):
validators=[valid_ids(models.TreatmentFile)])
+class ExhibitionFormSelection(TreatmentFileFormSelection):
+ pk = forms.CharField(
+ label="", required=False,
+ widget=widgets.DataTable(
+ reverse_lazy('get-exhibition'),
+ TreatmentFileSelect, models.TreatmentFile,
+ ),
+ validators=[valid_ids(models.TreatmentFile)])
+
+
class TreatmentFileForm(CustomForm, ManageOldType):
form_label = _("Treatment request")
base_models = ['treatment_type_type']
associated_models = {
'type': models.TreatmentFileType, 'in_charge': Person,
'applicant': Person, 'applicant_organisation': Organization,
- 'associated_basket': models.FindBasket
}
need_user_for_initialization = True
@@ -745,7 +754,7 @@ class TreatmentFileForm(CustomForm, ManageOldType):
reverse_lazy('autocomplete-organization'),
associated_model=Organization, new=True),
validators=[valid_id(Organization)], required=False)
- associated_basket = forms.IntegerField(
+ associated_basket_id = forms.IntegerField(
label=_("Associated basket"),
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-findbasket'),
diff --git a/archaeological_finds/ishtar_menu.py b/archaeological_finds/ishtar_menu.py
index 3fd01e00d..967d3267c 100644
--- a/archaeological_finds/ishtar_menu.py
+++ b/archaeological_finds/ishtar_menu.py
@@ -138,6 +138,16 @@ MENU_SECTIONS = [
css="menu-warehouse",
childs=[
MenuItem(
+ "exhibition",
+ _("Exhibition"),
+ model=models.TreatmentFile,
+ profile_restriction="museum",
+ access_controls=[
+ "archaeological_finds.view_treatmentfile",
+ "archaeological_finds.view_own_treatmentfile"
+ ],
+ ),
+ MenuItem(
"treatmentfle_search",
_("Search"),
model=models.TreatmentFile,
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 4c410f668..68d49dfd6 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -955,6 +955,24 @@ class FindBasket(Basket, MainItem, ValueGetter):
)
ADMIN_SECTION = _("Finds")
+ @property
+ def treatments(self):
+ Treatment = apps.get_model("archaeological_finds", "Treatment")
+ return Treatment.objects.filter(associated_basket_id=self.pk)
+
+ @property
+ def treatments_list(self):
+ return list(self.treatments.all())
+
+ @property
+ def treatment_files(self):
+ TreatmentFile = apps.get_model("archaeological_finds", "TreatmentFile")
+ return TreatmentFile.objects.filter(associated_basket_id=self.pk)
+
+ @property
+ def treatment_files_list(self):
+ return list(self.treatment_files.all())
+
def get_values(self, prefix="", no_values=False, filtr=None, **kwargs):
base_exclude = kwargs["exclude"][:] if "exclude" in kwargs else []
base_exclude.append(prefix + "items")
diff --git a/archaeological_finds/templates/ishtar/sheet_findbasket.html b/archaeological_finds/templates/ishtar/sheet_findbasket.html
index c846c0494..33b685abf 100644
--- a/archaeological_finds/templates/ishtar/sheet_findbasket.html
+++ b/archaeological_finds/templates/ishtar/sheet_findbasket.html
@@ -17,6 +17,7 @@
{% field_flex "Comment" item.comment %}
{% field_flex_multiple_full "Shared (read) with" item.shared_with %}
{% field_flex_multiple_full "Shared (read/edit) with" item.shared_write_with %}
+ {% field_flex_detail_multiple_full _("Associated treatments") item.treatments %}
{% trans "Associated treatment files" as treatment_label %}
{% field_flex_detail_multiple_full treatment_label item.treatment_files %}
</div>
diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py
index ad4082f8e..2af33537f 100644
--- a/archaeological_finds/urls.py
+++ b/archaeological_finds/urls.py
@@ -439,6 +439,22 @@ urlpatterns = [
views.treatmentfile_administrativeacttreatmentfile_delete,
name="delete-administrativeact-treatmentfile",
),
+ path(
+ "exhibition/",
+ check_permissions(
+ ["archaeological_finds.view_treatmentfile",
+ "archaeological_finds.view_own_treatmentfile"]
+ )(views.exhibition_wizard),
+ name="exhibition-search",
+ ),
+ path(
+ "exhibition/<step>/",
+ check_permissions(
+ ["archaeological_finds.view_treatmentfile",
+ "archaeological_finds.view_own_treatmentfile"]
+ )(views.exhibition_wizard),
+ name="exhibition-search",
+ ),
url(
r"^treatmentfle_search/(?P<step>.+)?$",
check_permissions(
@@ -597,7 +613,7 @@ urlpatterns = [
kwargs={"full": "shortcut"},
),
url(
- r"^show-find-basket/(?:(?P<pk>.+)/(?P<type>.+)?)?$",
+ r"^show-findbasket/(?:(?P<pk>.+)/(?P<type>.+)?)?$",
views.show_findbasket,
name="show-findbasket",
),
diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py
index c50f4fb1b..777b064c5 100644
--- a/archaeological_finds/views.py
+++ b/archaeological_finds/views.py
@@ -221,7 +221,7 @@ revert_find = revert_item(models.Find)
show_findbasket = show_item(
models.FindBasket, "findbasket", model_for_perms=models.Find
)
-display_findbasket = display_item(models.FindBasket, show_url="show-find-basket")
+display_findbasket = display_item(models.FindBasket, show_url="show-findbasket")
def autocomplete_findbasket(request, current_right=None):
@@ -629,6 +629,13 @@ get_downstreamtreatment = get_item(
models.FindDownstreamTreatments, "get_downstreamtreatment", "downtreatment"
)
+
+exhibition_wizard = wizards.TreatmentFileSearch.as_view(
+ [("search", forms_treatments.ExhibitionFormSelection)],
+ label=_("Exhibition: search"),
+ url_name="exhibition-search",
+)
+
treatment_wizard_steps = [
("selecfind-treatment_creation", forms.UpstreamFindFormSelection),
("file-treatment_creation", forms.TreatmentFormFileChoice),
diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py
index f1d4a2dc4..c43f65356 100644
--- a/archaeological_finds/wizards.py
+++ b/archaeological_finds/wizards.py
@@ -524,6 +524,13 @@ class TreatmentFileWizard(Wizard):
wizard_done_window = reverse_lazy("show-treatmentfile")
redirect_url = "treatmentfile_modification"
+ def get_formated_data_for_associated_basket_id(self, value):
+ try:
+ value = str(models.FindBasket.objects.get(pk=value))
+ except models.FindBasket.DoesNotExist:
+ value = ""
+ return value
+
class TreatmentFileModificationWizard(TreatmentFileWizard):
modification = True
diff --git a/ishtar_common/menu_base.py b/ishtar_common/menu_base.py
index 809dd1c2d..bb0b88c02 100644
--- a/ishtar_common/menu_base.py
+++ b/ishtar_common/menu_base.py
@@ -91,8 +91,6 @@ class MenuItem:
self.available = False
self.profile_restriction = profile_restriction
self.css = css
- if not self.check_profile_restriction():
- return False
def check_profile_restriction(self):
if self.profile_restriction:
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 552db0e8d..740a1c18d 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -497,7 +497,9 @@ class Wizard(IshtarWizard):
continue
if key in self.translated_keys:
value = _(value)
- if type(value) == bool:
+ if hasattr(self, f"get_formated_data_for_{key}"):
+ value = getattr(self, f"get_formated_data_for_{key}")(value)
+ elif type(value) == bool:
if value:
value = _("Yes")
else: