diff --git a/app/controllers/admin/versions_controller.rb b/app/controllers/admin/versions_controller.rb index 1bc7ae2a..268fa8ac 100644 --- a/app/controllers/admin/versions_controller.rb +++ b/app/controllers/admin/versions_controller.rb @@ -6,12 +6,15 @@ module Admin load_and_authorize_resource class: PaperTrail::Version def index - @conferences_with_role = current_user.is_admin? ? Conference.pluck(:short_title) : Conference.with_role([:organizer, :cfp, :info_desk], current_user).pluck(:short_title) - + if Conference.any? + @conferences_with_role = current_user.is_admin? ? Conference.pluck(:short_title) : Conference.with_role([:organizer, :cfp, :info_desk], current_user).pluck(:short_title) + @conferences_with_role.uniq! + end if current_user.has_cached_role? :organization_admin, :any @conferences_with_role = Organization.with_role('organization_admin', current_user).map { |org| org.conferences.pluck :short_title }.flatten + @conferences_with_role.uniq! end - @conferences_with_role.uniq! + return if @conference.blank? diff --git a/app/views/admin/versions/index.html.haml b/app/views/admin/versions/index.html.haml index 0facd770..785b9b99 100644 --- a/app/views/admin/versions/index.html.haml +++ b/app/views/admin/versions/index.html.haml @@ -8,8 +8,9 @@ %span.caret %ul.dropdown-menu %li= link_to 'All Conferences & Users', admin_revision_history_path - - @conferences_with_role.each do |conference_short_title| - %li= link_to conference_short_title, admin_conference_revision_history_path(conference_id: conference_short_title) + - if !@conferences_with_role.nil? + - @conferences_with_role.each do |conference_short_title| + %li= link_to conference_short_title, admin_conference_revision_history_path(conference_id: conference_short_title) %h1 Revision History %p.text-muted