From 427aad82772de95328ce99b5f8f697fcea796b17 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 1 Sep 2018 03:10:45 -0400 Subject: [PATCH] Add no results help texts for the converter, source, motd and mailer app. Add help text to the document type list view. Tweak the CSS of the no result secondary links. Signed-off-by: Roberto Rosario --- .../templates/appearance/no_results.html | 8 +- mayan/apps/converter/icons.py | 1 + mayan/apps/converter/links.py | 3 +- mayan/apps/documents/icons.py | 1 + mayan/apps/documents/links.py | 10 ++- .../documents/views/document_type_views.py | 19 ++++- mayan/apps/documents/views/document_views.py | 13 +++- mayan/apps/mailer/icons.py | 2 +- mayan/apps/mailer/views.py | 24 ++++-- mayan/apps/motd/icons.py | 1 + mayan/apps/motd/links.py | 6 +- mayan/apps/motd/views.py | 13 ++++ mayan/apps/sources/icons.py | 2 + mayan/apps/sources/links.py | 16 ++-- mayan/apps/sources/views.py | 77 +++++++++++++++---- 15 files changed, 152 insertions(+), 44 deletions(-) diff --git a/mayan/apps/appearance/templates/appearance/no_results.html b/mayan/apps/appearance/templates/appearance/no_results.html index 53bd7668e8..ea13c4ee1c 100644 --- a/mayan/apps/appearance/templates/appearance/no_results.html +++ b/mayan/apps/appearance/templates/appearance/no_results.html @@ -1,5 +1,11 @@ {% load i18n %} + +
{% if no_results_icon %} @@ -26,7 +32,7 @@ {% endif %} {% if no_results_secondary_links %} -
+
{% for link in no_results_secondary_links %} {% with 'btn btn-default btn-sm' as link_classes %} {% include 'navigation/generic_subnavigation.html' %} diff --git a/mayan/apps/converter/icons.py b/mayan/apps/converter/icons.py index 381d35d281..d87a5fc8d6 100644 --- a/mayan/apps/converter/icons.py +++ b/mayan/apps/converter/icons.py @@ -3,3 +3,4 @@ from __future__ import absolute_import, unicode_literals from appearance.classes import Icon icon_transformation = Icon(driver_name='fontawesome', symbol='crop') +icon_transformation_create = Icon(driver_name='fontawesome', symbol='plus') diff --git a/mayan/apps/converter/links.py b/mayan/apps/converter/links.py index 066bb372ac..09bb8ff301 100644 --- a/mayan/apps/converter/links.py +++ b/mayan/apps/converter/links.py @@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _ from navigation import Link -from .icons import icon_transformation +from .icons import icon_transformation, icon_transformation_create from .permissions import ( permission_transformation_create, permission_transformation_delete, permission_transformation_edit, permission_transformation_view @@ -31,6 +31,7 @@ def get_kwargs_factory(variable_name): link_transformation_create = Link( + icon_class = icon_transformation_create, kwargs=get_kwargs_factory('content_object'), permissions=(permission_transformation_create,), text=_('Create new transformation'), view='converter:transformation_create' diff --git a/mayan/apps/documents/icons.py b/mayan/apps/documents/icons.py index c1e41c9039..dd97e91fd3 100644 --- a/mayan/apps/documents/icons.py +++ b/mayan/apps/documents/icons.py @@ -59,6 +59,7 @@ icon_document_page_zoom_out = Icon( icon_document_pages = Icon(driver_name='fontawesome', symbol='copy') icon_document_preview = Icon(driver_name='fontawesome', symbol='eye') icon_document_properties = Icon(driver_name='fontawesome', symbol='info') +icon_document_type_create = Icon(driver_name='fontawesome', symbol='plus') icon_document_type_setup = Icon(driver_name='fontawesome', symbol='file') icon_document_type_filename = Icon( driver_name='fontawesome', symbol='keyboard' diff --git a/mayan/apps/documents/links.py b/mayan/apps/documents/links.py index 31a4d6fdf6..9e7c68b8b1 100644 --- a/mayan/apps/documents/links.py +++ b/mayan/apps/documents/links.py @@ -16,10 +16,11 @@ from .icons import ( icon_document_page_return, icon_document_page_rotate_left, icon_document_page_rotate_right, icon_document_page_zoom_in, icon_document_page_zoom_out, icon_document_pages, icon_document_preview, - icon_document_properties, icon_document_type_setup, - icon_document_type_filename_create, icon_document_version_list, - icon_document_version_return_document, icon_document_version_return_list, - icon_duplicated_document_list, icon_duplicated_document_scan + icon_document_properties, icon_document_type_create, + icon_document_type_filename_create, icon_document_type_setup, + icon_document_version_list, icon_document_version_return_document, + icon_document_version_return_list, icon_duplicated_document_list, + icon_duplicated_document_scan ) from .permissions import ( permission_document_delete, permission_document_download, @@ -313,6 +314,7 @@ link_document_version_revert = Link( # Document type related links link_document_type_create = Link( + icon_class=icon_document_type_create, permissions=(permission_document_type_create,), text=_('Create document type'), view='documents:document_type_create' ) diff --git a/mayan/apps/documents/views/document_type_views.py b/mayan/apps/documents/views/document_type_views.py index 8c2ded9573..806534ca3b 100644 --- a/mayan/apps/documents/views/document_type_views.py +++ b/mayan/apps/documents/views/document_type_views.py @@ -15,9 +15,12 @@ from common.generics import ( from ..forms import DocumentTypeFilenameForm_create from ..icons import ( - icon_document_type_filename, icon_document_type_filename_create + icon_document_type_filename, icon_document_type_filename_create, + icon_document_type_setup +) +from ..links import ( + link_document_type_create, link_document_type_filename_create ) -from ..links import link_document_type_filename_create from ..models import DocumentType, DocumentTypeFilename from ..permissions import ( permission_document_type_create, permission_document_type_delete, @@ -54,6 +57,18 @@ class DocumentTypeListView(SingleObjectListView): def get_extra_context(self): return { 'hide_link': True, + 'no_results_icon': icon_document_type_setup, + 'no_results_main_link': link_document_type_create.resolve( + context=RequestContext(request=self.request) + ), + 'no_results_text': _( + 'Document types are the most basic units of configuration. ' + 'Everything in the system will depend on them. ' + 'Define a document type for each type of physical ' + 'document you intend to upload. Example document types: ' + 'invoice, receipt, manual, prescription, balance sheet.' + ), + 'no_results_title': _('No document types available'), 'title': _('Document types'), } diff --git a/mayan/apps/documents/views/document_views.py b/mayan/apps/documents/views/document_views.py index 884ff11361..eafcf9a771 100644 --- a/mayan/apps/documents/views/document_views.py +++ b/mayan/apps/documents/views/document_views.py @@ -33,9 +33,9 @@ from ..forms import ( DocumentTypeSelectForm, ) from ..icons import ( - icon_document_list_deleted, icon_document_list_favorites, - icon_document_list_recent_access, icon_document_list_recent_added, - icon_duplicated_document_list + icon_document_list, icon_document_list_deleted, + icon_document_list_favorites, icon_document_list_recent_access, + icon_document_list_recent_added, icon_duplicated_document_list ) from ..literals import PAGE_RANGE_RANGE, DEFAULT_ZIP_FILENAME from ..models import ( @@ -73,6 +73,13 @@ class DocumentListView(SingleObjectListView): return { 'hide_links': True, 'list_as_items': True, + 'no_results_icon': icon_document_list, + 'no_results_text': _( + 'This could mean that no documents have been uploaded or ' + 'that your user account has not been granted the view ' + 'permission for any document or document type.' + ), + 'no_results_title': _('No documents available'), 'title': _('All documents'), } diff --git a/mayan/apps/mailer/icons.py b/mayan/apps/mailer/icons.py index 77ab8fd01c..d5c0eee448 100644 --- a/mayan/apps/mailer/icons.py +++ b/mayan/apps/mailer/icons.py @@ -8,6 +8,6 @@ icon_mail_document_submit = Icon( icon_system_mailer_error_log = Icon( driver_name='fontawesome', symbol='envelope' ) -icon_user_mailer_create = Icon(driver_name='fontawesome', symbol='envelope') +icon_user_mailer_create = Icon(driver_name='fontawesome', symbol='plus') icon_user_mailer_list = Icon(driver_name='fontawesome', symbol='envelope') icon_user_mailer_setup = Icon(driver_name='fontawesome', symbol='envelope') diff --git a/mayan/apps/mailer/views.py b/mayan/apps/mailer/views.py index 0d2a5b0749..1df011511a 100644 --- a/mayan/apps/mailer/views.py +++ b/mayan/apps/mailer/views.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals from django.http import Http404, HttpResponseRedirect from django.shortcuts import get_object_or_404 +from django.template import RequestContext from django.urls import reverse, reverse_lazy from django.utils.translation import ungettext, ugettext_lazy as _ @@ -18,7 +19,8 @@ from .forms import ( DocumentMailForm, UserMailerBackendSelectionForm, UserMailerDynamicForm, UserMailerTestForm ) -from .icons import icon_mail_document_submit +from .icons import icon_mail_document_submit, icon_user_mailer_setup +from .links import link_user_mailer_create from .models import LogEntry, UserMailer from .permissions import ( permission_mailing_link, permission_mailing_send_document, @@ -213,13 +215,25 @@ class UserMailerLogEntryListView(SingleObjectListView): class UserMailerListView(SingleObjectListView): - extra_context = { - 'hide_object': True, - 'title': _('Mailing profile'), - } model = UserMailer object_permission = permission_user_mailer_view + def get_extra_context(self): + return { + 'hide_object': True, + 'no_results_icon': icon_user_mailer_setup, + 'no_results_main_link': link_user_mailer_create.resolve( + context=RequestContext(request=self.request) + ), + 'no_results_text': _( + 'Mailing profiles are email configurations. ' + 'Mailing profiles are used to send documents ' + 'via email.' + ), + 'no_results_title': _('No mailing profiles available'), + 'title': _('Mailing profile'), + } + def get_form_schema(self): return {'fields': self.get_backend().fields} diff --git a/mayan/apps/motd/icons.py b/mayan/apps/motd/icons.py index 96683fed50..d2f870a142 100644 --- a/mayan/apps/motd/icons.py +++ b/mayan/apps/motd/icons.py @@ -2,4 +2,5 @@ from __future__ import absolute_import, unicode_literals from appearance.classes import Icon +icon_message_create = Icon(driver_name='fontawesome', symbol='plus') icon_message_list = Icon(driver_name='fontawesome', symbol='bullhorn') diff --git a/mayan/apps/motd/links.py b/mayan/apps/motd/links.py index 1bdfb3e369..511992f120 100644 --- a/mayan/apps/motd/links.py +++ b/mayan/apps/motd/links.py @@ -7,7 +7,7 @@ from django.utils.translation import ugettext_lazy as _ from navigation import Link, get_cascade_condition from permissions import Permission -from .icons import icon_message_list +from .icons import icon_message_create, icon_message_list from .permissions import ( permission_message_create, permission_message_delete, permission_message_edit, permission_message_view @@ -15,8 +15,8 @@ from .permissions import ( link_message_create = Link( - permissions=(permission_message_create,), text=_('Create message'), - view='motd:message_create' + icon_class=icon_message_create, permissions=(permission_message_create,), + text=_('Create message'), view='motd:message_create' ) link_message_delete = Link( args='object.pk', permissions=(permission_message_delete,), diff --git a/mayan/apps/motd/views.py b/mayan/apps/motd/views.py index 324c09455d..35ed3784e1 100644 --- a/mayan/apps/motd/views.py +++ b/mayan/apps/motd/views.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals import logging +from django.template import RequestContext from django.urls import reverse_lazy from django.utils.translation import ugettext_lazy as _ @@ -10,6 +11,8 @@ from common.views import ( SingleObjectListView ) +from .icons import icon_message_list +from .links import link_message_create from .models import Message from .permissions import ( permission_message_create, permission_message_delete, @@ -63,5 +66,15 @@ class MessageListView(SingleObjectListView): def get_extra_context(self): return { 'hide_link': True, + 'no_results_icon': icon_message_list, + 'no_results_main_link': link_message_create.resolve( + context=RequestContext(request=self.request) + ), + 'no_results_text': _( + 'Messages are displayed in the login view. You can use ' + 'messages to convery information about your organzation, ' + 'announcements or usage guidelines for your users.' + ), + 'no_results_title': _('No messages available'), 'title': _('Messages'), } diff --git a/mayan/apps/sources/icons.py b/mayan/apps/sources/icons.py index 709b22e60b..739e6d3ed7 100644 --- a/mayan/apps/sources/icons.py +++ b/mayan/apps/sources/icons.py @@ -5,6 +5,8 @@ from appearance.classes import Icon icon_document_create_multiple = Icon( driver_name='fontawesome', symbol='upload' ) +icon_log = Icon(driver_name='fontawesome', symbol='exclamation-triangle') icon_setup_sources = Icon(driver_name='fontawesome', symbol='upload') +icon_source_create = Icon(driver_name='fontawesome', symbol='plus') icon_upload_view_link = Icon(driver_name='fontawesome', symbol='upload') icon_wizard_submit = Icon(driver_name='fontawesome', symbol='arrow-right') diff --git a/mayan/apps/sources/links.py b/mayan/apps/sources/links.py index 11f1564273..a697a481dd 100644 --- a/mayan/apps/sources/links.py +++ b/mayan/apps/sources/links.py @@ -8,7 +8,9 @@ from documents.permissions import ( ) from navigation import Link -from .icons import icon_document_create_multiple, icon_setup_sources +from .icons import ( + icon_document_create_multiple, icon_setup_sources, icon_source_create +) from .literals import ( SOURCE_CHOICE_WEB_FORM, SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3, SOURCE_CHOICE_SANE_SCANNER, SOURCE_CHOICE_STAGING, SOURCE_CHOICE_WATCH @@ -55,32 +57,32 @@ link_setup_sources = Link( view='sources:setup_source_list' ) link_setup_source_create_imap_email = Link( - args='"%s"' % SOURCE_CHOICE_EMAIL_IMAP, + args='"%s"' % SOURCE_CHOICE_EMAIL_IMAP, icon_class=icon_source_create, permissions=(permission_sources_setup_create,), text=_('Add new IMAP email'), view='sources:setup_source_create', ) link_setup_source_create_pop3_email = Link( - args='"%s"' % SOURCE_CHOICE_EMAIL_POP3, + args='"%s"' % SOURCE_CHOICE_EMAIL_POP3, icon_class=icon_source_create, permissions=(permission_sources_setup_create,), text=_('Add new POP3 email'), view='sources:setup_source_create', ) link_setup_source_create_staging_folder = Link( - args='"%s"' % SOURCE_CHOICE_STAGING, + args='"%s"' % SOURCE_CHOICE_STAGING, icon_class=icon_source_create, permissions=(permission_sources_setup_create,), text=_('Add new staging folder'), view='sources:setup_source_create', ) link_setup_source_create_watch_folder = Link( - args='"%s"' % SOURCE_CHOICE_WATCH, + args='"%s"' % SOURCE_CHOICE_WATCH, icon_class=icon_source_create, permissions=(permission_sources_setup_create,), text=_('Add new watch folder'), view='sources:setup_source_create', ) link_setup_source_create_webform = Link( - args='"%s"' % SOURCE_CHOICE_WEB_FORM, + args='"%s"' % SOURCE_CHOICE_WEB_FORM, icon_class=icon_source_create, permissions=(permission_sources_setup_create,), text=_('Add new webform source'), view='sources:setup_source_create', ) link_setup_source_create_sane_scanner = Link( - args='"%s"' % SOURCE_CHOICE_SANE_SCANNER, + args='"%s"' % SOURCE_CHOICE_SANE_SCANNER, icon_class=icon_source_create, permissions=(permission_sources_setup_create,), text=_('Add new SANE scanner'), view='sources:setup_source_create', ) diff --git a/mayan/apps/sources/views.py b/mayan/apps/sources/views.py index 58bb0a1f55..c927dc5642 100644 --- a/mayan/apps/sources/views.py +++ b/mayan/apps/sources/views.py @@ -5,6 +5,7 @@ import logging from django.contrib import messages from django.http import HttpResponseRedirect, JsonResponse from django.shortcuts import get_object_or_404 +from django.template import RequestContext from django.urls import reverse, reverse_lazy from django.utils.encoding import force_text, uri_to_iri from django.utils.translation import ugettext_lazy as _ @@ -30,8 +31,14 @@ from .exceptions import SourceException from .forms import ( NewDocumentForm, NewVersionForm, WebFormUploadForm, WebFormUploadFormHTML5 ) -from .icons import icon_upload_view_link +from .icons import icon_log, icon_setup_sources, icon_upload_view_link from .literals import SOURCE_UNCOMPRESS_CHOICE_ASK, SOURCE_UNCOMPRESS_CHOICE_Y +from .links import ( + link_setup_source_create_imap_email, link_setup_source_create_pop3_email, + link_setup_source_create_staging_folder, + link_setup_source_create_watch_folder, link_setup_source_create_webform, + link_setup_source_create_sane_scanner +) from .models import ( InteractiveSource, Source, SaneScanner, StagingFolderSource ) @@ -52,6 +59,12 @@ class SourceLogListView(SingleObjectListView): def get_extra_context(self): return { 'hide_object': True, + 'no_results_icon': icon_log, + 'no_results_text': _( + 'Any error produced during the usage of a source will be ' + 'listed here to assist in debugging.' + ), + 'no_results_title': _('No log entries available'), 'object': self.get_source(), 'title': _('Log entries for source: %s') % self.get_source(), } @@ -565,21 +578,51 @@ class SetupSourceEditView(SingleObjectEditView): class SetupSourceListView(SingleObjectListView): - extra_context = { - 'extra_columns': ( - { - 'name': _('Type'), - 'attribute': encapsulate(lambda entry: entry.class_fullname()) - }, - { - 'name': _('Enabled'), - 'attribute': encapsulate( - lambda entry: TwoStateWidget(state=entry.enabled).render() - ) - }, - ), - 'hide_link': True, - 'title': _('Sources'), - } queryset = Source.objects.select_subclasses() view_permission = permission_sources_setup_view + + def get_extra_context(self): + return { + 'extra_columns': ( + { + 'name': _('Type'), + 'attribute': encapsulate(lambda entry: entry.class_fullname()) + }, + { + 'name': _('Enabled'), + 'attribute': encapsulate( + lambda entry: TwoStateWidget(state=entry.enabled).render() + ) + }, + ), + 'hide_link': True, + 'no_results_icon': icon_setup_sources, + 'no_results_secondary_links': [ + link_setup_source_create_webform.resolve( + context=RequestContext(request=self.request) + ), + link_setup_source_create_imap_email.resolve( + context=RequestContext(request=self.request) + ), + link_setup_source_create_pop3_email.resolve( + context=RequestContext(request=self.request) + ), + link_setup_source_create_sane_scanner.resolve( + context=RequestContext(request=self.request) + ), + link_setup_source_create_staging_folder.resolve( + context=RequestContext(request=self.request) + ), + link_setup_source_create_watch_folder.resolve( + context=RequestContext(request=self.request) + ), + ], + 'no_results_text': _( + 'Sources provide the means to upload documents. ' + 'Some sources like the webform, are interactive and require ' + 'user input to operate. Others like the email sources, are ' + 'automatic and run on the background without user intervention.' + ), + 'no_results_title': _('No sources available'), + 'title': _('Sources'), + }