cfp team users should have access to event commercials only

This commit is contained in:
Nishanth Vijayan 2016-08-16 18:56:54 +05:30
parent e2659ae907
commit a02060b665
2 changed files with 6 additions and 2 deletions

View file

@ -86,7 +86,9 @@ module Admin
@comment_count = @event.comment_threads.count
@ratings = @event.votes.includes(:user)
@difficulty_levels = @program.difficulty_levels
@versions = @event.versions | PaperTrail::Version.where(item_type: 'Commercial', item_id: @event.commercials.pluck(:id))
@versions = @event.versions |
PaperTrail::Version.where(item_type: 'Commercial').where_object(commercialable_id: @event.id, commercialable_type: 'Event') |
PaperTrail::Version.where(item_type: 'Commercial').where_object_changes(commercialable_id: @event.id, commercialable_type: 'Event')
end
def edit

View file

@ -211,8 +211,10 @@ class Ability
(Conference.with_role(:cfp, user).pluck(:id).include? role.resource_id)
end
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'Event', conference_id: conf_ids_for_cfp
can [:index, :revert_object, :revert_attribute], PaperTrail::Version do |version|
%w(Event Commercial).include?(version.item_type) && (conf_ids_for_cfp.include? version.conference_id)
version.item_type == 'Commercial' && conf_ids_for_cfp.include?(version.conference_id) &&
(version.object.to_s.include?('Event') || version.object_changes.to_s.include?('Event'))
end
end