diff options
Diffstat (limited to 'ishtar/furnitures/models.py')
| -rw-r--r-- | ishtar/furnitures/models.py | 14 | 
1 files changed, 9 insertions, 5 deletions
| diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index 0aac7d297..65258c65d 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -25,6 +25,7 @@ import datetime  from django.core.exceptions import ObjectDoesNotExist, ValidationError  from django.core.validators import validate_slug  from django.utils.translation import ugettext_lazy as _, ugettext +from django.db.utils import DatabaseError  from django.contrib.auth.models import User  from django.contrib.gis.db import models @@ -199,10 +200,14 @@ class FileType(GeneralType):          verbose_name = _(u"Archaeological file type")          verbose_name_plural = _(u"Archaeological file types") -try: -    PREVENTIVE = FileType.objects.filter(txt_idx="preventive").all()[0].pk -except: -    PREVENTIVE = 0 +    @classmethod +    def is_preventive(cls, file_type_id): +        try: +            preventive = FileType.objects.get(txt_idx="preventive").pk +            return file_type_id == preventive +        except ObjectDoesNotExist: +            return False +  if settings.COUNTRY == 'fr':      class SaisineType(GeneralType): @@ -251,7 +256,6 @@ class File(BaseHistorizedItem, OwnPerms):      def __unicode__(self):        return u"%d - %s" % (self.year, self.internal_reference) -  class OperationType(GeneralType):      class Meta:          verbose_name = _(u"Operation type") | 
