diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-28 13:17:29 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-29 18:25:09 +0200 |
commit | 02136acb286d0f6b97dcbc715138f085d59767ea (patch) | |
tree | 72aaceee89f2fe1e30602314d2871bb433fd5a15 /archaeological_warehouse/models.py | |
parent | 1e99edb16662266251fae93750e315d8b56593b3 (diff) | |
download | Ishtar-02136acb286d0f6b97dcbc715138f085d59767ea.tar.bz2 Ishtar-02136acb286d0f6b97dcbc715138f085d59767ea.zip |
Access control: fix get owns query for UEs, finds, warehouses and containers
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r-- | archaeological_warehouse/models.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index d1918f46a..fe054a37b 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -21,6 +21,7 @@ import datetime from django.conf import settings from django.contrib.gis.db import models +from django.db.models import Q from django.db.models.signals import post_save, post_delete from django.template.defaultfilters import slugify from django.utils.translation import ugettext_lazy as _, ugettext @@ -78,6 +79,10 @@ class Warehouse(Address, OwnPerms): return datetime.date.today().strftime('%Y-%m-%d') + '-' + \ slugify(unicode(self)) + @classmethod + def get_query_owns(cls, user): + return Q(person_in_charge__ishtaruser=user.ishtaruser) + def save(self, *args, **kwargs): super(Warehouse, self).save(*args, **kwargs) for container in self.containers.all(): @@ -208,6 +213,12 @@ class Container(LightHistorizedItem, ImageModel): cached_label = u" - ".join(items) return cached_label + @classmethod + def get_query_owns(cls, user): + return Q(history_creator=user) | \ + Q(location__person_in_charge__ishtaruser=user.ishtaruser) | \ + Q(responsible__person_in_charge__ishtaruser=user.ishtaruser) + @property def associated_filename(self): filename = datetime.date.today().strftime('%Y-%m-%d') |