diff options
Diffstat (limited to 'archaeological_finds/models.py')
| -rw-r--r-- | archaeological_finds/models.py | 28 | 
1 files changed, 14 insertions, 14 deletions
| diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index ce56fac27..99a7f14cb 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -132,12 +132,12 @@ class BaseFind(BaseHistorizedItem, OwnPerms):          # OPE|MAT.CODE|UE|FIND_index          if not self.context_record.operation:              return -        find = self.get_last_find() +        # find = self.get_last_find()          ope = self.context_record.operation          c_id = [unicode(ope.code_patriarche) if ope.code_patriarche else                  (unicode(ope.year) + "-" + unicode(ope.operation_code))] -        print c_id -        c_id.append(find and find.material_type.code or '') +        # c_id.append(find and find.material_type.code or '') +        c_id.append('')          c_id.append(self.context_record.label)          c_id.append(unicode(self.index))          return settings.JOINT.join(c_id) @@ -204,7 +204,7 @@ WEIGHT_UNIT = (('g', _(u"g")),  class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): -    TABLE_COLS = ['label', 'material_type', 'dating.period', +    TABLE_COLS = ['label', 'material_types', 'dating.period',                    'base_finds.context_record.parcel.town',                    'base_finds.context_record.operation.year',                    'base_finds.context_record.operation.operation_code', @@ -220,8 +220,8 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):      order = models.IntegerField(_(u"Order"), default=1)      label = models.CharField(_(u"ID"), max_length=60)      description = models.TextField(_(u"Description"), blank=True, null=True) -    material_type = models.ForeignKey( -        MaterialType, verbose_name=_(u"Material type")) +    material_types = models.ManyToManyField( +        MaterialType, verbose_name=_(u"Material types"), related_name='finds')      conservatory_state = models.ForeignKey(          ConservatoryState, verbose_name=_(u"Conservatory state"), blank=True,          null=True) @@ -377,7 +377,7 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):      def duplicate(self, user):          dct = dict([(attr, getattr(self, attr)) for attr in -                    ('order', 'label', 'description', 'material_type', +                    ('order', 'label', 'description',                       'volume', 'weight', 'find_number', 'dating',                       'conservatory_state', 'preservation_to_consider',                       'weight_unit', 'find_number')]) @@ -397,13 +397,13 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):                                .filter(context_record=base_find.context_record)\                                .aggregate(Max('index'))                  base_find.index = idx and idx['index__max'] + 1 or 1 -            if not base_find.material_index: -                idx = BaseFind.objects\ -                              .filter(context_record=base_find.context_record, -                                      find__material_type=self.material_type)\ -                              .aggregate(Max('material_index')) -                base_find.material_index = \ -                    idx and idx['material_index__max'] + 1 or 1 +            # if not base_find.material_index: +            #    idx = BaseFind.objects\ +            #                  .filter(context_record=base_find.context_record, +            #                          find__material_types=self.material_type)\ +            #                  .aggregate(Max('material_index')) +            #    base_find.material_index = \ +            #        idx and idx['material_index__max'] + 1 or 1              base_find.save() | 
