From 70b09963549e3d7865b972b7bc29984c94ec085f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 2 Jul 2015 00:57:08 -0400 Subject: [PATCH] Fix smart link document type assign remove view --- mayan/apps/linking/urls.py | 2 +- mayan/apps/linking/views.py | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/mayan/apps/linking/urls.py b/mayan/apps/linking/urls.py index e76e518e23..f75a16300a 100644 --- a/mayan/apps/linking/urls.py +++ b/mayan/apps/linking/urls.py @@ -13,7 +13,7 @@ urlpatterns = patterns( url(r'^setup/create/$', 'smart_link_create', name='smart_link_create'), url(r'^setup/(?P\d+)/delete/$', 'smart_link_delete', name='smart_link_delete'), url(r'^setup/(?P\d+)/edit/$', 'smart_link_edit', name='smart_link_edit'), - url(r'^setup/(?P\d+)/document_types/$', SetupSmartLinkDocumentTypesView.as_view(), name='smart_link_document_types'), + url(r'^setup/(?P\d+)/document_types/$', SetupSmartLinkDocumentTypesView.as_view(), name='smart_link_document_types'), url(r'^setup/(?P\d+)/condition/list/$', 'smart_link_condition_list', name='smart_link_condition_list'), url(r'^setup/(?P\d+)/condition/create/$', 'smart_link_condition_create', name='smart_link_condition_create'), diff --git a/mayan/apps/linking/views.py b/mayan/apps/linking/views.py index 21dfea35c2..bba3756d28 100644 --- a/mayan/apps/linking/views.py +++ b/mayan/apps/linking/views.py @@ -32,34 +32,30 @@ logger = logging.getLogger(__name__) class SetupSmartLinkDocumentTypesView(AssignRemoveView): decode_content_type = True + left_list_title = _('Available document types') + right_list_title = _('Document types enabled') + object_permission = permission_smart_link_edit def add(self, item): - self.smart_link.document_types.add(item) + self.get_object().document_types.add(item) - def dispatch(self, request, *args, **kwargs): - self.smart_link = get_object_or_404(SmartLink, pk=self.kwargs['smart_link_pk']) - - try: - Permission.check_permissions(self.request.user, [permission_smart_link_edit]) - except PermissionDenied: - AccessControlList.objects.check_access(permission_smart_link_edit, self.request.user, self.smart_link) - - return super(SetupSmartLinkDocumentTypesView, self).dispatch(request, *args, **kwargs) + def get_object(self): + return get_object_or_404(SmartLink, pk=self.kwargs['pk']) def left_list(self): - return AssignRemoveView.generate_choices(DocumentType.objects.exclude(pk__in=self.smart_link.document_types.all())) + return AssignRemoveView.generate_choices(DocumentType.objects.exclude(pk__in=self.get_object().document_types.all())) def right_list(self): - return AssignRemoveView.generate_choices(self.smart_link.document_types.all()) + return AssignRemoveView.generate_choices(self.get_object().document_types.all()) def remove(self, item): - self.smart_link.document_types.remove(item) + self.get_object().document_types.remove(item) def get_context_data(self, **kwargs): data = super(SetupSmartLinkDocumentTypesView, self).get_context_data(**kwargs) data.update({ - 'main_title': _('Document type for which to enable smart link: %s') % self.smart_link, - 'object': self.smart_link, + 'object': self.get_object(), + 'title': _('Document type for which to enable smart link: %s') % self.get_object(), }) return data