diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-05-09 17:49:16 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:44:18 +0200 |
| commit | 43c017bc8dd00372f26728130b00b1cd9196fb10 (patch) | |
| tree | 3c5fab3ad0c77f861ee46e18d14e7d6f848226af /archaeological_context_records/models.py | |
| parent | bf3810a26abe3c53fc11c4afe52e865cd5dbcc54 (diff) | |
| download | Ishtar-43c017bc8dd00372f26728130b00b1cd9196fb10.tar.bz2 Ishtar-43c017bc8dd00372f26728130b00b1cd9196fb10.zip | |
Standardize related field item for imagee collections (refs #4076)
Diffstat (limited to 'archaeological_context_records/models.py')
| -rw-r--r-- | archaeological_context_records/models.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index bdb21ea39..396b91f67 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -34,7 +34,7 @@ from ishtar_common.models import GeneralType, BaseHistorizedItem, \ HistoricalRecords, OwnPerms, ShortMenuItem, Source, GeneralRelationType,\ GeneralRecordRelations, post_delete_record_relation, get_image_path, \ ImageModel, post_save_cache, ValueGetter, BulkUpdatedItem, IshtarImage, \ - RelationItem + RelationItem, ThroughImage from archaeological_operations.models import Operation, Period, Parcel, \ ArchaeologicalSite @@ -485,11 +485,8 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, return True def _get_base_image_path(self): - ope = self.operation - return u"operation/{}/{}/{}/{}".format( - ope.year, ope.reference, self.SLUG, - slugify(self.label or u"00") - ) + return self.operation._get_base_image_path() + \ + u"/{}/{}".format(self.SLUG, slugify(self.label or u"00")) @property def reference(self): @@ -565,10 +562,9 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, post_save.connect(cached_label_changed, sender=ContextRecord) -class ContextRecordImage(models.Model): - image = models.ForeignKey(IshtarImage, on_delete=models.CASCADE) - context_record = models.ForeignKey(ContextRecord, on_delete=models.CASCADE) - is_main = models.BooleanField(_(u"Main image"), default=False) +class ContextRecordImage(ThroughImage): + item = models.ForeignKey(ContextRecord, on_delete=models.CASCADE, + related_name='associated_images') class RelationType(GeneralRelationType): |
