Add support for sortable columns

Add a new argument to the SourceColumn class to flag a column as
sortable. The SourceColum will generate a request querystring to
be used as the table header archor href. The SingleObjectListView
will capture the querystring and call the order_by on the queryset
to sort it.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-23 05:11:14 -04:00
parent 36101dfea6
commit 25edc73100
17 changed files with 308 additions and 106 deletions
+22
View File
@@ -1,10 +1,15 @@
from __future__ import absolute_import, unicode_literals
import logging
from django.apps import apps
from django.core.exceptions import PermissionDenied
from django.urls import Resolver404, resolve
from mayan.apps.permissions import Permission
logger = logging.getLogger(__name__)
def get_cascade_condition(app_label, model_name, object_permission, view_permission=None):
"""
@@ -38,3 +43,20 @@ def get_cascade_condition(app_label, model_name, object_permission, view_permiss
return queryset.count() > 0
return condition
def get_current_view_name(request):
current_path = request.META['PATH_INFO']
# Get sources: view name, view objects
try:
current_view_name = resolve(current_path).view_name
except Resolver404:
# Can't figure out which view corresponds to this URL.
# Most likely it is an invalid URL.
logger.warning(
'Can\'t figure out which view corresponds to this '
'URL: %s; aborting menu resolution.', current_path
)
else:
return current_view_name