diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 32ae0e85..ebcc9f92 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -3,7 +3,8 @@ module Admin load_and_authorize_resource def index - @conferences_available = Conference.with_roles([:admin, :organizer, :cfp], current_user) + @comments = Comment.accessible_by(current_ability).order(created_at: :desc).group_by { |comment| comment.commentable.conference } + @another_comments = Hash[@comments.map{|conference, comments| [conference, comments.group_by {|comment| comment.commentable}]}] end end end diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index 25f60e12..89ad9970 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -27,6 +27,7 @@ module Admin @recent_users = User.limit(5).order(created_at: :desc) @recent_events = Event.limit(5).order(created_at: :desc) @recent_registrations = Registration.limit(5).order(created_at: :desc) + @top_submitter = Conference.get_top_submitter @submissions = {} diff --git a/app/models/user.rb b/app/models/user.rb index 6ffd2059..568a1c89 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,7 +12,7 @@ class User < ActiveRecord::Base before_create :setup_role # add scope - scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_id = ?', conference.id)} + scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id)} # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, diff --git a/app/views/admin/comments/_all_comments.html.haml b/app/views/admin/comments/_all_comments.html.haml index 004c0606..a08b6eb9 100644 --- a/app/views/admin/comments/_all_comments.html.haml +++ b/app/views/admin/comments/_all_comments.html.haml @@ -1,19 +1,10 @@ .panel.well - -@conferences_available.each do |conference| - -conference.events.each do |event| - - if event.comment_threads.count > 0 - %panel - %panel.panel-header - %h4.title - %ul.list-unstyled - %li= link_to event.title, admin_conference_event_path(event.conference.short_title, event) - %li= conference.title - %hr - -event.comment_threads.each do |comment| - %panel-body - %ul.list-unstyled - %li= comment.body - %ul.list-inline - %li Posted by: #{comment.user.name} - %li Created at: #{comment.created_at} - %hr + %ul + - @another_comments.each do |conference, events| + %li= conference.title + - events.each do |event, comments| + %li= event.title + - comments.each do |comment| + %li= comment.body + %li= comment.user.name + %li= comment.created_at diff --git a/app/views/admin/comments/_posted_comments.html.haml b/app/views/admin/comments/_posted_comments.html.haml index 3c49d82c..7efd1295 100644 --- a/app/views/admin/comments/_posted_comments.html.haml +++ b/app/views/admin/comments/_posted_comments.html.haml @@ -1,17 +1,2 @@ .panel.well - -@conferences_available.each do |conference| - -conference.events.each do |event| - - if event.comment_threads.find_comments_by_user(current_user).count > 0 - %panel - %panel.panel-header - %h4.title - %ul.list-unstyled - %li= link_to event.title, admin_conference_event_path(event.conference.short_title, event) - %li= conference.title - %hr - -event.comment_threads.find_comments_by_user(current_user).each do |comment| - %panel-body - %ul.list-unstyled - %li= comment.body - %li Created at: #{comment.created_at} - %hr + Some text diff --git a/app/views/admin/comments/_unread_comments.html.haml b/app/views/admin/comments/_unread_comments.html.haml index e229aa78..6a8abba3 100644 --- a/app/views/admin/comments/_unread_comments.html.haml +++ b/app/views/admin/comments/_unread_comments.html.haml @@ -1,19 +1,2 @@ .panel.well - -@conferences_available.each do |conference| - -conference.events.each do |event| - - if event.comment_threads.find_since_last_login(current_user).count > 0 - %panel - %panel.panel-header - %h4.title - %ul.list-unstyled - %li= link_to event.title, admin_conference_event_path(event.conference.short_title, event) - %li= conference.title - %hr - -event.comment_threads.find_since_last_login(current_user).each do |comment| - %panel-body - %ul.list-unstyled - %li= comment.body - %ul.list-inline - %li Posted by: #{comment.user.name} - %li Created at: #{comment.created_at} - %hr + Some text