diff options
Diffstat (limited to 'archaeological_warehouse')
-rw-r--r-- | archaeological_warehouse/migrations/0033_auto_20190212_1524.py | 40 | ||||
-rw-r--r-- | archaeological_warehouse/models.py | 17 | ||||
-rw-r--r-- | archaeological_warehouse/templates/ishtar/sheet_container.html | 52 |
3 files changed, 83 insertions, 26 deletions
diff --git a/archaeological_warehouse/migrations/0033_auto_20190212_1524.py b/archaeological_warehouse/migrations/0033_auto_20190212_1524.py new file mode 100644 index 000000000..0af79c8bd --- /dev/null +++ b/archaeological_warehouse/migrations/0033_auto_20190212_1524.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2019-02-12 15:24 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0084_auto_20190206_1522'), + ('archaeological_warehouse', '0032_auto_20190206_1442'), + ] + + operations = [ + migrations.RemoveField( + model_name='container', + name='image', + ), + migrations.RemoveField( + model_name='container', + name='thumbnail', + ), + migrations.AddField( + model_name='container', + name='documents', + field=models.ManyToManyField(blank=True, related_name='containers', to='ishtar_common.Document', verbose_name='Documents'), + ), + migrations.AddField( + model_name='container', + name='main_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='main_image_containers', to='ishtar_common.Document', verbose_name='Image principale'), + ), + migrations.AlterField( + model_name='warehouse', + name='main_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='main_image_warehouses', to='ishtar_common.Document', verbose_name='Image principale'), + ), + ] diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index a0da12601..42a9bb310 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -30,7 +30,7 @@ from django.utils.translation import ugettext_lazy as _, pgettext_lazy from ishtar_common.data_importer import post_importer_action from ishtar_common.models import Document, GeneralType, get_external_id, \ LightHistorizedItem, OwnPerms, Address, Person, post_save_cache, \ - ImageModel, DashboardFormItem, ExternalIdManager, ShortMenuItem, \ + DashboardFormItem, ExternalIdManager, ShortMenuItem, \ document_attached_changed, SearchAltName from ishtar_common.utils import cached_label_changed @@ -316,7 +316,7 @@ post_save.connect(post_save_cache, sender=ContainerType) post_delete.connect(post_save_cache, sender=ContainerType) -class Container(LightHistorizedItem, ImageModel, OwnPerms): +class Container(LightHistorizedItem, OwnPerms): SLUG = 'container' SHOW_URL = 'show-container' TABLE_COLS = ['reference', 'container_type__label', 'cached_location', @@ -393,6 +393,13 @@ class Container(LightHistorizedItem, ImageModel, OwnPerms): external_id = models.TextField(_(u"External ID"), blank=True, null=True) auto_external_id = models.BooleanField( _(u"External ID is set automatically"), default=False) + documents = models.ManyToManyField( + Document, related_name='containers', verbose_name=_(u"Documents"), + blank=True) + main_image = models.ForeignKey( + Document, related_name='main_image_containers', + on_delete=models.SET_NULL, + verbose_name=_(u"Main image"), blank=True, null=True) class Meta: verbose_name = _(u"Container") @@ -431,6 +438,9 @@ class Container(LightHistorizedItem, ImageModel, OwnPerms): ] return u" | ".join(locas) + def _get_base_image_path(self): + return self.responsible._get_base_image_path() + u"/" + self.external_id + @classmethod def get_query_owns(cls, ishtaruser): return Q(history_creator=ishtaruser.user_ptr) | \ @@ -631,6 +641,9 @@ class Container(LightHistorizedItem, ImageModel, OwnPerms): post_save.connect(cached_label_changed, sender=Container) +m2m_changed.connect(document_attached_changed, + sender=Container.documents.through) + class ContainerLocalisation(models.Model): container = models.ForeignKey(Container, verbose_name=_(u"Container"), diff --git a/archaeological_warehouse/templates/ishtar/sheet_container.html b/archaeological_warehouse/templates/ishtar/sheet_container.html index 262d7145b..27cbf9bee 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_container.html +++ b/archaeological_warehouse/templates/ishtar/sheet_container.html @@ -8,34 +8,38 @@ {% endblock %} {% block content %} -<div class="row"> - <div class="offset-lg-4 col-lg-4 offset-md-3 col-md-6 offset-sm-1 col-sm-10 col-12"> - <div class="card"> - {% include "ishtar/blocks/window_image.html" %} - <div class="card-body"> - <p class="card-text"> - <p class="window-refs">{{ item.reference|default:"" }}</p> - <p class="window-refs">{{ item.container_type|default:"" }}</p> - <p class="window-refs">{{ item.responsible.name }} - {{ item.index }}</p> - <p class="window-refs">{{ item.old_reference|default:"" }}</p> - {% include "ishtar/blocks/sheet_external_id.html" %} - </p> - </div> - </div> +<div class="clearfix"> + {% if item.main_image %} + <div class="card float-left col-12 col-md-4"> + {% include "ishtar/blocks/window_image.html" %} + </div> + {% endif %} + {% if item.main_image %} + <div class="float-left col-12 col-md-6 col-lg-8 text-center">{# </div>> #} + {% else %} + <div class="float-left col-6 col-md-3 text-center"> + {% endif %} + <p class="window-refs">{{ item.reference|default:"" }}</p> + <p class="window-refs">{{ item.container_type|default:"" }}</p> + <p class="window-refs">{{ item.responsible.name }} - {{ item.index }}</p> + <p class="window-refs">{{ item.old_reference|default:"" }}</p> + {% include "ishtar/blocks/sheet_external_id.html" %} + </div> + {% if item.main_image %} + <div class="row float-left col-12 col-md-6 col-lg-8 text-center">{# </div>> #} + {% else %} + <div class="float-left row col-6 col-md-8"> + {% endif %} + {% field_flex_detail "Responsible warehouse" item.responsible %} + {% field_flex_detail "Location (warehouse)" item.location %} + {% include "ishtar/blocks/sheet_creation_section.html" %} + {% field_flex "Location" item.precise_location %} + {% field_flex_full "Comment" item.comment "<pre>" "</pre>" %} + {% include "ishtar/blocks/sheet_json.html" %} </div> </div> -<div class="row"> - {% field_flex_detail "Responsible warehouse" item.responsible %} - {% field_flex_detail "Location (warehouse)" item.location %} - {% include "ishtar/blocks/sheet_creation_section.html" %} - {% field_flex "Location" item.precise_location %} - {% field_flex_full "Comment" item.comment "<pre>" "</pre>" %} -</div> - -{% include "ishtar/blocks/sheet_json.html" %} - {% if item.finds.count %} <h4>{% trans "Content" %}</h4> {% dynamic_table_document finds 'finds' 'container' item.pk 'TABLE_COLS' output 'large' %} |