summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py63
1 files changed, 11 insertions, 52 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index bc140a2d7..0b974ecf8 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -34,62 +34,11 @@ from ishtar_common.models import GeneralType, BaseHistorizedItem, \
HistoricalRecords, LightHistorizedItem, OwnPerms, Department, Source,\
Person, Organization, Town, Dashboard, IshtarUser, ValueGetter, \
DocumentTemplate, ShortMenuItem, DashboardFormItem, GeneralRelationType,\
- GeneralRecordRelations, post_delete_record_relation
+ GeneralRecordRelations, post_delete_record_relation, OperationType
FILES_AVAILABLE = 'archaeological_files' in settings.INSTALLED_APPS
FINDS_AVAILABLE = 'archaeological_finds' in settings.INSTALLED_APPS
-class OperationType(GeneralType):
- order = models.IntegerField(_(u"Order"), default=1)
- preventive = models.BooleanField(_(u"Is preventive"), default=True)
-
- class Meta:
- verbose_name = _(u"Operation type")
- verbose_name_plural = _(u"Operation types")
- ordering = ['-preventive', 'order', 'label']
-
- @classmethod
- def get_types(cls, dct={}, instances=False, exclude=[], empty_first=True,
- default=None):
- tuples = []
- dct['available'] = True
- if not instances and empty_first and not default:
- tuples.append(('', '--'))
- if default:
- try:
- default = cls.objects.get(txt_idx=default)
- tuples.append((default.pk, _(unicode(default))))
- except cls.DoesNotExist:
- pass
- items = cls.objects.filter(**dct)
- if default:
- exclude.append(default.txt_idx)
- if exclude:
- items = items.exclude(txt_idx__in=exclude)
- current_preventive, current_lst = None, None
- for item in items.order_by(*cls._meta.ordering).all():
- if not current_lst or item.preventive != current_preventive:
- if current_lst:
- tuples.append(current_lst)
- current_lst = [_(u"Preventive") if item.preventive else
- _(u"Research"), []]
- current_preventive = item.preventive
- current_lst[1].append((item.pk, _(unicode(item))))
- if current_lst:
- tuples.append(current_lst)
- return tuples
-
- @classmethod
- def is_preventive(cls, ope_type_id, key=''):
- try:
- op_type = OperationType.objects.get(pk=ope_type_id)
- except OperationType.DoesNotExist:
- return False
- if not key:
- return op_type.preventive
- return key == op_type.txt_idx
-
-
class RemainType(GeneralType):
class Meta:
verbose_name = _(u"Remain type")
@@ -1384,3 +1333,13 @@ class OperationDashboard:
dct_res['towns_cost'].append((u"%s (%s)" % (
r['town__name'], r['town__departement__number']),
r['nb']))
+
+
+class OperationTypeOld(GeneralType):
+ order = models.IntegerField(_(u"Order"), default=1)
+ preventive = models.BooleanField(_(u"Is preventive"), default=True)
+
+ class Meta:
+ verbose_name = _(u"Operation type old")
+ verbose_name_plural = _(u"Operation types old")
+ ordering = ['-preventive', 'order', 'label']