Events: Display current user events

Add a new view to display the events of the current user.
The link to this view is added to the user menu in the main menu
bar.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-06 22:01:41 -04:00
parent 3ab41e6b63
commit 28a1ecb685
5 changed files with 33 additions and 11 deletions

View File

@@ -158,6 +158,7 @@
- The HOME_VIEW setting is not a Django setting but a setting
from the common app. The HOME_VIEW has been moved to the
COMMON namespace and renamed to COMMON_HOME_VIEW.
- New link added to display the events of the current user.
3.1.9 (2018-11-01)
==================

View File

@@ -13,9 +13,10 @@ from mayan.apps.navigation import SourceColumn
from .licenses import * # NOQA
from .links import (
link_event_types_subscriptions_list, link_events_list,
link_notification_mark_read, link_notification_mark_read_all,
link_user_events, link_user_notifications_list
link_current_user_events, link_event_types_subscriptions_list,
link_events_list, link_notification_mark_read,
link_notification_mark_read_all, link_user_events,
link_user_notifications_list
)
from .widgets import event_object_link, event_type_link, event_user_link
@@ -96,4 +97,8 @@ class EventsApp(MayanAppConfig):
sources=('events:user_notifications_list',)
)
menu_tools.bind_links(links=(link_events_list,))
menu_user.bind_links(links=(link_event_types_subscriptions_list,))
menu_user.bind_links(
links=(
link_event_types_subscriptions_list, link_current_user_events
)
)

View File

@@ -36,9 +36,9 @@ def get_notification_count(context):
return context['request'].user.notifications.filter(read=False).count()
link_events_list = Link(
icon_class=icon_events_list, permissions=(permission_events_view,),
text=_('Events'), view='events:events_list'
link_current_user_events = Link(
icon_class=icon_events_user_list, text=_('My events'),
view='events:current_user_events'
)
link_events_details = Link(
text=_('Events'), view='events:events_list'
@@ -49,6 +49,10 @@ link_events_for_object = Link(
permissions=(permission_events_view,), text=_('Events'),
view='events:events_for_object',
)
link_events_list = Link(
icon_class=icon_events_list, permissions=(permission_events_view,),
text=_('Events'), view='events:events_list'
)
link_event_types_subscriptions_list = Link(
icon_class=icon_event_types_subscriptions_list,
text=_('Event subscriptions'),

View File

@@ -8,9 +8,10 @@ from .api_views import (
APINotificationListView, APIObjectEventListView
)
from .views import (
EventListView, EventTypeSubscriptionListView, NotificationListView,
NotificationMarkRead, NotificationMarkReadAll, ObjectEventListView,
ObjectEventTypeSubscriptionListView, UserEventListView, VerbEventListView
CurrentUserEventListView, EventListView, EventTypeSubscriptionListView,
NotificationListView, NotificationMarkRead, NotificationMarkReadAll,
ObjectEventListView, ObjectEventTypeSubscriptionListView,
UserEventListView, VerbEventListView
)
urlpatterns = [
@@ -37,7 +38,11 @@ urlpatterns = [
name='object_event_types_user_subcriptions_list'
),
url(
r'^user/(?P<pk>\d+)/events/$', UserEventListView.as_view(),
r'^user/$', CurrentUserEventListView.as_view(),
name='current_user_events'
),
url(
r'^user/(?P<pk>\d+)/$', UserEventListView.as_view(),
name='user_events'
),
url(

View File

@@ -298,6 +298,13 @@ class UserEventListView(SingleObjectListView):
return get_object_or_404(get_user_model(), pk=self.kwargs['pk'])
class CurrentUserEventListView(UserEventListView):
view_permission = None
def get_user(self):
return self.request.user
class VerbEventListView(SingleObjectListView):
def get_extra_context(self):
return {