summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py47
1 files changed, 42 insertions, 5 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index ba317998f..dd968f891 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2341,7 +2341,8 @@ class DocumentTemplate(models.Model):
return output_name
-class Area(HierarchicalType):
+class Area(HierarchicalType, DocumentItem):
+ SLUG = "area"
towns = models.ManyToManyField(
Town, verbose_name=_("Towns"), blank=True, related_name="areas"
)
@@ -2355,10 +2356,21 @@ class Area(HierarchicalType):
related_name="children",
on_delete=models.SET_NULL,
)
+ documents = models.ManyToManyField(
+ "Document", related_name="areas", verbose_name=_("Documents"), blank=True
+ )
+ main_image = models.ForeignKey(
+ "Document",
+ related_name="main_image_areas",
+ on_delete=models.SET_NULL,
+ verbose_name=_("Main image"),
+ blank=True,
+ null=True,
+ )
class Meta:
- verbose_name = _("Town - Area")
- verbose_name_plural = _("Town - Areas")
+ verbose_name = _("Area")
+ verbose_name_plural = _("Areas")
ordering = ("label",)
ADMIN_SECTION = _("Geography")
@@ -2435,6 +2447,12 @@ class Area(HierarchicalType):
label.append(self.parent.full_label)
return " / ".join(label)
+ def _get_base_image_path(self):
+ return self.SLUG
+
+
+#m2m_changed.connect(document_attached_changed, sender=Area.documents.through)
+
GENDER = (
("M", _("Male")),
@@ -3844,6 +3862,8 @@ class Document(
"containers",
"files",
"administrativeacts",
+ "towns",
+ "areas",
]
# same fields but in order for forms
RELATED_MODELS_ALT = [
@@ -3857,6 +3877,8 @@ class Document(
"containers",
"treatments",
"treatment_files",
+ "towns",
+ "areas",
]
SLUG = "document"
LINK_SPLIT = "<||>"
@@ -3874,6 +3896,10 @@ class Document(
"history_creator_id",
"containers",
"sites",
+ "towns",
+ "areas",
+ "main_image_towns",
+ "main_image_areas",
"main_image_warehouses",
"main_image_operations",
"main_image_treatments",
@@ -3915,6 +3941,8 @@ class Document(
SearchVectorConfig("warehouses__name"),
SearchVectorConfig("containers__cached_label"),
SearchVectorConfig("files__cached_label"),
+ SearchVectorConfig("towns__name"),
+ SearchVectorConfig("areas__label"),
]
PARENT_SEARCH_VECTORS = [
"authors",
@@ -4082,6 +4110,14 @@ class Document(
pgettext_lazy("key for text search", "warehouse"),
"warehouses__name__iexact",
),
+ "town": SearchAltName(
+ pgettext_lazy("key for text search", "town"),
+ "towns__name__iexact",
+ ),
+ "area": SearchAltName(
+ pgettext_lazy("key for text search", "area"),
+ "areas__label__iexact",
+ ),
"image__isnull": SearchAltName(
pgettext_lazy("key for text search", "has-image"), "image__isnull"
),
@@ -4275,7 +4311,8 @@ class Document(
)
scale = models.CharField(_("Scale"), max_length=30, null=True, blank=True)
authors = models.ManyToManyField(
- Author, verbose_name=_("Authors"), related_name="documents"
+ Author, verbose_name=_("Authors"), related_name="documents",
+ blank=True
)
authors_raw = models.CharField(
verbose_name=_("Authors (raw)"), blank=True, null=True, max_length=250
@@ -4302,7 +4339,7 @@ class Document(
)
# container = models.ForeignKey("archaeological_warehouse.Container")
container_ref_id = models.PositiveIntegerField(
- verbose_name=_("Container ID"), blank=True, null=True
+ verbose_name=_("Container reference ID"), blank=True, null=True
)
# container_ref = models.ForeignKey("archaeological_warehouse.Container")
comment = models.TextField(_("Comment"), blank=True, default="")