diff options
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 21 | 
1 files changed, 15 insertions, 6 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 919b1ba15..872d2bf4e 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -228,6 +228,10 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,      )      locality_cadastral = models.TextField(_(u"Cadastral locality"),                                            null=True, blank=True) +    collaborators = models.ManyToManyField( +        Person, blank=True, verbose_name=_(u"Collaborators"), +        related_name='site_collaborator' +    )      # underwater      shipwreck_name = models.TextField(          _(u"Shipwreck name"), null=True, blank=True) @@ -294,12 +298,13 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,          ) | cls._construct_query_own(              'top_operation__context_record__base_finds__find__container__location__',              Warehouse._get_query_owns_dicts(ishtaruser) -        ) |  cls._construct_query_own( -            'operations__', Operation._get_query_owns_dicts(ishtaruser) +        ) | cls._construct_query_own( +            'operations__', Operation._get_query_owns_dicts(ishtaruser, +                                                            no_rel=True)          ) | cls._construct_query_own(              'top_operation__', Operation._get_query_owns_dicts(ishtaruser)          ) | cls._construct_query_own('', [ -            {'history_creator': ishtaruser.user_ptr}, +            {'history_creator': ishtaruser.user_ptr}          ])          return q @@ -1093,24 +1098,28 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,          return round(float(self.cost) / self.surface, 2)      @classmethod -    def _get_query_owns_dicts(cls, ishtaruser): +    def _get_query_owns_dicts(cls, ishtaruser, no_rel=False):          profile = ishtaruser.current_profile          town_ids = []          if profile:              town_ids = [town['pk']                          for town in profile.query_towns.values('pk').all()] -        return [ +        query_owns = [              {                  'in_charge': ishtaruser.person,                  'scientist': ishtaruser.person,                  'collaborators__pk': ishtaruser.person.pk,                  'history_creator': ishtaruser.user_ptr, -                'towns__pk__in': town_ids +                'towns__pk__in': town_ids,              },              {                  'end_date__isnull': True              }          ] +        if not no_rel: +            query_owns[0]['archaeological_sites__collaborators__pk'] = \ +                ishtaruser.person.pk +        return query_owns      @classmethod      def get_query_owns(cls, ishtaruser):  | 
