From ad5709c8cefb997dd2f9233134a0cfa531cb7cdd Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 2 Jul 2015 02:47:46 -0400 Subject: [PATCH] Remove maintenance tools menu entry, apps now register tools directly to the tools menu. --- mayan/apps/common/api.py | 11 -------- mayan/apps/common/apps.py | 4 +-- mayan/apps/common/links.py | 1 - mayan/apps/common/urls.py | 3 +- mayan/apps/common/views.py | 40 ++++++--------------------- mayan/apps/document_indexing/apps.py | 6 ++-- mayan/apps/document_indexing/links.py | 1 + mayan/apps/document_indexing/urls.py | 4 ++- mayan/apps/document_indexing/views.py | 3 +- mayan/apps/documents/apps.py | 6 ++-- mayan/apps/documents/links.py | 5 +++- 11 files changed, 23 insertions(+), 61 deletions(-) delete mode 100644 mayan/apps/common/api.py diff --git a/mayan/apps/common/api.py b/mayan/apps/common/api.py deleted file mode 100644 index 29dd3616fa..0000000000 --- a/mayan/apps/common/api.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import unicode_literals - -tools = {} - - -def register_maintenance_links(links, title=None, namespace=None): - namespace_dict = tools.get(namespace, {'title': None, 'links': []}) - namespace_dict['title'] = title - for link in links: - namespace_dict['links'].append(link) - tools[namespace] = namespace_dict diff --git a/mayan/apps/common/apps.py b/mayan/apps/common/apps.py index 631810f9c3..7aa53fc9dd 100644 --- a/mayan/apps/common/apps.py +++ b/mayan/apps/common/apps.py @@ -15,8 +15,7 @@ from .handlers import ( from .links import ( link_about, link_current_user_details, link_current_user_edit, link_current_user_locale_profile_details, - link_current_user_locale_profile_edit, link_license, - link_maintenance_menu, link_setup, link_tools + link_current_user_locale_profile_edit, link_license, link_setup, link_tools ) from .menus import ( menu_facet, menu_main, menu_secondary, menu_setup, menu_tools @@ -62,7 +61,6 @@ class CommonApp(MayanAppConfig): ], sources=['common:current_user_details', 'common:current_user_edit', 'common:current_user_locale_profile_details', 'common:current_user_locale_profile_edit', 'authentication:password_change_view', 'common:setup_list', 'common:tools_list'] ) - menu_tools.bind_links(links=[link_maintenance_menu]) user_logged_in.connect(user_locale_profile_session_config, dispatch_uid='user_locale_profile_session_config', sender=settings.AUTH_USER_MODEL) post_save.connect(user_locale_profile_create, dispatch_uid='user_locale_profile_create', sender=settings.AUTH_USER_MODEL) diff --git a/mayan/apps/common/links.py b/mayan/apps/common/links.py index 5aa2596a57..eb171d2268 100644 --- a/mayan/apps/common/links.py +++ b/mayan/apps/common/links.py @@ -15,6 +15,5 @@ link_current_user_edit = Link(icon='fa fa-user', text=_('Edit details'), view='c link_current_user_locale_profile_details = Link(icon='fa fa-globe', text=_('Locale profile'), view='common:current_user_locale_profile_details') link_current_user_locale_profile_edit = Link(icon='fa fa-globe', text=_('Edit locale profile'), view='common:current_user_locale_profile_edit') link_license = Link(icon='fa fa-book', text=_('License'), view='common:license_view') -link_maintenance_menu = Link(icon='fa fa-wrench', text=_('Maintenance'), view='common:maintenance_menu') link_setup = Link(icon='fa fa-gear', text=_('Setup'), view='common:setup_list') link_tools = Link(icon='fa fa-wrench', text=_('Tools'), view='common:tools_list') diff --git a/mayan/apps/common/urls.py b/mayan/apps/common/urls.py index 92f5146198..ae9a2f2abd 100644 --- a/mayan/apps/common/urls.py +++ b/mayan/apps/common/urls.py @@ -6,7 +6,7 @@ from django.views.generic import RedirectView from .views import ( AboutView, CurrentUserDetailsView, CurrentUserLocaleProfileDetailsView, - HomeView, LicenseView, MaintenanceMenuView, SetupListView, ToolsListView + HomeView, LicenseView, SetupListView, ToolsListView ) urlpatterns = patterns( @@ -14,7 +14,6 @@ urlpatterns = patterns( url(r'^$', HomeView.as_view(), name='home'), url(r'^about/$', AboutView.as_view(), name='about_view'), url(r'^license/$', LicenseView.as_view(), name='license_view'), - url(r'^maintenance_menu/$', MaintenanceMenuView.as_view(), name='maintenance_menu'), url(r'^object/multiple/action/$', 'multi_object_action_view', name='multi_object_action_view'), url(r'^setup/$', SetupListView.as_view(), name='setup_list'), url(r'^tools/$', ToolsListView.as_view(), name='tools_list'), diff --git a/mayan/apps/common/views.py b/mayan/apps/common/views.py index b071eac84d..ad21935fe8 100644 --- a/mayan/apps/common/views.py +++ b/mayan/apps/common/views.py @@ -20,7 +20,6 @@ from django.views.generic.list import ListView from documents.search import document_search -from .api import tools from .classes import MissingItem from .forms import ( ChoiceForm, LicenseForm, LocaleProfileForm, LocaleProfileForm_view, @@ -219,30 +218,6 @@ class LicenseView(ExtraContextMixin, TemplateView): template_name = 'appearance/generic_form.html' -class MaintenanceMenuView(TemplateView): - template_name = 'appearance/tools.html' - - def get_context_data(self, **kwargs): - data = super(MaintenanceMenuView, self).get_context_data(**kwargs) - - user_tools = {} - for namespace, values in tools.items(): - user_tools[namespace] = { - 'title': values['title'] - } - user_tools[namespace].setdefault('links', []) - for link in values['links']: - resolved_link = link.resolve(context=RequestContext(self.request)) - if resolved_link: - user_tools[namespace]['links'].append(resolved_link) - - data.update({ - 'blocks': user_tools, - 'title': _('Maintenance menu') - }) - return data - - class MultiFormView(FormView): prefixes = {} @@ -486,16 +461,17 @@ class SimpleView(ViewPermissionCheckMixin, ExtraContextMixin, TemplateView): pass -class ToolsListView(TemplateView): +class ToolsListView(SimpleView): template_name = 'appearance/generic_list_horizontal.html' - def get_context_data(self, **kwargs): - data = super(ToolsListView, self).get_context_data(**kwargs) - data.update({ - 'resolved_links': menu_tools.resolve(context=RequestContext(self.request)), + def get_menu_links(self): + return menu_tools.resolve(context=RequestContext(self.request)) + + def get_extra_context(self): + return { + 'resolved_links': self.get_menu_links(), 'title': _('Tools'), - }) - return data + } def multi_object_action_view(request): diff --git a/mayan/apps/document_indexing/apps.py b/mayan/apps/document_indexing/apps.py index 522f37d741..549e6a6a50 100644 --- a/mayan/apps/document_indexing/apps.py +++ b/mayan/apps/document_indexing/apps.py @@ -5,9 +5,8 @@ from django.utils.translation import ugettext_lazy as _ from common import ( MayanAppConfig, menu_facet, menu_main, menu_object, menu_secondary, - menu_setup + menu_setup, menu_tools ) -from common.api import register_maintenance_links from documents.models import Document from metadata.models import DocumentMetadata from rest_api.classes import APIEndPoint @@ -44,9 +43,8 @@ class DocumentIndexingApp(MayanAppConfig): menu_main.bind_links(links=[link_index_main_menu]) menu_secondary.bind_links(links=[link_index_setup_list, link_index_setup_create], sources=[Index, 'indexing:index_setup_list', 'indexing:index_setup_create']) menu_setup.bind_links(links=[link_index_setup]) + menu_tools.bind_links(links=[link_rebuild_index_instances]) post_save.connect(document_metadata_index_update, dispatch_uid='document_metadata_index_update', sender=DocumentMetadata) post_delete.connect(document_index_delete, dispatch_uid='document_index_delete', sender=Document) post_delete.connect(document_metadata_index_post_delete, dispatch_uid='document_metadata_index_post_delete', sender=DocumentMetadata) - - register_maintenance_links([link_rebuild_index_instances], namespace='document_indexing', title=_('Indexes')) diff --git a/mayan/apps/document_indexing/links.py b/mayan/apps/document_indexing/links.py index 04259e7658..f043017542 100644 --- a/mayan/apps/document_indexing/links.py +++ b/mayan/apps/document_indexing/links.py @@ -28,6 +28,7 @@ link_index_setup_delete = Link(permissions=[permission_document_indexing_delete] link_index_setup_view = Link(permissions=[permission_document_indexing_setup], text=_('Tree template'), view='indexing:index_setup_view', args='resolved_object.pk') link_index_setup_document_types = Link(permissions=[permission_document_indexing_edit], text=_('Document types'), view='indexing:index_setup_document_types', args='resolved_object.pk') link_rebuild_index_instances = Link( + icon='fa fa-database', description=_('Deletes and creates from scratch all the document indexes.'), permissions=[permission_document_indexing_rebuild_indexes], text=_('Rebuild indexes'), view='indexing:rebuild_index_instances' diff --git a/mayan/apps/document_indexing/urls.py b/mayan/apps/document_indexing/urls.py index cb3bdbae75..25592ba0f9 100644 --- a/mayan/apps/document_indexing/urls.py +++ b/mayan/apps/document_indexing/urls.py @@ -7,7 +7,9 @@ from .api_views import ( APIIndexNodeInstanceDocumentListView, APIIndexTemplateListView, APIIndexTemplateView, APIIndexView ) -from .views import IndexListView, SetupIndexDocumentTypesView, SetupIndexListView +from .views import ( + IndexListView, SetupIndexDocumentTypesView, SetupIndexListView, +) urlpatterns = patterns( diff --git a/mayan/apps/document_indexing/views.py b/mayan/apps/document_indexing/views.py index b5a4da32b9..4cb130d0fd 100644 --- a/mayan/apps/document_indexing/views.py +++ b/mayan/apps/document_indexing/views.py @@ -30,9 +30,8 @@ from .permissions import ( from .tasks import task_do_rebuild_all_indexes from .widgets import index_instance_item_link, get_breadcrumbs, node_level + # Setup views - - class SetupIndexListView(SingleObjectListView): model = Index view_permission = permission_document_indexing_setup diff --git a/mayan/apps/documents/apps.py b/mayan/apps/documents/apps.py index 5644558815..43648058ce 100644 --- a/mayan/apps/documents/apps.py +++ b/mayan/apps/documents/apps.py @@ -9,9 +9,8 @@ from acls.links import link_acl_list from acls.permissions import permission_acl_edit, permission_acl_view from common import ( MayanAppConfig, MissingItem, menu_facet, menu_front_page, menu_object, - menu_secondary, menu_setup, menu_sidebar, menu_multi_item + menu_secondary, menu_setup, menu_sidebar, menu_multi_item, menu_tools ) -from common.api import register_maintenance_links from common.classes import ModelAttribute from common.signals import post_initial_setup from common.utils import encapsulate @@ -93,6 +92,7 @@ class DocumentsApp(MayanAppConfig): menu_front_page.bind_links(links=[link_document_list_recent, link_document_list]) menu_setup.bind_links(links=[link_document_type_setup]) + menu_tools.bind_links(links=[link_clear_image_cache]) # Document type links menu_object.bind_links(links=[link_document_type_edit, link_document_type_filename_list, link_document_type_delete], sources=[DocumentType]) @@ -128,7 +128,5 @@ class DocumentsApp(MayanAppConfig): registry.register(Document) - register_maintenance_links([link_clear_image_cache], namespace='documents', title=_('Documents')) - SourceColumn(source=Document, label=_('Thumbnail'), attribute=encapsulate(lambda document: document_thumbnail(document, gallery_name='documents:document_list', title=getattr(document, 'label', None), size=setting_thumbnail_size.value))) SourceColumn(source=Document, label=_('type'), attribute='document_type') diff --git a/mayan/apps/documents/links.py b/mayan/apps/documents/links.py index 1592e83444..c4fdc3ca0a 100644 --- a/mayan/apps/documents/links.py +++ b/mayan/apps/documents/links.py @@ -65,8 +65,9 @@ link_document_version_download = Link(args='object.pk', permissions=[permission_ # Tools link_clear_image_cache = Link( + icon='fa fa-file-image-o', description=_('Clear the graphics representations used to speed up the documents\' display and interactive transformations results.'), - permissions=[permission_document_tools], text=_('Clear the document image cache'), + permissions=[permission_document_tools], text=_('Clear image cache'), view='documents:document_clear_image_cache' ) @@ -96,3 +97,5 @@ link_document_type_filename_edit = Link(permissions=[permission_document_type_ed link_document_type_filename_list = Link(permissions=[permission_document_type_view], text=_('Filenames'), view='documents:document_type_filename_list', args='resolved_object.id') link_document_type_list = Link(permissions=[permission_document_type_view], text=_('Document types'), view='documents:document_type_list') link_document_type_setup = Link(icon='fa fa-file', permissions=[permission_document_type_view], text=_('Document types'), view='documents:document_type_list') + +link_tools = Link