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.py41
1 files changed, 33 insertions, 8 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index a855c3bda..228e9859e 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -66,8 +66,8 @@ class ReportState(GeneralType):
order = models.IntegerField(_(u"Order"))
class Meta:
- verbose_name = _(u"Report state")
- verbose_name_plural = _(u"Report states")
+ verbose_name = _(u"Type of report state")
+ verbose_name_plural = _(u"Types of report state")
ordering = ('order',)
def __unicode__(self):
@@ -174,6 +174,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
'start_date', 'excavation_end_date']
TABLE_COLS.insert(4, 'associated_file_short_label')
IMAGE_PREFIX = 'operations/'
+ SLUG = 'operation'
creation_date = models.DateField(_(u"Creation date"),
default=datetime.date.today)
end_date = models.DateField(_(u"Closing date"), null=True, blank=True)
@@ -194,7 +195,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
on_delete=models.SET_NULL,
related_name='operation_responsability')
year = models.IntegerField(_(u"Year"), null=True, blank=True)
- operation_code = models.IntegerField(_(u"Operation code"), null=True,
+ operation_code = models.IntegerField(_(u"Numeric reference"), null=True,
blank=True)
associated_file = models.ForeignKey(
'archaeological_files.File',
@@ -269,6 +270,16 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
_(u"Record quality"), max_length=2, null=True, blank=True,
choices=QUALITY)
abstract = models.TextField(_(u"Abstract"), null=True, blank=True)
+ documentation_deadline = models.DateField(
+ _(u"Deadline for submission of the documentation"), blank=True,
+ null=True)
+ documentation_received = models.NullBooleanField(
+ _(u"Documentation received"), blank=True, null=True)
+ finds_deadline = models.DateField(
+ _(u"Deadline for submission of the finds"), blank=True, null=True)
+ finds_received = models.NullBooleanField(
+ _(u"Finds received"), blank=True, null=True)
+
point = models.PointField(_(u"Point"), blank=True, null=True)
multi_polygon = models.MultiPolygonField(_(u"Multi polygon"), blank=True,
null=True)
@@ -288,8 +299,12 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
ordering = ('cached_label',)
@classmethod
- def get_owns(cls, user):
- owns = super(Operation, cls).get_owns(user)
+ def get_owns(cls, user, menu_filtr=None):
+ replace_query = {}
+ if menu_filtr:
+ replace_query = {'associated_file': menu_filtr}
+ owns = super(Operation, cls).get_owns(
+ user, replace_query=replace_query)
# owns = owns.annotate(null_count=Count('operation_code'))
# return owns.order_by("common_name", "-year", "operation_code")
return sorted(owns, key=lambda x: x.cached_label)
@@ -463,6 +478,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
@property
def nb_parcels(self):
+ _(u"Number of parcels")
nb = 0
if self.associated_file:
nb = self.associated_file.parcels.count()
@@ -513,7 +529,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
for res in q.all():
nbs.append((unicode(res['unit__label']),
self.context_record.filter(unit=res['unit']).count()))
- return nbs
+ return list(set(nbs))
@property
def nb_context_records_by_periods(self, update=False):
@@ -538,7 +554,8 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
def _nb_finds(self):
from archaeological_finds.models import Find
q = Find.objects.filter(
- base_finds__context_record__operation=self)
+ base_finds__context_record__operation=self,
+ upstream_treatment_id__isnull=True).distinct()
return q.count()
@property
@@ -549,13 +566,16 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
from archaeological_finds.models import Find
nbs = []
q = Find.objects.filter(
- base_finds__context_record__operation=self).values(
+ upstream_treatment_id__isnull=True,
+ base_finds__context_record__operation=self).distinct().values(
'material_types__pk', 'material_types__label').distinct().order_by(
'material_types__label')
for res in q.all():
nbs.append(
(unicode(res['material_types__label']),
Find.objects.filter(
+ base_finds__context_record__operation=self,
+ upstream_treatment_id__isnull=True,
material_types__pk=res['material_types__pk']).count()))
return nbs
@@ -577,6 +597,8 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
nbs.append(
(label,
Find.objects.filter(
+ base_finds__context_record__operation=self,
+ upstream_treatment_id__isnull=True,
object_types=res['object_types']).count()))
return nbs
@@ -595,6 +617,8 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
nbs.append(
(unicode(res['datings__period__label']),
Find.objects.filter(
+ base_finds__context_record__operation=self,
+ upstream_treatment_id__isnull=True,
datings__period=res['datings__period']).count()))
return nbs
@@ -626,6 +650,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
self.source,
ContextRecordSource.objects.filter(context_record__operation=self),
FindSource.objects.filter(
+ find__upstream_treatment_id__isnull=True,
find__base_finds__context_record__operation=self)]
for q in qs:
for res in q.values('source_type').distinct():