diff options
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index d8233ba0f..0b506e12b 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -36,7 +36,8 @@ from ishtar_common.models import BaseHistorizedItem, Dashboard, \ HistoricalRecords, IshtarUser, LightHistorizedItem, \ OperationType, Organization, OwnPerms, Person, PersonType, \ post_delete_record_relation, post_save_cache, RelationItem, \ - ShortMenuItem, SourceType, Town, ValueGetter, get_current_profile + ShortMenuItem, SourceType, Town, ValueGetter, get_current_profile, \ + document_attached_changed from ishtar_common.utils import cached_label_changed, \ force_cached_label_changed, mode @@ -267,6 +268,9 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, documents = models.ManyToManyField( Document, related_name="sites", verbose_name=_(u"Documents"), blank=True) + main_image = models.ForeignKey( + Document, related_name='main_image_sites', + verbose_name=_(u"Main image"), blank=True, null=True) cached_label = models.TextField(_(u"Cached name"), null=True, blank=True, db_index=True) @@ -420,6 +424,9 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, post_save.connect(cached_label_changed, sender=ArchaeologicalSite) +m2m_changed.connect(document_attached_changed, + sender=ArchaeologicalSite.documents.through) + def get_values_town_related(item, prefix, values): values[prefix + 'parcellist'] = item.render_parcels() @@ -845,6 +852,9 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, documents = models.ManyToManyField( Document, related_name='operations', verbose_name=_(u"Documents"), blank=True) + main_image = models.ForeignKey( + Document, related_name='main_image_operations', + verbose_name=_(u"Main image"), blank=True, null=True) cached_label = models.CharField(_(u"Cached name"), max_length=500, null=True, blank=True, db_index=True) archaeological_sites = models.ManyToManyField( @@ -1386,6 +1396,8 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, m2m_changed.connect(force_cached_label_changed, sender=Operation.towns.through) +m2m_changed.connect(document_attached_changed, + sender=Operation.documents.through) def operation_post_save(sender, **kwargs): |