diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-09-09 20:04:26 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-09-09 20:04:26 +0200 | 
| commit | b6f2dfaeca2bd8e507333b299985e1e3386f6689 (patch) | |
| tree | 7c7a7a01a5cf2be00a3e737341d65c18d264e7a7 /archaeological_finds/models.py | |
| parent | 9fefb173a1c5a76df73dc5d5c94dcdb6f303990a (diff) | |
| download | Ishtar-b6f2dfaeca2bd8e507333b299985e1e3386f6689.tar.bz2 Ishtar-b6f2dfaeca2bd8e507333b299985e1e3386f6689.zip | |
Add many fields to finds - associated migrations, forms and autocomplete view (refs #2784)
Diffstat (limited to 'archaeological_finds/models.py')
| -rw-r--r-- | archaeological_finds/models.py | 29 | 
1 files changed, 29 insertions, 0 deletions
| diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index 4fd4543b4..947cd9067 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -67,6 +67,24 @@ class PreservationType(GeneralType):          ordering = ('label',) +class ObjectType(GeneralType): +    parent = models.ForeignKey("ObjectType", blank=True, null=True, +                               verbose_name=_(u"Parent")) + +    class Meta: +        verbose_name = _(u"Object type") +        verbose_name_plural = _(u"Object types") +        ordering = ('parent__label', 'label',) + +    def __unicode__(self): +        lbls = [self.label] +        item = self +        while item.parent: +            item = item.parent +            lbls.append(item.label) +        return u" > ".join(reversed(lbls)) + +  class BaseFind(BaseHistorizedItem, OwnPerms):      label = models.CharField(_(u"ID"), max_length=60)      external_id = models.CharField(_(u"External ID"), blank=True, null=True, @@ -225,6 +243,17 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):          container = models.ForeignKey(              Container, verbose_name=_(u"Container"), blank=True, null=True,              related_name='finds') +    is_complete = models.NullBooleanField(_(u"Is complete?"), blank=True, +                                          null=True) +    object_types = models.ManyToManyField( +        ObjectType, verbose_name=_(u"Object types"), related_name='find') +    length = models.FloatField(_(u"Length (cm)"), blank=True, null=True) +    width = models.FloatField(_(u"Width (cm)"), blank=True, null=True) +    height = models.FloatField(_(u"Height (cm)"), blank=True, null=True) +    diameter = models.FloatField(_(u"Diameter (cm)"), blank=True, null=True) +    mark = models.TextField(_(u"Mark"), blank=True, null=True) +    comment = models.TextField(_(u"Comment"), blank=True, null=True) +    previous_id = models.TextField(_(u"Previous ID"), blank=True, null=True)      history = HistoricalRecords()      def __init__(self, *args, **kwargs): | 
