Skip to content

Commit

Permalink
[#3009] Fix auth for dashboard_mark_all_new_activities_as_old
Browse files Browse the repository at this point in the history
I think this is the correct way to do it, so that the auth function can
be overridden by IAuth plugins.
  • Loading branch information
Sean Hammond committed Nov 15, 2012
1 parent aed806f commit 3007c85
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
13 changes: 3 additions & 10 deletions ckan/logic/action/get.py
Expand Up @@ -2273,17 +2273,10 @@ def dashboard_mark_all_new_activities_as_old(context, data_dict):
This will reset dashboard_new_activities_count to 0.
'''
if 'user' not in context:
raise logic.NotAuthorized(
_("You must be logged in to access your dashboard."))

_check_access('dashboard_mark_all_new_activities_as_old', context,
data_dict)
model = context['model']

userobj = model.User.get(context['user'])
if not userobj:
raise logic.NotAuthorized(
_("You must be logged in to access your dashboard."))
user_id = userobj.id
user_id = model.User.get(context['user']).id
model.Dashboard.update_activity_stream_last_viewed(user_id)


Expand Down
5 changes: 5 additions & 0 deletions ckan/logic/auth/get.py
Expand Up @@ -202,3 +202,8 @@ def dashboard_activity_list(context, data_dict):
def dashboard_new_activities_count(context, data_dict):
return ckan.new_authz.is_authorized('dashboard_activity_list',
context, data_dict)


def dashboard_mark_all_new_activities_as_old(context, data_dict):
return ckan.new_authz.is_authorized('dashboard_activity_list',
context, data_dict)
1 change: 1 addition & 0 deletions ckan/logic/auth/publisher/get.py
Expand Up @@ -8,6 +8,7 @@
from ckan.logic.auth.get import (
dashboard_new_activities_count,
dashboard_activity_list,
dashboard_mark_all_new_activities_as_old,
)

def site_read(context, data_dict):
Expand Down

0 comments on commit 3007c85

Please sign in to comment.