From cd32c5bda564fe4cb012a901922ce728bd2098c9 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 16 Feb 2017 21:46:40 -0400 Subject: [PATCH] Return the corresponing keyword arguments to the view of the document thumbnail widget depending on the view type: template or API. --- mayan/apps/documents/widgets.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mayan/apps/documents/widgets.py b/mayan/apps/documents/widgets.py index ef5900ec41..2bd1b0e7bc 100644 --- a/mayan/apps/documents/widgets.py +++ b/mayan/apps/documents/widgets.py @@ -101,11 +101,21 @@ class InstanceImageWidget(object): # Click view def get_click_view_kwargs(self, instance): - return { - 'pk': instance.document.pk, - 'version_pk': instance.document_version.pk, - 'page_pk': instance.pk - } + """ + Determine if the view is a template or API view and vary the view + keyword arguments + """ + + if self.click_view_name.startswith('rest_api'): + return { + 'pk': instance.document.pk, + 'version_pk': instance.document_version.pk, + 'page_pk': instance.pk + } + else: + return { + 'pk': instance.pk, + } def get_click_view_query_dict(self, instance): return self.click_view_query_dict