Remove maintenance tools menu entry, apps now register tools directly to the tools menu.
This commit is contained in:
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'))
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user