summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-02-12 11:21:56 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-02-19 14:45:57 +0100
commit17d286b114f003c4dbf7865d668ab41b63bcec4f (patch)
tree64147de58a77abb71409fb5b1e71a61b9405512c
parent7313642f0ebcdfc83cc1d28906e618489594e8a9 (diff)
downloadIshtar-17d286b114f003c4dbf7865d668ab41b63bcec4f.tar.bz2
Ishtar-17d286b114f003c4dbf7865d668ab41b63bcec4f.zip
✨ exhibtion: add description field - basket sheet: display associated exhibitions
-rw-r--r--archaeological_finds/forms_treatments.py4
-rw-r--r--archaeological_finds/migrations/0135_exhibition_description.py23
-rw-r--r--archaeological_finds/models_finds.py11
-rw-r--r--archaeological_finds/models_treatments.py9
-rw-r--r--archaeological_finds/templates/ishtar/sheet_exhibition.html1
-rw-r--r--archaeological_finds/templates/ishtar/sheet_findbasket.html1
6 files changed, 48 insertions, 1 deletions
diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py
index 0ac7ee7d3..936834267 100644
--- a/archaeological_finds/forms_treatments.py
+++ b/archaeological_finds/forms_treatments.py
@@ -918,6 +918,8 @@ class ExhibitionSelect(DocumentItemSelect):
reverse_lazy('autocomplete-person'),
associated_model=Person),
validators=[valid_id(Person)])
+ description = forms.CharField(label=_("Description"))
+ comment = forms.CharField(label=_("Comment"))
TYPES = [
FieldType("exhibition_type", models.ExhibitionType),
]
@@ -963,6 +965,8 @@ class ExhibitionForm(forms.ModelForm, CustomForm, ManageOldType):
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-findbasket'),
associated_model=models.FindBasket), required=False)
+ description = forms.CharField(label=_("Description"),
+ widget=forms.Textarea, required=False)
comment = forms.CharField(label=_("Comment"),
widget=forms.Textarea, required=False)
diff --git a/archaeological_finds/migrations/0135_exhibition_description.py b/archaeological_finds/migrations/0135_exhibition_description.py
new file mode 100644
index 000000000..5e8444685
--- /dev/null
+++ b/archaeological_finds/migrations/0135_exhibition_description.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.24 on 2025-02-12 11:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_finds', '0134_other_reference_rename_find_treatment_imports'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='exhibition',
+ name='description',
+ field=models.TextField(blank=True, default='', verbose_name='Description'),
+ ),
+ migrations.AddField(
+ model_name='historicalexhibition',
+ name='description',
+ field=models.TextField(blank=True, default='', verbose_name='Description'),
+ ),
+ ]
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index e1c4e2f71..f49685199 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -973,6 +973,15 @@ class FindBasket(Basket, MainItem, ValueGetter):
def treatment_files_list(self):
return list(self.treatment_files.all())
+ @property
+ def exhibitions(self):
+ Exhibition = apps.get_model("archaeological_finds", "Exhibition")
+ return Exhibition.objects.filter(associated_basket_id=self.pk)
+
+ @property
+ def exhibitions_list(self):
+ return list(self.exhibitions.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")
@@ -1041,7 +1050,7 @@ class FindBasket(Basket, MainItem, ValueGetter):
(
reverse("findbasket-add-exhibition", args=[self.pk]),
_("Create exhibition"),
- "fa fa-calendar",
+ "fa fa-users",
"",
"",
False,
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index ce9066fc7..81b1df7df 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -1515,6 +1515,7 @@ class TreatmentFile(
def save(self, *args, **kwargs):
self.pre_save()
+ self.pre_save_basket()
super().save(*args, **kwargs)
@@ -1581,6 +1582,7 @@ class Exhibition(
verbose_name=_("Basket ID"), blank=True, null=True,
help_text=_("Reference basket")
)
+ description = models.TextField(_("Description"), blank=True, default="")
comment = models.TextField(_("Comment"), blank=True, default="")
treatment_files = models.ManyToManyField(
TreatmentFile,
@@ -1625,6 +1627,9 @@ class Exhibition(
]
ADMIN_SECTION = _("Treatments")
+ def __str__(self):
+ return f"{self.name or ''} [{self.year}]"
+
def get_extra_actions(self, request):
"""
For sheet template:
@@ -1645,3 +1650,7 @@ class Exhibition(
),
]
return actions
+
+ def save(self, *args, **kwargs):
+ self.pre_save_basket()
+ super().save(*args, **kwargs)
diff --git a/archaeological_finds/templates/ishtar/sheet_exhibition.html b/archaeological_finds/templates/ishtar/sheet_exhibition.html
index 71cad264a..820391a9e 100644
--- a/archaeological_finds/templates/ishtar/sheet_exhibition.html
+++ b/archaeological_finds/templates/ishtar/sheet_exhibition.html
@@ -50,6 +50,7 @@
{% field_flex _("Type") item.exhibition_type %}
{% field_flex _("Year") item.year %}
{% field_flex_detail _("Responsible") item.in_charge %}
+ {% field_flex_full "Description" item.description "<pre>" "</pre>" %}
{% field_flex_full "Comment" item.comment "<pre>" "</pre>" %}
{% include "ishtar/blocks/sheet_json.html" %}
</div>
diff --git a/archaeological_finds/templates/ishtar/sheet_findbasket.html b/archaeological_finds/templates/ishtar/sheet_findbasket.html
index 33b685abf..209c73862 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 exhibitions") item.exhibitions %}
{% 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 %}