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
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

View file

@ -137,7 +137,7 @@ class Ability
can :manage, Sponsor, 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 [:index, :create], Comment, commentable_type: 'Event',
can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(conference_id: conf_ids_for_organizer).pluck(:id)
end
@ -157,7 +157,7 @@ class Ability
can :manage, CallForPaper, conference_id: conf_ids_for_cfp
can :manage, Commercial, commercialable_type: 'Event',
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)
end

View file

@ -29,7 +29,7 @@ class User < ActiveRecord::Base
devise(*devise_modules)
has_and_belongs_to_many :roles
has_and_belongs_to_many :roles
has_many :openids
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids,

View file

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