summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorValérie-Emma Leroux <emma@iggdrasil.net>2017-04-07 11:40:31 +0200
committerValérie-Emma Leroux <emma@iggdrasil.net>2017-04-07 11:40:31 +0200
commit7f22d3c20cc24debfe123425efa63ec5293e4b4c (patch)
treef773b80964981c231c892ee5255b94285bc5620a /archaeological_operations/models.py
parent9127307734c85b816ac7dbb539b565ffb106d60f (diff)
parentda4af2ab5d105f6d2ce442b517e532b7570616e3 (diff)
downloadIshtar-7f22d3c20cc24debfe123425efa63ec5293e4b4c.tar.bz2
Ishtar-7f22d3c20cc24debfe123425efa63ec5293e4b4c.zip
Merge branch 'master' of git.iggdrasil.net:/srv/git/ishtar
Conflicts: archaeological_operations/templates/ishtar/sheet_operation.html
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')),