diff options
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 29 | 
1 files changed, 26 insertions, 3 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index c54a060cb..7507da817 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -882,8 +882,10 @@ class OperationSource(Source):  class ActType(GeneralType):      TYPE = (('F', _(u'Archaeological file')),              ('O', _(u'Operation')), +            ('TF', _(u'Treatment file')), +            ('T', _(u'Treatment')),              ) -    intented_to = models.CharField(_(u"Intended to"), max_length=1, +    intented_to = models.CharField(_(u"Intended to"), max_length=2,                                     choices=TYPE)      code = models.CharField(_(u"Code"), max_length=10, blank=True, null=True)      associated_template = models.ManyToManyField( @@ -988,6 +990,16 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):          blank=True, null=True,          related_name='administrative_act',          verbose_name=_(u"Archaeological file")) +    treatment_file = models.ForeignKey( +        'archaeological_finds.TreatmentFile', +        blank=True, null=True, +        related_name='administrative_act', +        verbose_name=_(u"Treatment file")) +    treatment = models.ForeignKey( +        'archaeological_finds.Treatment', +        blank=True, null=True, +        related_name='administrative_act', +        verbose_name=_(u"Treatment"))      signature_date = models.DateField(_(u"Signature date"), blank=True,                                        null=True)      year = models.IntegerField(_(u"Year"), blank=True, null=True) @@ -1025,7 +1037,7 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):      def __unicode__(self):          return settings.JOINT.join(              [unicode(item) for item in [ -                self.operation, self.associated_file, self.act_object] +                self.related_item, self.act_object]               if item])      full_ref_lbl = _(u"Ref.") @@ -1042,6 +1054,10 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):          return u" ".join(lbl)      @property +    def associated_filename(self): +        return self.get_filename() + +    @property      def towns(self):          if self.associated_file:              return self.associated_file.towns.all() @@ -1069,7 +1085,14 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):      @property      def related_item(self): -        return self.operation if self.operation else self.associated_file +        if self.operation: +            return self.operation +        if self.associated_file: +            return self.associated_file +        if self.treatment: +            return self.treatment +        if self.treatment_file: +            return self.treatment_file      def get_filename(self):          filename = self.related_item.associated_filename  | 
