summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-24 10:33:07 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-24 10:33:07 +0200
commitff8681360e589ff3c8e63dcef6ad0d31ac8ecab8 (patch)
treeaff85c928066d444a8639daf6dd1c52d38e6c7dc /ishtar_common/models.py
parentfee9b4904fee90077cdb73ecddc130288ba0ab21 (diff)
downloadIshtar-ff8681360e589ff3c8e63dcef6ad0d31ac8ecab8.tar.bz2
Ishtar-ff8681360e589ff3c8e63dcef6ad0d31ac8ecab8.zip
Allow own locker to edit their locks
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index cb1325af1..f3ef8103c 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1852,7 +1852,9 @@ class DocumentItem(object):
return actions
can_add_doc = self.can_do(request, 'add_document')
- if can_add_doc and not getattr(self, "locked", False):
+ if can_add_doc and (
+ not hasattr(self, "is_locked") or
+ not self.is_locked(request.user)):
actions = [
(
reverse("create-document") + "?{}={}".format(
@@ -2164,6 +2166,11 @@ class BaseHistorizedItem(StatisticItem, TemplateItem, FullSearch, Imported,
def get_verbose_name(cls):
return cls._meta.verbose_name
+ def is_locked(self, user=None):
+ if not user:
+ return self.locked
+ return self.locked and (not self.lock_user or self.lock_user != user)
+
def merge(self, item, keep_old=False):
merge_model_objects(self, item, keep_old=keep_old)