diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-10-18 11:50:20 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-10-24 12:06:09 +0200 |
commit | 49be6089b2354a71372dfaf71612de08d67986ff (patch) | |
tree | a3289c874c9bc0ebe0a7d2674ad770aa75e75c6d | |
parent | 693d7cb53d4b4f13699c4b07dd1bb8a9d513130d (diff) | |
download | Ishtar-49be6089b2354a71372dfaf71612de08d67986ff.tar.bz2 Ishtar-49be6089b2354a71372dfaf71612de08d67986ff.zip |
Fix access to sheet and permission check for owns
-rw-r--r-- | ishtar_common/backend.py | 7 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/ishtar_common/backend.py b/ishtar_common/backend.py index 261e4dc6f..d5e092fa5 100644 --- a/ishtar_common/backend.py +++ b/ishtar_common/backend.py @@ -55,10 +55,9 @@ class ObjectPermBackend(ModelBackend): if obj is None: model_name = perm.split('_')[-1].lower() model = None - for app in apps.get_apps(): - for modl in apps.get_models(app): - if modl.__name__.lower() == model_name: - model = modl + for modl in apps.get_models(): + if modl.__name__.lower() == model_name: + model = modl if not model: return False return not is_ownperm or model.has_item_of(ishtar_user) diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index d068fb554..5cd3eb826 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -135,7 +135,7 @@ def show_item(model, name, extra_dct=None): return HttpResponse('NOK') query_own = model.get_query_owns(request.user.ishtaruser) if query_own: - q = q.filter(query_own) + q = q.filter(query_own).distinct() try: item = q.get(pk=pk) except ObjectDoesNotExist: |