diff options
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r-- | archaeological_warehouse/models.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 92eaf5d2f..3b157ee0c 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -23,7 +23,7 @@ from django.conf import settings from django.contrib.gis.db import models from django.core.urlresolvers import reverse from django.db.models import Q -from django.db.models.signals import post_save, post_delete +from django.db.models.signals import post_save, post_delete, m2m_changed from django.template.defaultfilters import slugify from django.utils.translation import ugettext_lazy as _, pgettext_lazy, \ activate, deactivate @@ -31,7 +31,8 @@ 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 + ImageModel, DashboardFormItem, ExternalIdManager, ShortMenuItem, \ + document_attached_changed from ishtar_common.utils import cached_label_changed @@ -87,6 +88,9 @@ class Warehouse(Address, DashboardFormItem, OwnPerms, documents = models.ManyToManyField( Document, related_name='warehouses', verbose_name=_(u"Documents"), blank=True) + main_image = models.ForeignKey( + Document, related_name='main_image_warehouses', + verbose_name=_(u"Main image"), blank=True, null=True) external_id = models.TextField(_(u"External ID"), blank=True, null=True) auto_external_id = models.BooleanField( _(u"External ID is set automatically"), default=False) @@ -252,6 +256,10 @@ class Warehouse(Address, DashboardFormItem, OwnPerms, return +m2m_changed.connect(document_attached_changed, + sender=Warehouse.documents.through) + + class Collection(LightHistorizedItem): name = models.CharField(_(u"Name"), max_length=200, null=True, blank=True) |