summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-09-08 16:50:47 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-09-08 16:51:10 +0200
commit472dafdad56d6d9ddf12d9200da9002d25b77055 (patch)
treed28bff9889e53e55b854a6feca7443ceacc95373 /archaeological_operations/models.py
parentd98a415de18e2db183d86bb313137f146d03740b (diff)
downloadIshtar-472dafdad56d6d9ddf12d9200da9002d25b77055.tar.bz2
Ishtar-472dafdad56d6d9ddf12d9200da9002d25b77055.zip
Operation sheet: fix stats (refs #2989)
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 37c9305e9..f5a1ca8b0 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -194,7 +194,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',
@@ -473,6 +473,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()
@@ -523,7 +524,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):
@@ -548,7 +549,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
@@ -559,13 +561,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
@@ -587,6 +592,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
@@ -605,6 +612,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
@@ -636,6 +645,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():