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, 54 insertions, 9 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 14e5e1f7e..129040706 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -225,6 +225,28 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
'finds_deadline_before': 'finds_deadline__lte',
'finds_deadline_after': 'finds_deadline__gte',
}
+ EXTRA_FULL_FIELDS_LABELS = {
+ 'full_code_patriarche': u"Code patriarche",
+ 'year_index': _(u"Year - Index"),
+ 'associated_file_short_label': _(u"Associated file (label)"),
+ 'operator__name': _(u"Operator name"),
+ 'scientist__raw_name': _(u"Scientist (full name)"),
+ 'associated_file__external_id': _(u"Associated file (external ID)"),
+ 'scientist__title': _(u"Scientist (title)"),
+ 'scientist__surname': _(u"Scientist (surname)"),
+ 'scientist__name': _(u"Scientist (name)"),
+ 'scientist__attached_to__name': _(u"Scientist - Organization (name)"),
+ 'in_charge__title': _(u"In charge (title)"),
+ 'in_charge__surname': _(u"In charge (surname)"),
+ 'in_charge__name': _(u"In charge (name)"),
+ 'in_charge__attached_to__name': _(u"In charge - Organization (name)"),
+ 'cira_rapporteur__surname': u"Rapporteur CIRA (prénom)",
+ 'cira_rapporteur__name': u"Rapporteur CIRA (nom)",
+ 'cira_rapporteur__attached_to__name': u"Rapporteur CIRA - "
+ u"Organisation (nom)",
+ 'archaeological_sites__reference': _(u"Archaeological sites ("
+ u"reference)"),
+ }
# fields definition
creation_date = models.DateField(_(u"Creation date"),
@@ -355,9 +377,9 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
@classmethod
def get_owns(cls, user, menu_filtr=None, limit=None):
- replace_query = {}
- if menu_filtr:
- replace_query = {'associated_file': menu_filtr}
+ replace_query = None
+ if menu_filtr and 'file' in menu_filtr:
+ replace_query = Q(associated_file=menu_filtr['file'])
owns = super(Operation, cls).get_owns(
user, replace_query=replace_query,
limit=limit)
@@ -798,9 +820,9 @@ post_delete.connect(post_delete_record_relation, sender=RecordRelations)
class OperationByDepartment(models.Model):
- '''
+ """
Database view for dashboard
- '''
+ """
operation = models.ForeignKey(Operation, verbose_name=_(u"Operation"))
department = models.ForeignKey(Department, verbose_name=_(u"Department"),
blank=True, null=True)
@@ -860,8 +882,10 @@ class OperationSource(Source):
class ActType(GeneralType):
TYPE = (('F', _(u'Archaeological file')),
('O', _(u'Operation')),
+ ('TF', _(u'Treatment request')),
+ ('T', _(u'Treatment')),
)
- intented_to = models.CharField(_(u"Intended to"), max_length=1,
+ intented_to = models.CharField(_(u"Intended to"), max_length=2,
choices=TYPE)
code = models.CharField(_(u"Code"), max_length=10, blank=True, null=True)
associated_template = models.ManyToManyField(
@@ -965,7 +989,17 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
'archaeological_files.File',
blank=True, null=True,
related_name='administrative_act',
- verbose_name=_(u"Archaelogical file"))
+ verbose_name=_(u"Archaeological file"))
+ treatment_file = models.ForeignKey(
+ 'archaeological_finds.TreatmentFile',
+ blank=True, null=True,
+ related_name='administrative_act',
+ verbose_name=_(u"Treatment request"))
+ treatment = models.ForeignKey(
+ 'archaeological_finds.Treatment',
+ blank=True, null=True,
+ related_name='administrative_act',
+ verbose_name=_(u"Treatment"))
signature_date = models.DateField(_(u"Signature date"), blank=True,
null=True)
year = models.IntegerField(_(u"Year"), blank=True, null=True)
@@ -1003,7 +1037,7 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
def __unicode__(self):
return settings.JOINT.join(
[unicode(item) for item in [
- self.operation, self.associated_file, self.act_object]
+ self.related_item, self.act_object]
if item])
full_ref_lbl = _(u"Ref.")
@@ -1020,6 +1054,10 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
return u" ".join(lbl)
@property
+ def associated_filename(self):
+ return self.get_filename()
+
+ @property
def towns(self):
if self.associated_file:
return self.associated_file.towns.all()
@@ -1047,7 +1085,14 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
@property
def related_item(self):
- return self.operation if self.operation else self.associated_file
+ if self.operation:
+ return self.operation
+ if self.associated_file:
+ return self.associated_file
+ if self.treatment:
+ return self.treatment
+ if self.treatment_file:
+ return self.treatment_file
def get_filename(self):
filename = self.related_item.associated_filename