created can_manage_comments helper for rendering button

This commit is contained in:
raluka 2015-08-26 22:09:36 +02:00
parent 84cd952b57
commit a3b6f204cb
4 changed files with 8 additions and 4 deletions

View file

@ -263,6 +263,10 @@ module ApplicationHelper
end end
end end
def can_manage_comments(conference)
(current_user.has_role? :organizer, conference) || (current_user.has_role? :cfp, conference)
end
def sign_in_path def sign_in_path
if CONFIG['authentication']['ichain']['enabled'] if CONFIG['authentication']['ichain']['enabled']
new_user_ichain_session_path new_user_ichain_session_path

View file

@ -137,7 +137,7 @@ class Ability
can :manage, Sponsor, conference_id: conf_ids_for_organizer can :manage, Sponsor, conference_id: conf_ids_for_organizer
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer
can :manage, Ticket, conference_id: conf_ids_for_organizer can :manage, Ticket, conference_id: conf_ids_for_organizer
can [:index, :create], Comment, commentable_type: 'Event', can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(conference_id: conf_ids_for_organizer).pluck(:id) commentable_id: Event.where(conference_id: conf_ids_for_organizer).pluck(:id)
end end
@ -157,7 +157,7 @@ class Ability
can :manage, CallForPaper, conference_id: conf_ids_for_cfp can :manage, CallForPaper, conference_id: conf_ids_for_cfp
can :manage, Commercial, commercialable_type: 'Event', can :manage, Commercial, commercialable_type: 'Event',
commercialable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id) commercialable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id)
can [:index, :create], Comment, commentable_type: 'Event', can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id) commentable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id)
end end

View file

@ -25,7 +25,7 @@
%b.caret %b.caret
%ul.dropdown-menu %ul.dropdown-menu
= render 'layouts/user_menu' = render 'layouts/user_menu'
- if can? :index, Comment #TODO modify condition - if can_manage_comments(@conference)
%ul.nav.navbar-nav.navbar-right %ul.nav.navbar-nav.navbar-right
%li.dropdown %li.dropdown
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#", id: "unread-comments-preview"} %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#", id: "unread-comments-preview"}