From ff5a0d32d49dd4dfd06044de09f6479403064975 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 21 Sep 2018 02:01:58 -0400 Subject: [PATCH] Only show smart link resolution errors to the user with the smart link edit permission. Signed-off-by: Roberto Rosario --- HISTORY.rst | 1 + mayan/apps/linking/views.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index d485d9186f..345a47490d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,6 +11,7 @@ * Add support for natural keys to the DocumentPageImageCache model. * Add database conversion test to the common app. * Fix label display for resolved smart links when not using a dynamic label. +* Only show smart link resolution errors to the user with the smart link edit permission. 3.1.1 (2018-09-18) ================== diff --git a/mayan/apps/linking/views.py b/mayan/apps/linking/views.py index 11bf4feb73..c68f00bf76 100644 --- a/mayan/apps/linking/views.py +++ b/mayan/apps/linking/views.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals import logging from django.contrib import messages +from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from django.template import RequestContext from django.urls import reverse, reverse_lazy @@ -58,7 +59,14 @@ class ResolvedSmartLinkView(DocumentListView): except Exception as exception: queryset = Document.objects.none() - if self.request.user.is_staff or self.request.user.is_superuser: + try: + AccessControlList.objects.check_access( + permissions=permission_smart_link_edit, user=request.user, + obj=self.smart_link + ) + except PermissionDenied: + pass + else: messages.error( self.request, _('Smart link query error: %s' % exception) )