diff --git a/HISTORY.rst b/HISTORY.rst index dbc3e76de1..3eb843de53 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,7 @@ Importer branch ================== * Support configurable GUnicorn timeouts. Defaults to current value of 120 seconds. +* Fix help text of the platformtemplate command. 3.2.3 (2019-06-21) ================== diff --git a/docs/chapters/deploying.rst b/docs/chapters/deploying.rst index 3a90e44556..425f3274f9 100644 --- a/docs/chapters/deploying.rst +++ b/docs/chapters/deploying.rst @@ -4,7 +4,6 @@ Direct deployments Mayan EDMS should be deployed like any other Django_ project and preferably using virtualenv_. Below are some ways to deploy and use Mayan EDMS. -Do not use more than one method. Being a Django_ and a Python_ project, familiarity with these technologies is recommended to better understand why Mayan EDMS does some of the things it @@ -38,7 +37,7 @@ For another setup that offers more performance and scalability refer to the Platforms with the ARM CPU might also need additional requirements. :: - apt-sudo get libffi-dev libssl-dev -y + sudo apt-get install libffi-dev libssl-dev -y 2. Create the user account for the installation: @@ -149,7 +148,7 @@ For another setup that offers more performance and scalability refer to the ------------------------------------------------------------------------ :: - MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=mayan \ + sudo MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=mayan \ MAYAN_DATABASE_PASSWORD=mayanuserpass MAYAN_DATABASE_USER=mayan \ MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=/opt/mayan-edms/media \ /opt/mayan-edms/bin/mayan-edms.py platformtemplate supervisord > /etc/supervisor/conf.d/mayan.conf @@ -161,17 +160,17 @@ For another setup that offers more performance and scalability refer to the database and only keep 1 database: :: - echo "maxmemory-policy allkeys-lru" >> /etc/redis/redis.conf - echo "save \"\"" >> /etc/redis/redis.conf - echo "databases 1" >> /etc/redis/redis.conf - systemctl restart redis + sudo echo "maxmemory-policy allkeys-lru" >> /etc/redis/redis.conf + sudo echo "save \"\"" >> /etc/redis/redis.conf + sudo echo "databases 1" >> /etc/redis/redis.conf + sudo systemctl restart redis 13. Enable and restart the services [1_]: ----------------------------------------- :: - systemctl enable supervisor - systemctl restart supervisor + sudo systemctl enable supervisor + sudo systemctl restart supervisor 14. Cleaning up: @@ -180,7 +179,7 @@ For another setup that offers more performance and scalability refer to the installation and can be removed. :: - apt-get remove --purge libjpeg-dev libpq-dev libpng-dev libtiff-dev zlib1g-dev + sudo apt-get remove --purge libjpeg-dev libpq-dev libpng-dev libtiff-dev zlib1g-dev .. _deployment_advanced: @@ -227,7 +226,7 @@ of a restart or power failure. The Gunicorn workers are increased to 3. with:: - MAYAN_BROKER_URL="amqp://mayan:mayanuserpass@localhost:5672/mayan", + MAYAN_BROKER_URL="amqp://mayan:mayanrabbitmqpassword@localhost:5672/mayan", increase the number of Gunicorn workers to 3 in the line (``-w 2`` section):: @@ -240,7 +239,7 @@ of a restart or power failure. The Gunicorn workers are increased to 3. ------------------------ :: - supervisorctl restart all + sudo supervisorctl restart all diff --git a/docs/releases/3.2.4.rst b/docs/releases/3.2.4.rst index 3220236ed3..9db3ec8308 100644 --- a/docs/releases/3.2.4.rst +++ b/docs/releases/3.2.4.rst @@ -9,7 +9,7 @@ Changes - Support configurable GUnicorn timeouts. Defaults to current value of 120 seconds. - +- Fix help text of the platformtemplate command. Removals -------- diff --git a/mayan/apps/permissions/apps.py b/mayan/apps/permissions/apps.py index 9bdf738bdb..c1c7392966 100644 --- a/mayan/apps/permissions/apps.py +++ b/mayan/apps/permissions/apps.py @@ -12,6 +12,7 @@ from mayan.apps.common.menus import ( menu_list_facet, menu_object, menu_secondary, menu_setup ) from mayan.apps.common.signals import perform_upgrade +from mayan.apps.dashboards.dashboards import dashboard_main from mayan.apps.events.classes import ModelEventType from mayan.apps.events.links import ( link_events_for_object, link_object_event_types_user_subcriptions_list @@ -19,6 +20,7 @@ from mayan.apps.events.links import ( from mayan.apps.events.permissions import permission_events_view from mayan.apps.navigation.classes import SourceColumn +from .dashboard_widgets import DashboardWidgetRoleTotal from .events import event_role_created, event_role_edited from .handlers import handler_purge_permissions from .links import ( @@ -66,6 +68,10 @@ class PermissionsApp(MayanAppConfig): attribute='label', is_identifier=True, is_sortable=True, source=Role ) + dashboard_main.add_widget( + widget=DashboardWidgetRoleTotal, order=99 + ) + menu_list_facet.bind_links( links=( link_acl_list, link_events_for_object, diff --git a/mayan/apps/permissions/dashboard_widgets.py b/mayan/apps/permissions/dashboard_widgets.py new file mode 100644 index 0000000000..b06990a753 --- /dev/null +++ b/mayan/apps/permissions/dashboard_widgets.py @@ -0,0 +1,30 @@ +from __future__ import absolute_import, unicode_literals + +from django.apps import apps +from django.urls import reverse_lazy +from django.utils.translation import ugettext_lazy as _ + +from mayan.apps.dashboards.classes import DashboardWidgetNumeric + +from .icons import icon_role_list +from .permissions import permission_role_view + + +class DashboardWidgetRoleTotal(DashboardWidgetNumeric): + icon_class = icon_role_list + label = _('Total roles') + link = reverse_lazy(viewname='permissions:role_list') + + def render(self, request): + AccessControlList = apps.get_model( + app_label='acls', model_name='AccessControlList' + ) + Role = apps.get_model( + app_label='permissions', model_name='Role' + ) + + self.count = AccessControlList.objects.restrict_queryset( + permission=permission_role_view, user=request.user, + queryset=Role.objects.all() + ).count() + return super(DashboardWidgetRoleTotal, self).render(request) diff --git a/mayan/apps/platform/management/commands/platformtemplate.py b/mayan/apps/platform/management/commands/platformtemplate.py index f76fcc8c7e..3517d5c14a 100644 --- a/mayan/apps/platform/management/commands/platformtemplate.py +++ b/mayan/apps/platform/management/commands/platformtemplate.py @@ -16,7 +16,8 @@ class Command(management.BaseCommand): ) parser.add_argument( '--context', action='store', default='', dest='context', - help='Show a list of available templates.', + help='Pass a context to the template in the form of a JSON encoded ' + 'dictionary.', ) def handle(self, *args, **options): diff --git a/mayan/apps/user_management/apps.py b/mayan/apps/user_management/apps.py index 9415f0e44b..22ac437887 100644 --- a/mayan/apps/user_management/apps.py +++ b/mayan/apps/user_management/apps.py @@ -16,6 +16,7 @@ from mayan.apps.common.menus import ( menu_list_facet, menu_multi_item, menu_object, menu_secondary, menu_setup, menu_user ) +from mayan.apps.dashboards.dashboards import dashboard_main from mayan.apps.events.classes import ModelEventType from mayan.apps.events.links import ( link_events_for_object, link_object_event_types_user_subcriptions_list @@ -25,6 +26,9 @@ from mayan.apps.metadata.classes import MetadataLookup from mayan.apps.navigation.classes import SourceColumn from mayan.apps.rest_api.fields import DynamicSerializerField +from .dashboard_widgets import ( + DashboardWidgetGroupTotal, DashboardWidgetUserTotal +) from .events import ( event_group_created, event_group_edited, event_user_created, event_user_edited @@ -206,6 +210,13 @@ class UserManagementApp(MayanAppConfig): ) User.add_to_class(name='save', value=get_method_user_save()) + dashboard_main.add_widget( + widget=DashboardWidgetUserTotal, order=99 + ) + dashboard_main.add_widget( + widget=DashboardWidgetGroupTotal, order=99 + ) + menu_list_facet.bind_links( links=( link_acl_list, link_events_for_object, diff --git a/mayan/apps/user_management/dashboard_widgets.py b/mayan/apps/user_management/dashboard_widgets.py new file mode 100644 index 0000000000..29d96bab49 --- /dev/null +++ b/mayan/apps/user_management/dashboard_widgets.py @@ -0,0 +1,46 @@ +from __future__ import absolute_import, unicode_literals + +from django.apps import apps +from django.contrib.auth import get_user_model +from django.urls import reverse_lazy +from django.utils.translation import ugettext_lazy as _ + +from mayan.apps.dashboards.classes import DashboardWidgetNumeric + +from .icons import icon_group_list, icon_user_list +from .permissions import permission_group_view, permission_user_view + + +class DashboardWidgetUserTotal(DashboardWidgetNumeric): + icon_class = icon_user_list + label = _('Total users') + link = reverse_lazy(viewname='user_management:user_list') + + def render(self, request): + AccessControlList = apps.get_model( + app_label='acls', model_name='AccessControlList' + ) + self.count = AccessControlList.objects.restrict_queryset( + permission=permission_user_view, user=request.user, + queryset=get_user_model().objects.all() + ).count() + return super(DashboardWidgetUserTotal, self).render(request) + + +class DashboardWidgetGroupTotal(DashboardWidgetNumeric): + icon_class = icon_group_list + label = _('Total groups') + link = reverse_lazy(viewname='user_management:group_list') + + def render(self, request): + AccessControlList = apps.get_model( + app_label='acls', model_name='AccessControlList' + ) + Group = apps.get_model( + app_label='auth', model_name='Group' + ) + self.count = AccessControlList.objects.restrict_queryset( + permission=permission_group_view, user=request.user, + queryset=Group.objects.all() + ).count() + return super(DashboardWidgetGroupTotal, self).render(request)