Add view to show list of events performed by an user.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
- Remove Vagrant section of the document. Anything related to
|
||||
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.
|
||||
|
||||
2.7.3 (2017-09-11)
|
||||
==================
|
||||
|
||||
@@ -25,6 +25,7 @@ What's new
|
||||
- Remove Vagrant section of the document. Anything related to
|
||||
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.
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common import (
|
||||
@@ -14,7 +15,7 @@ from rest_api.classes import APIEndPoint
|
||||
from .links import (
|
||||
link_events_list, link_event_types_subscriptions_list,
|
||||
link_notification_mark_read, link_notification_mark_read_all,
|
||||
link_user_notifications_list,
|
||||
link_user_events, link_user_notifications_list,
|
||||
)
|
||||
from .licenses import * # NOQA
|
||||
from .widgets import event_object_link, event_type_link
|
||||
@@ -38,6 +39,7 @@ class EventsApp(MayanAppConfig):
|
||||
Action = apps.get_model(app_label='actstream', model_name='Action')
|
||||
Notification = self.get_model(model_name='Notification')
|
||||
StoredEventType = self.get_model(model_name='StoredEventType')
|
||||
User = get_user_model()
|
||||
|
||||
APIEndPoint(app=self, version_string='1')
|
||||
|
||||
@@ -94,6 +96,9 @@ class EventsApp(MayanAppConfig):
|
||||
menu_object.bind_links(
|
||||
links=(link_notification_mark_read,), sources=(Notification,)
|
||||
)
|
||||
menu_object.bind_links(
|
||||
links=(link_user_events,), sources=(User,)
|
||||
)
|
||||
menu_secondary.bind_links(
|
||||
links=(link_notification_mark_read_all,),
|
||||
sources=('events:user_notifications_list',)
|
||||
|
||||
@@ -63,6 +63,10 @@ link_object_event_types_user_subcriptions_list_with_icon = Link(
|
||||
permissions=(permission_events_view,), text=_('Subscriptions'),
|
||||
view='events:object_event_types_user_subcriptions_list',
|
||||
)
|
||||
link_user_events = Link(
|
||||
args='resolved_object.pk', text=_('User events'),
|
||||
view='events:user_events'
|
||||
)
|
||||
link_user_notifications_list = Link(
|
||||
icon='fa fa-bell', text=get_notification_count,
|
||||
view='events:user_notifications_list'
|
||||
|
||||
@@ -10,7 +10,7 @@ from .api_views import (
|
||||
from .views import (
|
||||
EventListView, EventTypeSubscriptionListView, NotificationListView,
|
||||
NotificationMarkRead, NotificationMarkReadAll, ObjectEventListView,
|
||||
ObjectEventTypeSubscriptionListView, VerbEventListView
|
||||
ObjectEventTypeSubscriptionListView, UserEventListView, VerbEventListView
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
@@ -36,14 +36,17 @@ urlpatterns = [
|
||||
ObjectEventTypeSubscriptionListView.as_view(),
|
||||
name='object_event_types_user_subcriptions_list'
|
||||
),
|
||||
url(
|
||||
r'^user/(?P<pk>\d+)/events/$', UserEventListView.as_view(),
|
||||
name='user_events'
|
||||
),
|
||||
url(
|
||||
r'^user/event_types/subscriptions/$',
|
||||
EventTypeSubscriptionListView.as_view(),
|
||||
name='event_types_user_subcriptions_list'
|
||||
),
|
||||
url(
|
||||
r'^user/notifications/$',
|
||||
NotificationListView.as_view(),
|
||||
r'^user/notifications/$', NotificationListView.as_view(),
|
||||
name='user_notifications_list'
|
||||
),
|
||||
]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.http import Http404, HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404
|
||||
@@ -240,6 +241,33 @@ class ObjectEventTypeSubscriptionListView(FormView):
|
||||
return ModelEventType.get_for_instance(instance=self.get_object())
|
||||
|
||||
|
||||
class UserEventListView(SingleObjectListView):
|
||||
view_permission = permission_events_view
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'extra_columns': (
|
||||
{
|
||||
'name': _('Target'),
|
||||
'attribute': encapsulate(
|
||||
lambda entry: event_object_link(entry)
|
||||
)
|
||||
},
|
||||
),
|
||||
'hide_object': True,
|
||||
'object': self.get_user(),
|
||||
'title': _(
|
||||
'Events for user: %s'
|
||||
) % self.get_user(),
|
||||
}
|
||||
|
||||
def get_object_list(self):
|
||||
return Action.objects.actor(obj=self.get_user())
|
||||
|
||||
def get_user(self):
|
||||
return get_object_or_404(get_user_model(), pk=self.kwargs['pk'])
|
||||
|
||||
|
||||
class VerbEventListView(SingleObjectListView):
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user