diff options
Diffstat (limited to 'archaeological_finds/models.py')
-rw-r--r-- | archaeological_finds/models.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 4b1e95e34..8fb18385b 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2012-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,7 +22,7 @@ from django.contrib.gis.db import models from django.db.models import Max from django.utils.translation import ugettext_lazy as _, ugettext -from ishtar_common.models import GeneralType, BaseHistorizedItem, \ +from ishtar_common.models import GeneralType, ImageModel, BaseHistorizedItem, \ LightHistorizedItem, HistoricalRecords, OwnPerms, Source, Person from archaeological_operations.models import AdministrativeAct @@ -130,7 +130,7 @@ class BaseFind(BaseHistorizedItem, OwnPerms): self.context_record.label, lbl) if it]) -class Find(BaseHistorizedItem, OwnPerms): +class Find(BaseHistorizedItem, ImageModel, OwnPerms): TABLE_COLS = ['label', 'material_type', 'dating.period', 'base_finds.context_record.parcel.town', 'base_finds.context_record.operation.year', @@ -145,6 +145,10 @@ class Find(BaseHistorizedItem, OwnPerms): order = models.IntegerField(_(u"Order")) label = models.CharField(_(u"ID"), max_length=60) description = models.TextField(_(u"Description"), blank=True, null=True) + """ + image = models.ImageField(upload_to="finds/", blank=True, null=True) + thumbnail = models.ImageField(upload_to='finds/thumbs/', blank=True, + null=True)""" material_type = models.ForeignKey(MaterialType, verbose_name = _(u"Material type")) volume = models.FloatField(_(u"Volume (l)"), blank=True, null=True) @@ -160,6 +164,13 @@ class Find(BaseHistorizedItem, OwnPerms): blank=True, null=True, related_name='finds') history = HistoricalRecords() + def __init__(self, *args, **kwargs): + super(Find, self).__init__(*args, **kwargs) + image = self._meta.get_field_by_name("image")[0] + image.upload_to = "finds/" + thumbnail = self._meta.get_field_by_name("thumbnail")[0] + thumbnail.upload_to = "finds/thumbs/" + @classmethod def get_years(cls): years = set() |