From 52a503afd2c831b97fe2d9979296e8dc0132415f Mon Sep 17 00:00:00 2001 From: raluka Date: Tue, 1 Sep 2015 13:01:57 +0200 Subject: [PATCH] changed #signed_in_with_roles(user) in ability.rb model --- app/controllers/admin/comments_controller.rb | 2 ++ app/helpers/application_helper.rb | 4 ---- app/models/ability.rb | 8 ++++---- app/views/layouts/_navigation.html.haml | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 990375cf..ae6623a1 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -1,7 +1,9 @@ module Admin class CommentsController < Admin::BaseController + load_and_authorize_resource :conference, find_by: :short_title load_and_authorize_resource + def index @ordered_events = Event.order(:title).all end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7f24331e..54d79425 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -263,10 +263,6 @@ module ApplicationHelper end end - def can_manage_comments(conference) - (current_user.has_role? :organizer, conference) || (current_user.has_role? :cfp, conference) - end - def sign_in_path if CONFIG['authentication']['ichain']['enabled'] new_user_ichain_session_path diff --git a/app/models/ability.rb b/app/models/ability.rb index 2b78cc06..b71bee97 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -88,10 +88,10 @@ class Ability # Abilities from not_signed_in and signed_in are also inherited signed_in(user) - signed_in_with_organizer_role(user) - signed_in_with_cfp_role(user) - signed_in_with_info_desk_role(user) - signed_in_with_volunteers_coordinator_role(user) + signed_in_with_organizer_role(user) if user.has_role? :organizer, :any + signed_in_with_cfp_role(user) if user.has_role? :cfp, :any + signed_in_with_info_desk_role(user) if user.has_role? :info_desk, :any + signed_in_with_volunteers_coordinator_role(user) if user.has_role? :volunteer_coordinator, :any # for users with any role can [:show], Conference diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 1f66af8b..a9a45ecc 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -25,7 +25,7 @@ %b.caret %ul.dropdown-menu = render 'layouts/user_menu' - - if can_manage_comments(@conference) + - if can? :index, Comment %ul.nav.navbar-nav.navbar-right %li.dropdown %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#", id: "unread-comments-preview"}