From 41531364d2dbd63e8ea693c918c69e4a985c30ae Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 31 Mar 2015 04:10:15 -0400 Subject: [PATCH] Add getting started self guided help system for missing user setup --- .../appearance/templates/appearance/home.html | 22 ++++++++++++++++++- mayan/apps/documents/apps.py | 4 +++- mayan/apps/main/__init__.py | 2 +- mayan/apps/main/classes.py | 16 ++++++++++++++ mayan/apps/main/views.py | 3 ++- mayan/apps/sources/apps.py | 4 +++- mayan/settings/base.py | 3 ++- 7 files changed, 48 insertions(+), 6 deletions(-) diff --git a/mayan/apps/appearance/templates/appearance/home.html b/mayan/apps/appearance/templates/appearance/home.html index 38e3c6650c..b25a73fbd0 100644 --- a/mayan/apps/appearance/templates/appearance/home.html +++ b/mayan/apps/appearance/templates/appearance/home.html @@ -15,6 +15,26 @@
+ {% if missing_list %} +
+
+

{% trans 'Getting started' %}

+
+
+ {% trans 'Before you can fully use Mayan EDMS you need the following:' %} + +
+ {% for missing in missing_list %} + +

{{ missing.label }}

+

{{ missing.description }}

+
+ {% endfor %} +
+
+
+ {% endif %} +
{% with 'navigation/large_button_link.html' as link_template %} @@ -34,7 +54,7 @@ - {% trans 'Advanced search' %} + {% trans 'Advanced' %}
diff --git a/mayan/apps/documents/apps.py b/mayan/apps/documents/apps.py index 84a4e622a5..08ddc52222 100644 --- a/mayan/apps/documents/apps.py +++ b/mayan/apps/documents/apps.py @@ -12,7 +12,7 @@ from common.classes import ModelAttribute from common.utils import encapsulate, validate_path from dynamic_search.classes import SearchModel from events.permissions import PERMISSION_EVENTS_VIEW -from main import FrontPageButton +from main import FrontPageButton, MissingItem from main.api import register_maintenance_links from navigation.api import register_links, register_model_list_columns from navigation.links import link_spacer @@ -149,3 +149,5 @@ class DocumentsApp(apps.AppConfig): registry.register(Document) DocumentPage.add_to_class('get_transformation_list', lambda document_page: DocumentPageTransformation.objects.get_for_document_page_as_list(document_page)) + + MissingItem(label=_('Create a document type'), description=_('Every uploaded document must be assigned a document type, it is the basic way Mayan EDMS categorizes documents.'), condition=lambda: not DocumentType.objects.exists(), view='documents:document_type_list') diff --git a/mayan/apps/main/__init__.py b/mayan/apps/main/__init__.py index 212da1b862..4be245e2f4 100644 --- a/mayan/apps/main/__init__.py +++ b/mayan/apps/main/__init__.py @@ -1 +1 @@ -from .classes import FrontPageButton # NOQA +from .classes import FrontPageButton, MissingItem # NOQA diff --git a/mayan/apps/main/classes.py b/mayan/apps/main/classes.py index 63e788b596..6178dff7b2 100644 --- a/mayan/apps/main/classes.py +++ b/mayan/apps/main/classes.py @@ -8,3 +8,19 @@ class FrontPageButton(object): def __init__(self, link): self.link = link self.__class__._registry.append(link) + + +class MissingItem(object): + _registry = [] + + @classmethod + def get_all(cls): + return cls._registry + + def __init__(self, label, condition, description, view): + self.label = label + self.condition = condition + self.description = description + self.view = view + self.__class__._registry.append(self) + diff --git a/mayan/apps/main/views.py b/mayan/apps/main/views.py index 83fda4df8d..4201677a49 100644 --- a/mayan/apps/main/views.py +++ b/mayan/apps/main/views.py @@ -9,7 +9,7 @@ from dynamic_search.classes import SearchModel from permissions.models import Permission from .api import diagnostics, tools -from .classes import FrontPageButton +from .classes import FrontPageButton, MissingItem def home(request): @@ -20,6 +20,7 @@ def home(request): 'query_string': request.GET, 'hide_links': True, 'search_results_limit': 100, + 'missing_list': [item for item in MissingItem.get_all() if item.condition()], } if request.GET: diff --git a/mayan/apps/sources/apps.py b/mayan/apps/sources/apps.py index f1d52c0c41..63ffa559a0 100644 --- a/mayan/apps/sources/apps.py +++ b/mayan/apps/sources/apps.py @@ -6,7 +6,7 @@ from django.utils.translation import ugettext_lazy as _ from common.utils import encapsulate from documents.links import document_list_recent, document_list from documents.models import Document -from main import FrontPageButton +from main import FrontPageButton, MissingItem from navigation.api import register_links, register_model_list_columns from project_setup.api import register_setup from rest_api.classes import APIEndPoint @@ -50,3 +50,5 @@ class SourcesApp(apps.AppConfig): APIEndPoint('sources') FrontPageButton(link=document_create_multiple) + + MissingItem(label=_('Create a document source'), description=_('Document sources are the way in which new documents are feed to Mayan EDMS, create at least a web form source to be able to upload documents from a browser.'), condition=lambda: not Source.objects.exists(), view='sources:setup_source_list') diff --git a/mayan/settings/base.py b/mayan/settings/base.py index 2a02c72855..040d357cae 100644 --- a/mayan/settings/base.py +++ b/mayan/settings/base.py @@ -37,6 +37,8 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( + # Placed at the top so it can override any template + 'appearance.apps.AppearanceApp', # 3rd party 'suit', # Django @@ -75,7 +77,6 @@ INSTALLED_APPS = ( 'smart_settings.apps.SmartSettingsApp', 'user_management.apps.UserManagementApp', # Mayan EDMS - 'appearance.apps.AppearanceApp', 'checkouts.apps.CheckoutsApp', 'document_acls.apps.DocumentACLsApp', 'document_comments.apps.DocumentCommentsApp',