diff --git a/mayan/apps/documents/migrations/0031_convert_uuid.py b/mayan/apps/documents/migrations/0031_convert_uuid.py index 28edb9d746..cbbf04ed1f 100644 --- a/mayan/apps/documents/migrations/0031_convert_uuid.py +++ b/mayan/apps/documents/migrations/0031_convert_uuid.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import uuid -from django.db import migrations, models +from django.db import migrations def convert_uuid_to_hex(apps, schema_editor): diff --git a/mayan/apps/linking/urls.py b/mayan/apps/linking/urls.py index 71d593aca4..c9a1c01a1a 100644 --- a/mayan/apps/linking/urls.py +++ b/mayan/apps/linking/urls.py @@ -11,7 +11,7 @@ from .views import ( ) urlpatterns = patterns( - 'linking.views', + '', url( r'^document/(?P\d+)/list/$', DocumentSmartLinkListView.as_view(), name='smart_link_instances_for_document' diff --git a/mayan/apps/linking/views.py b/mayan/apps/linking/views.py index 89d38c4340..f67a71d0b1 100644 --- a/mayan/apps/linking/views.py +++ b/mayan/apps/linking/views.py @@ -2,13 +2,10 @@ from __future__ import absolute_import, unicode_literals import logging -from django.conf import settings from django.contrib import messages from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse, reverse_lazy -from django.http import HttpResponseRedirect -from django.shortcuts import get_object_or_404, render_to_response -from django.template import RequestContext +from django.shortcuts import get_object_or_404 from django.utils.translation import ugettext_lazy as _ from acls.models import AccessControlList @@ -31,42 +28,6 @@ from .permissions import ( 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.get_object().document_types.add(item) - - 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.get_object().document_types.all() - ) - ) - - def right_list(self): - return AssignRemoveView.generate_choices( - self.get_object().document_types.all() - ) - - def remove(self, item): - self.get_object().document_types.remove(item) - - def get_extra_context(self): - return { - 'object': self.get_object(), - 'title': _( - 'Document type for which to enable smart link: %s' - ) % self.get_object() - } - - class ResolvedSmartLinkView(DocumentListView): def dispatch(self, request, *args, **kwargs): self.document = get_object_or_404( @@ -131,9 +92,51 @@ class ResolvedSmartLinkView(DocumentListView): } +class SetupSmartLinkDocumentTypesView(AssignRemoveView): + decode_content_type = True + left_list_title = _('Available document types') + object_permission = permission_smart_link_edit + right_list_title = _('Document types enabled') + + def add(self, item): + self.get_object().document_types.add(item) + + def get_extra_context(self): + return { + 'object': self.get_object(), + 'title': _( + 'Document type for which to enable smart link: %s' + ) % self.get_object() + } + + 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.get_object().document_types.all() + ) + ) + + def remove(self, item): + self.get_object().document_types.remove(item) + + def right_list(self): + return AssignRemoveView.generate_choices( + self.get_object().document_types.all() + ) + + class SmartLinkListView(SingleObjectListView): object_permission = permission_smart_link_view + def get_extra_context(self): + return { + 'hide_link': True, + 'title': _('Smart links'), + } + def get_queryset(self): self.queryset = self.get_smart_link_queryset() return super(SmartLinkListView, self).get_queryset() @@ -141,12 +144,6 @@ class SmartLinkListView(SingleObjectListView): def get_smart_link_queryset(self): return SmartLink.objects.all() - def get_extra_context(self): - return { - 'hide_link': True, - 'title': _('Smart links'), - } - class DocumentSmartLinkListView(SmartLinkListView): def dispatch(self, request, *args, **kwargs): @@ -165,20 +162,20 @@ class DocumentSmartLinkListView(SmartLinkListView): DocumentSmartLinkListView, self ).dispatch(request, *args, **kwargs) + def get_extra_context(self): + return { + 'document': self.document, + 'hide_link': True, + 'hide_object': True, + 'object': self.document, + 'title': _('Smart links for document: %s') % self.document, + } + def get_smart_link_queryset(self): return ResolvedSmartLink.objects.filter( document_types=self.document.document_type, enabled=True ) - def get_extra_context(self): - return { - 'document': self.document, - 'hide_object': True, - 'hide_link': True, - 'object': self.document, - 'title': _('Smart links for document: %s') % self.document, - } - class SmartLinkCreateView(SingleObjectCreateView): extra_context = {'title': _('Create new smart link')} @@ -224,12 +221,12 @@ class SmartLinkConditionListView(SingleObjectListView): ) % self.get_smart_link(), } - def get_smart_link(self): - return get_object_or_404(SmartLink, pk=self.kwargs['pk']) - def get_queryset(self): return self.get_smart_link().conditions.all() + def get_smart_link(self): + return get_object_or_404(SmartLink, pk=self.kwargs['pk']) + class SmartLinkConditionCreateView(SingleObjectCreateView): form_class = SmartLinkConditionForm @@ -263,15 +260,17 @@ class SmartLinkConditionCreateView(SingleObjectCreateView): def get_post_action_redirect(self): return reverse( - 'linking:smart_link_condition_list', args=(self.get_smart_link().pk,) + 'linking:smart_link_condition_list', args=( + self.get_smart_link().pk, + ) ) - def get_smart_link(self): - return get_object_or_404(SmartLink, pk=self.kwargs['pk']) - def get_queryset(self): return self.get_smart_link().conditions.all() + def get_smart_link(self): + return get_object_or_404(SmartLink, pk=self.kwargs['pk']) + class SmartLinkConditionEditView(SingleObjectEditView): form_class = SmartLinkConditionForm diff --git a/mayan/apps/motd/apps.py b/mayan/apps/motd/apps.py index 42eacb3556..0258d066da 100644 --- a/mayan/apps/motd/apps.py +++ b/mayan/apps/motd/apps.py @@ -2,11 +2,6 @@ from __future__ import unicode_literals import logging -from django import apps -from django.conf import settings -from django.conf.urls import include, url -from django.contrib.auth.signals import user_logged_in -from django.db.models.signals import post_save from django.utils.translation import ugettext_lazy as _ from common import MayanAppConfig, menu_object, menu_secondary, menu_setup diff --git a/mayan/apps/motd/links.py b/mayan/apps/motd/links.py index 01e627316e..8b454857af 100644 --- a/mayan/apps/motd/links.py +++ b/mayan/apps/motd/links.py @@ -5,8 +5,8 @@ from django.utils.translation import ugettext_lazy as _ from navigation import Link from .permissions import ( - permission_message_create, permission_message_delete, permission_message_edit, - permission_message_view + permission_message_create, permission_message_delete, + permission_message_edit, ) link_message_create = Link( diff --git a/mayan/apps/motd/migrations/0004_auto_20160314_0040.py b/mayan/apps/motd/migrations/0004_auto_20160314_0040.py index c108711878..ac9158c471 100644 --- a/mayan/apps/motd/migrations/0004_auto_20160314_0040.py +++ b/mayan/apps/motd/migrations/0004_auto_20160314_0040.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations class Migration(migrations.Migration): @@ -17,6 +17,9 @@ class Migration(migrations.Migration): ), migrations.AlterModelOptions( name='message', - options={'verbose_name': 'Message', 'verbose_name_plural': 'Messages'}, + options={ + 'verbose_name': 'Message', + 'verbose_name_plural': 'Messages' + }, ), ] diff --git a/mayan/apps/motd/models.py b/mayan/apps/motd/models.py index e240da0b64..a907e1af6d 100644 --- a/mayan/apps/motd/models.py +++ b/mayan/apps/motd/models.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -from django.conf import settings from django.db import models from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ diff --git a/mayan/apps/motd/tests/test_models.py b/mayan/apps/motd/tests/test_models.py index 7a1df0acb8..bb250982fa 100644 --- a/mayan/apps/motd/tests/test_models.py +++ b/mayan/apps/motd/tests/test_models.py @@ -40,7 +40,7 @@ class MOTDTestCase(TestCase): self.assertEqual(queryset.exists(), False) def test_enable(self): - self.motd.enabled=False + self.motd.enabled = False self.motd.save() queryset = Message.objects.get_for_now() diff --git a/mayan/apps/motd/views.py b/mayan/apps/motd/views.py index f8a883874d..c7af38a035 100644 --- a/mayan/apps/motd/views.py +++ b/mayan/apps/motd/views.py @@ -2,14 +2,8 @@ from __future__ import absolute_import, unicode_literals import logging -from django.conf import settings -from django.contrib import messages -from django.core.exceptions import PermissionDenied -from django.core.urlresolvers import reverse, reverse_lazy -from django.http import HttpResponseRedirect -from django.shortcuts import get_object_or_404, render_to_response -from django.template import RequestContext -from django.utils.translation import ugettext_lazy as _, ungettext +from django.core.urlresolvers import reverse_lazy +from django.utils.translation import ugettext_lazy as _ from common.views import ( SingleObjectCreateView, SingleObjectDeleteView, SingleObjectEditView, @@ -19,7 +13,7 @@ from common.views import ( from .models import Message from .permissions import ( permission_message_create, permission_message_delete, - permission_message_edit, permission_message_view, + permission_message_edit, permission_message_view ) logger = logging.getLogger(__name__) diff --git a/mayan/apps/ocr/views.py b/mayan/apps/ocr/views.py index a11ee69ad4..0fd2709fbb 100644 --- a/mayan/apps/ocr/views.py +++ b/mayan/apps/ocr/views.py @@ -4,8 +4,7 @@ from django.contrib import messages from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect -from django.shortcuts import get_object_or_404, render_to_response -from django.template import RequestContext +from django.shortcuts import get_object_or_404 from django.utils.translation import ugettext_lazy as _ from acls.models import AccessControlList diff --git a/mayan/apps/sources/forms.py b/mayan/apps/sources/forms.py index 389da8bbf2..5a6848511c 100644 --- a/mayan/apps/sources/forms.py +++ b/mayan/apps/sources/forms.py @@ -78,6 +78,7 @@ class WebFormUploadFormHTML5(WebFormUploadForm): ) ) + class WebFormSetupForm(forms.ModelForm): class Meta: fields = ('label', 'enabled', 'uncompress') diff --git a/mayan/apps/sources/views.py b/mayan/apps/sources/views.py index 47dbea93c6..a0d02acefa 100644 --- a/mayan/apps/sources/views.py +++ b/mayan/apps/sources/views.py @@ -7,7 +7,6 @@ from django.core.urlresolvers import reverse, reverse_lazy from django.http import HttpResponseRedirect from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext -from django.utils.http import urlencode from django.utils.translation import ugettext_lazy as _ from acls.models import AccessControlList diff --git a/mayan/apps/tags/serializers.py b/mayan/apps/tags/serializers.py index 633169c685..3f49cf2e42 100644 --- a/mayan/apps/tags/serializers.py +++ b/mayan/apps/tags/serializers.py @@ -33,7 +33,6 @@ class TagSerializer(serializers.HyperlinkedModelSerializer): return instance.documents.count() - class NewTagSerializer(serializers.ModelSerializer): class Meta: fields = (