diff options
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 17 | 
1 files changed, 10 insertions, 7 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 082a0072d..4342db912 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -33,18 +33,20 @@ if FILES_AVAILABLE:      from archaeological_files.models import File  class OperationType(GeneralType): +    preventive = models.BooleanField(_(u"Is preventive"), default=True)      class Meta:          verbose_name = _(u"Operation type")          verbose_name_plural = _(u"Operation types")      @classmethod      def is_preventive(cls, ope_type_id, key=''): -        key = key or 'prev_excavation'          try: -            preventive = OperationType.objects.get(txt_idx=key).pk -            return ope_type_id == preventive +            op_type = OperationType.objects.get(pk=ope_type_id)          except ObjectDoesNotExist:              return False +        if not key: +            return op_type.preventive +        return key == op_type.txt_idx  class RemainType(GeneralType):      class Meta: @@ -74,8 +76,9 @@ class Operation(BaseHistorizedItem, OwnPerms):      end_date = models.DateField(_(u"Closing date"), null=True, blank=True)      in_charge = models.ForeignKey(Person, related_name='+', null=True,                                    blank=True, verbose_name=_(u"In charge")) -    year = models.IntegerField(_(u"Year")) -    operation_code = models.IntegerField(_(u"Operation code")) +    year = models.IntegerField(_(u"Year"), null=True, blank=True) +    operation_code = models.IntegerField(_(u"Operation code"), null=True, +                                         blank=True)      if FILES_AVAILABLE:          associated_file = models.ForeignKey(File, related_name='operations',                                   verbose_name=_(u"File"), blank=True, null=True) @@ -110,8 +113,8 @@ class Operation(BaseHistorizedItem, OwnPerms):           _(u"Prescription on geoarchaeological context"), blank=True, null=True)      operator_reference = models.CharField(_(u"Operator reference"),                                      max_length=20, null=True, blank=True) -    common_name = models.CharField(_(u"Generic name"), max_length=120, null=True, -                                   blank=True) +    common_name = models.CharField(_(u"Generic name"), max_length=120, +                                   null=True, blank=True)      comment = models.TextField(_(u"Comment"), null=True, blank=True)      history = HistoricalRecords()  | 
