Files
mayan-edms/mayan/apps/checkouts/dashboard_widgets.py
Roberto Rosario 8e69178e07 Project: Switch to full app paths
Instead of inserting the path of the apps into the Python app,
the apps are now referenced by their full import path.

This app name claves with external or native Python libraries.
Example: Mayan statistics app vs. Python new statistics library.

Every app reference is now prepended with 'mayan.apps'.

Existing config.yml files need to be updated manually.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2018-12-05 02:04:20 -04:00

37 lines
1.4 KiB
Python

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.common.classes import DashboardWidgetNumeric
from mayan.apps.documents.permissions import permission_document_view
from .icons import icon_dashboard_checkouts
from .permissions import permission_document_checkout_detail_view
class DashboardWidgetTotalCheckouts(DashboardWidgetNumeric):
icon_class = icon_dashboard_checkouts
label = _('Checkedout documents')
link = reverse_lazy('checkouts:checkout_list')
def render(self, request):
AccessControlList = apps.get_model(
app_label='acls', model_name='AccessControlList'
)
DocumentCheckout = apps.get_model(
app_label='checkouts', model_name='DocumentCheckout'
)
queryset = AccessControlList.objects.filter_by_access(
permission=permission_document_checkout_detail_view,
user=request.user,
queryset=DocumentCheckout.objects.checked_out_documents()
)
queryset = AccessControlList.objects.filter_by_access(
permission=permission_document_view, user=request.user,
queryset=queryset
)
self.count = queryset.count()
return super(DashboardWidgetTotalCheckouts, self).render(request)