diff options
-rw-r--r-- | docs/src/INSTALL.t2t | 1 | ||||
-rw-r--r-- | ishtar/furnitures/forms.py | 2 | ||||
-rw-r--r-- | ishtar/furnitures/models.py | 14 |
3 files changed, 11 insertions, 6 deletions
diff --git a/docs/src/INSTALL.t2t b/docs/src/INSTALL.t2t index 9e147bcb2..d9ca435b5 100644 --- a/docs/src/INSTALL.t2t +++ b/docs/src/INSTALL.t2t @@ -18,6 +18,7 @@ Last update: %%date(%m-%d-%Y) - registration - libjs-jquery - libjs-jquery-ui +- django-formwizard To install django-simple-history: ``` diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index 91c9370bc..588d3b2de 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -198,7 +198,7 @@ def is_preventive(self, request, storage): try: file_type = int(request.session[storage.prefix]['step_data']['0']\ ['0-file_type']) - return file_type == models.PREVENTIVE + return models.FileType.is_preventive(file_type) except ValueError: return False 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") |