Reorganize the way the document print view checks for permission to move permission checking to the dispatch method.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -718,6 +718,14 @@ class DocumentPrint(FormView):
|
|||||||
form_class = DocumentPrintForm
|
form_class = DocumentPrintForm
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
instance = self.get_object()
|
||||||
|
AccessControlList.objects.check_access(
|
||||||
|
permissions=permission_document_print, user=self.request.user,
|
||||||
|
obj=instance
|
||||||
|
)
|
||||||
|
|
||||||
|
instance.add_as_recent_document_for_user(self.request.user)
|
||||||
|
|
||||||
self.page_group = self.request.GET.get('page_group')
|
self.page_group = self.request.GET.get('page_group')
|
||||||
self.page_range = self.request.GET.get('page_range')
|
self.page_range = self.request.GET.get('page_range')
|
||||||
return super(DocumentPrint, self).dispatch(request, *args, **kwargs)
|
return super(DocumentPrint, self).dispatch(request, *args, **kwargs)
|
||||||
@@ -767,16 +775,7 @@ class DocumentPrint(FormView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
instance = get_object_or_404(Document, pk=self.kwargs['pk'])
|
return get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||||
|
|
||||||
AccessControlList.objects.check_access(
|
|
||||||
permissions=permission_document_print, user=self.request.user,
|
|
||||||
obj=instance
|
|
||||||
)
|
|
||||||
|
|
||||||
instance.add_as_recent_document_for_user(self.request.user)
|
|
||||||
|
|
||||||
return instance
|
|
||||||
|
|
||||||
def get_template_names(self):
|
def get_template_names(self):
|
||||||
if self.page_group or self.page_range:
|
if self.page_group or self.page_range:
|
||||||
|
|||||||
Reference in New Issue
Block a user