summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-05-14 16:02:33 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:20 +0100
commit5fa2a1d83d08fe47ce8285d3d350b5d5da103edd (patch)
tree63d6dbce538def79fc2a007a6c841427ede69a05
parentcbd38f88d2fa64f29ac2ee8eac73bdc2c0377cb2 (diff)
downloadIshtar-5fa2a1d83d08fe47ce8285d3d350b5d5da103edd.tar.bz2
Ishtar-5fa2a1d83d08fe47ce8285d3d350b5d5da103edd.zip
Documents - add format, scale, associated containers
-rw-r--r--ishtar_common/forms_common.py23
-rw-r--r--ishtar_common/migrations/0204_auto_20200514_1124.py27
-rw-r--r--ishtar_common/models.py18
-rw-r--r--ishtar_common/templates/ishtar/sheet_document.html6
4 files changed, 71 insertions, 3 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index df8535240..70204fbd7 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -1235,7 +1235,9 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
form_slug = "document-general"
file_upload = True
extra_form_modals = ["author", "person", "organization"]
- associated_models = {'source_type': models.SourceType}
+ associated_models = {'source_type': models.SourceType,
+ 'support_type': models.SupportType,
+ 'format_type': models.Format}
pk = forms.IntegerField(label="", required=False, widget=forms.HiddenInput)
title = forms.CharField(label=_("Title"), required=False,
@@ -1243,6 +1245,19 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
source_type = widgets.ModelChoiceField(
model=models.SourceType, label=_("Source type"), choices=[],
required=False)
+ support_type = widgets.ModelChoiceField(
+ model=models.SupportType, label=_("Support"), choices=[],
+ required=False)
+ format_type = widgets.ModelChoiceField(
+ model=models.Format, label=_("Format"), choices=[],
+ required=False)
+ scale = forms.CharField(label=_("Scale"), max_length=30, required=False)
+ container = widgets.ModelJQueryAutocompleteField(
+ label=_("Current container"),
+ model=Container, required=False)
+ container_ref = widgets.ModelJQueryAutocompleteField(
+ label=_("Reference container"),
+ model=Container, required=False)
authors = widgets.ModelJQueryAutocompleteField(
model=models.Author, multiple=True, label=_("Authors"), new=True,
long_widget=True, required=False)
@@ -1284,23 +1299,29 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
TYPES = [
FieldType('source_type', models.SourceType),
+ FieldType('support_type', models.SupportType),
+ FieldType('format_type', models.Format),
]
class Meta:
model = models.Document
fields = [
'title', 'source_type', 'reference', 'internal_reference',
+ 'format_type', 'support_type', 'scale',
'image', 'associated_file', 'associated_url',
'authors', 'receipt_date',
'receipt_date_in_documentation', 'creation_date',
+ 'container', "container_ref",
'comment', 'description', 'additional_information', 'duplicate'
]
HEADERS = {
'title': FormHeader(_("Identification")),
+ 'format_type': FormHeader(_("Format")),
'image': FormHeader(_("Content")),
'authors': FormHeader(_("Authors")),
'receipt_date': FormHeader(_("Dates")),
+ 'container': FormHeader(_("Container"), collapse=True),
'comment': FormHeader(_("Advanced"), collapse=True),
'finds': FormHeader(_("Related items")),
}
diff --git a/ishtar_common/migrations/0204_auto_20200514_1124.py b/ishtar_common/migrations/0204_auto_20200514_1124.py
new file mode 100644
index 000000000..4eea40bf3
--- /dev/null
+++ b/ishtar_common/migrations/0204_auto_20200514_1124.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.27 on 2020-05-14 11:24
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_warehouse', '0103_auto_container_views'),
+ ('ishtar_common', '0203_auto_20200407_1142'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='document',
+ name='container',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='contained_documents', to='archaeological_warehouse.Container', verbose_name='Container'),
+ ),
+ migrations.AddField(
+ model_name='document',
+ name='container_ref',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='contained_documents_ref', to='archaeological_warehouse.Container', verbose_name='Reference container'),
+ ),
+ ]
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 6eea042ce..4b9253b03 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -5525,6 +5525,15 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
verbose_name=_("Receipt date in documentation"))
item_number = models.IntegerField(_("Number of items"), default=1)
description = models.TextField(_("Description"), blank=True, null=True)
+ container = models.ForeignKey(
+ "archaeological_warehouse.Container", verbose_name=_("Container"),
+ blank=True, null=True, related_name='contained_documents',
+ on_delete=models.SET_NULL)
+ container_ref = models.ForeignKey(
+ "archaeological_warehouse.Container",
+ verbose_name=_("Reference container"),
+ blank=True, null=True,
+ related_name='contained_documents_ref', on_delete=models.SET_NULL)
comment = models.TextField(_("Comment"), blank=True, null=True)
additional_information = models.TextField(_("Additional information"),
blank=True, null=True)
@@ -5573,6 +5582,15 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel,
def duplicate_item(self, user=None, data=None):
return duplicate_item(self, user, data)
+ @property
+ def source_type_html(self):
+ source_types = []
+ source_type = self.source_type
+ while source_type:
+ source_types.append(str(source_type))
+ source_type = source_type.parent
+ return " / ".join(reversed(source_types))
+
def public_representation(self):
site = Site.objects.get_current()
if settings.ISHTAR_SECURE:
diff --git a/ishtar_common/templates/ishtar/sheet_document.html b/ishtar_common/templates/ishtar/sheet_document.html
index 93951c056..321125edd 100644
--- a/ishtar_common/templates/ishtar/sheet_document.html
+++ b/ishtar_common/templates/ishtar/sheet_document.html
@@ -24,16 +24,18 @@
<div class="row">
{% field_flex "Title" item.title %}
{% field_flex "Index" item.index %}
- {% field_flex "Source type" item.source_type %}
+ {% field_flex "Source type" item.source_type_html "" "" 1 %}
{% trans "File" context "Not directory" as file_label %}
{% field_flex_file file_label item.associated_file %}
- {% field_flex "Format type" item.format_type %}
+ {% field_flex "Format" item.format_type %}
{% field_flex "Scale" item.scale %}
{% trans "Web link" as weblink_label %}
{% field_flex_url weblink_label item.associated_url %}
{% if item.item_number != 1 %}{% field_flex "Item number" item.item_number %}{% endif %}
{% field_flex "Ref." item.reference %}
{% field_flex "Internal ref." item.internal_reference %}
+ {% field_flex_detail "Container" item.container %}
+ {% field_flex_detail "Reference container" item.container_ref %}
{% field_flex "Creation date" item.creation_date %}
{% field_flex "Receipt date" item.receipt_date %}
{% field_flex "Receipt date in documentation" item.receipt_date_in_documentation %}