summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-04-07 12:16:37 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-04-07 12:16:37 +0200
commit6b87dae76d931ead9838db1f66a6ff1fe1cc1dd1 (patch)
tree0a2273d9db0499214e18a041987339eac9d20ac9 /archaeological_operations/models.py
parent75730c0ac55c935c03e58977405b4b8a2233595d (diff)
parent3d8b8d86f01ecb9b37e24e25fd15500b8f4fb2a0 (diff)
downloadIshtar-6b87dae76d931ead9838db1f66a6ff1fe1cc1dd1.tar.bz2
Ishtar-6b87dae76d931ead9838db1f66a6ff1fe1cc1dd1.zip
Merge branch 'master' into v0.9
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index e741f5644..3826678c3 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -269,6 +269,10 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
verbose_name=_(u"In charge"),
on_delete=models.SET_NULL,
related_name='operation_responsability')
+ collaborators = models.ManyToManyField(
+ Person, blank=True, null=True, verbose_name=_(u"Collaborators"),
+ related_name='operation_collaborator'
+ )
year = models.IntegerField(_(u"Year"), null=True, blank=True)
operation_code = models.IntegerField(_(u"Numeric reference"), null=True,
blank=True)
@@ -570,8 +574,10 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
@classmethod
def get_query_owns(cls, user):
- return (Q(in_charge=user.ishtaruser.person) |\
- Q(scientist=user.ishtaruser.person) |\
+ return (
+ Q(in_charge=user.ishtaruser.person) |
+ Q(scientist=user.ishtaruser.person) |
+ Q(collaborators__pk=user.ishtaruser.person.pk) |
Q(history_creator=user)) & Q(end_date__isnull=True)
def is_active(self):
@@ -587,14 +593,6 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,
nb = self.parcels.count()
return nb
- def _get_or_set_stats(self, funcname, update):
- key, val = get_cache(self.__class__, [funcname, self.pk])
- if not update and val is not None:
- return val
- val = getattr(self, funcname)()
- cache.set(key, val, settings.CACHE_TIMEOUT)
- return val
-
@property
def nb_acts(self, update=False):
_(u"Number of administrative acts")
@@ -911,6 +909,13 @@ class OperationSource(Source):
return u"{}-{:04d}".format(self.operation.code_patriarche or '',
self.index)
+ @classmethod
+ def get_query_owns(cls, user):
+ return (Q(operation__in_charge=user.ishtaruser.person) |
+ Q(operation__scientist=user.ishtaruser.person) |
+ Q(operation__collaborators__pk=user.ishtaruser.person.pk)) \
+ & Q(operation__end_date__isnull=True)
+
class ActType(GeneralType):
TYPE = (('F', _(u'Archaeological file')),