Allow organizers to view changes in a per conference basis

This commit is contained in:
Nishanth Vijayan 2016-08-06 17:22:53 +05:30
parent d07de3ca88
commit 7cff5e0da6
2 changed files with 24 additions and 2 deletions

View file

@ -4,8 +4,14 @@ module Admin
def index def index
authorize! :index, PaperTrail::Version.new(item_type: 'User') authorize! :index, PaperTrail::Version.new(item_type: 'User')
conf_ids_for_organizer = current_user.is_admin? ? Conference.pluck(:id) : Conference.with_role(:organizer, current_user).pluck(:id) @conf_ids_for_organizer = current_user.is_admin? ? Conference.pluck(:id) : Conference.with_role(:organizer, current_user).pluck(:id)
@versions = PaperTrail::Version.where(["conference_id IN (?) OR item_type = 'User'", conf_ids_for_organizer]) @conference_id = params[:conference_id].to_i unless params[:conference_id].nil?
if @conference_id.nil?
@versions = PaperTrail::Version.where(["conference_id IN (?) OR item_type = 'User'", @conf_ids_for_organizer])
else
@versions = PaperTrail::Version.where(['conference_id IN (?)', (@conf_ids_for_organizer & [@conference_id])]).
where.not(item_type: 'User')
end
end end
def revert_attribute def revert_attribute

View file

@ -1,6 +1,22 @@
.row .row
.col-md-12 .col-md-12
.page-header .page-header
.dropdown.pull-right
%button.btn.btn-success.dropdown-toggle{'data-toggle' => 'dropdown', type: 'button'}
- if @conference_id.nil?
All Conferences & Users
- elsif @conf_ids_for_organizer.include?(@conference_id)
= Conference.find(@conference_id).short_title
- else
Filter By Conference
%span.caret
%ul.dropdown-menu
%li= link_to 'All Conferences & Users', admin_revision_history_path
- @conf_ids_for_organizer.each do |conf_id|
- conference = Conference.find(conf_id)
%li= link_to conference.short_title, admin_revision_history_path(conference_id: conference.id)
%h1 Revision History %h1 Revision History
%p.text-muted %p.text-muted
Log of changes made to conferences and associated resources Log of changes made to conferences and associated resources