Make event list's user column an interactive link that
filters by user. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
Vagrant has been move into its own repository at:
|
||||
https://gitlab.com/mayan-edms/mayan-edms-vagrant
|
||||
- Add view to show list of events performed by an user.
|
||||
- Allow filtering an event list by clicking on the user column.
|
||||
|
||||
2.7.3 (2017-09-11)
|
||||
==================
|
||||
|
||||
@@ -26,6 +26,7 @@ What's new
|
||||
Vagrant has been move into its own repository at:
|
||||
https://gitlab.com/mayan-edms/mayan-edms-vagrant
|
||||
- Add view to show list of events performed by an user.
|
||||
- Allow filtering an event list by clicking on the user column.
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -18,15 +18,7 @@ from .links import (
|
||||
link_user_events, link_user_notifications_list,
|
||||
)
|
||||
from .licenses import * # NOQA
|
||||
from .widgets import event_object_link, event_type_link
|
||||
|
||||
|
||||
def event_actor(action):
|
||||
return _('System') if action.actor == action.target else action.actor
|
||||
|
||||
|
||||
def event_action_object(action):
|
||||
return action.action_object if action.action_object != action.target and action.action_object else ''
|
||||
from .widgets import event_object_link, event_type_link, event_user_link
|
||||
|
||||
|
||||
class EventsApp(MayanAppConfig):
|
||||
@@ -48,7 +40,7 @@ class EventsApp(MayanAppConfig):
|
||||
)
|
||||
SourceColumn(
|
||||
source=Action, label=_('Actor'),
|
||||
func=lambda context: event_actor(context['object'])
|
||||
func=lambda context: event_user_link(context['object'])
|
||||
)
|
||||
SourceColumn(
|
||||
source=Action, label=_('Event'),
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .classes import EventType
|
||||
|
||||
@@ -34,3 +35,15 @@ def event_type_link(entry):
|
||||
'label': EventType.get(name=entry.verb)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def event_user_link(entry):
|
||||
if entry.actor == entry.target:
|
||||
return _('System')
|
||||
else:
|
||||
return mark_safe(
|
||||
'<a href="%(url)s">%(label)s</a>' % {
|
||||
'url': reverse('events:user_events', kwargs={'pk': entry.actor.pk}),
|
||||
'label': entry.actor
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user