summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r--archaeological_warehouse/models.py11
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')