Move events index datatable row to a partial
- clean up columns - tag unregistered submitters & speakers - implement caching
This commit is contained in:
parent
0d4c9e32cf
commit
a2ed9c0074
7 changed files with 84 additions and 54 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
class DifficultyLevel < ApplicationRecord
|
class DifficultyLevel < ApplicationRecord
|
||||||
belongs_to :program
|
belongs_to :program, touch: true
|
||||||
has_many :events, dependent: :nullify
|
has_many :events, dependent: :nullify
|
||||||
|
|
||||||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class EventType < ApplicationRecord
|
class EventType < ApplicationRecord
|
||||||
belongs_to :program
|
belongs_to :program, touch: true
|
||||||
has_many :events, dependent: :restrict_with_error
|
has_many :events, dependent: :restrict_with_error
|
||||||
|
|
||||||
has_paper_trail meta: { conference_id: :conference_id }
|
has_paper_trail meta: { conference_id: :conference_id }
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ class EventUser < ApplicationRecord
|
||||||
# TODO: Do we need these roles?
|
# TODO: Do we need these roles?
|
||||||
ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator]]
|
ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator]]
|
||||||
|
|
||||||
belongs_to :event
|
belongs_to :event, touch: true
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class Track < ApplicationRecord
|
||||||
|
|
||||||
resourcify :roles, dependent: :delete_all
|
resourcify :roles, dependent: :delete_all
|
||||||
|
|
||||||
belongs_to :program
|
belongs_to :program, touch: true
|
||||||
belongs_to :submitter, class_name: 'User'
|
belongs_to :submitter, class_name: 'User'
|
||||||
belongs_to :room
|
belongs_to :room
|
||||||
belongs_to :selected_schedule, class_name: 'Schedule'
|
belongs_to :selected_schedule, class_name: 'Schedule'
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
before_create :setup_role
|
before_create :setup_role
|
||||||
|
|
||||||
|
after_save :touch_events
|
||||||
|
|
||||||
# add scope
|
# add scope
|
||||||
scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', 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)}
|
||||||
|
|
||||||
|
|
@ -231,6 +233,10 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def touch_events
|
||||||
|
event_users.each(&:touch)
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Check if biography has an allowed number of words. Used as validation.
|
# Check if biography has an allowed number of words. Used as validation.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
63
app/views/admin/events/_datatable_row.haml
Normal file
63
app/views/admin/events/_datatable_row.haml
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
- cache ['admin', conference_id, program, event] do
|
||||||
|
%tr{ id: "event-#{event.id}" }
|
||||||
|
%td
|
||||||
|
= event.id
|
||||||
|
|
||||||
|
%td
|
||||||
|
= link_to event.title,
|
||||||
|
admin_conference_program_event_path(conference_id, event)
|
||||||
|
|
||||||
|
- if rating_enabled
|
||||||
|
%td.col-md-1{ data: { order: event.average_rating } }
|
||||||
|
= render 'datatable_row_rating',
|
||||||
|
event: event,
|
||||||
|
show_votes: show_votes,
|
||||||
|
max_rating: max_rating
|
||||||
|
|
||||||
|
- if event.submitter
|
||||||
|
%td
|
||||||
|
= link_to event.submitter.name, admin_user_path(event.submitter)
|
||||||
|
- unless event.submitter.registrations.for_conference(event.conference)
|
||||||
|
%span.label.label-warning Unregistered
|
||||||
|
- else
|
||||||
|
%td.bg-danger
|
||||||
|
Unknown submitter
|
||||||
|
|
||||||
|
%td
|
||||||
|
- event.speakers_ordered.each do |speaker|
|
||||||
|
.speaker
|
||||||
|
= link_to speaker.name, admin_user_path(speaker)
|
||||||
|
- unless speaker.registrations.for_conference(event.conference)
|
||||||
|
%span.label.label-danger Unregistered
|
||||||
|
|
||||||
|
- if @program.languages.present?
|
||||||
|
%td
|
||||||
|
= event.language
|
||||||
|
|
||||||
|
%td.text-center{ data: { order: event.require_registration.to_s } }
|
||||||
|
= event_switch_checkbox(event, :require_registration, conference_id)
|
||||||
|
- if event.require_registration
|
||||||
|
= link_to registered_text(event),
|
||||||
|
registrations_admin_conference_program_event_path(conference_id,
|
||||||
|
event),
|
||||||
|
class: 'btn btn-xs btn-default'
|
||||||
|
|
||||||
|
%td.text-center{ data: { order: event.is_highlight.to_s } }
|
||||||
|
= event_switch_checkbox(event, :is_highlight, conference_id)
|
||||||
|
|
||||||
|
%td
|
||||||
|
= event_type_dropdown(event, event_types, conference_id)
|
||||||
|
|
||||||
|
%td
|
||||||
|
= track_dropdown(event, tracks, conference_id)
|
||||||
|
|
||||||
|
%td
|
||||||
|
= difficulty_dropdown(event, difficulty_levels, conference_id)
|
||||||
|
|
||||||
|
%td
|
||||||
|
= state_dropdown(event, conference_id, email_settings)
|
||||||
|
|
||||||
|
%td.text-center
|
||||||
|
= link_to "#{event.comments_count}",
|
||||||
|
admin_conference_program_event_path(conference_id, event),
|
||||||
|
anchor: 'comments-div'
|
||||||
|
|
@ -90,53 +90,14 @@
|
||||||
%th
|
%th
|
||||||
.fa.fa-comment
|
.fa.fa-comment
|
||||||
- @events.each do |event|
|
- @events.each do |event|
|
||||||
%tr
|
= render 'datatable_row',
|
||||||
%td
|
event: event,
|
||||||
= event.id
|
conference_id: @conference.short_title,
|
||||||
%td
|
program: @program,
|
||||||
= link_to event.title, admin_conference_program_event_path(@conference.short_title, event)
|
rating_enabled: @program.rating_enabled?,
|
||||||
|
show_votes: @program.show_voting?,
|
||||||
- if @program.rating_enabled?
|
max_rating: @program.rating,
|
||||||
%td.col-md-1{ data: { order: event.average_rating } }
|
event_types: @event_types,
|
||||||
= render 'datatable_row_rating',
|
tracks: @tracks,
|
||||||
event: event,
|
difficulty_levels: @difficulty_levels,
|
||||||
show_votes: @program.show_voting?,
|
email_settings: @conference.email_settings
|
||||||
max_rating: @program.rating
|
|
||||||
|
|
||||||
- if event.submitter && event.submitter.registrations && event.submitter.registrations.count < 1
|
|
||||||
- bgcolor = '#F7819F'
|
|
||||||
- else
|
|
||||||
- bgcolor = ''
|
|
||||||
%td{ style: "background-color: #{bgcolor}" }
|
|
||||||
- unless event.submitter.nil?
|
|
||||||
= link_to event.submitter.name, admin_user_path(event.submitter)
|
|
||||||
- if event.submitter.registrations.count < 1
|
|
||||||
(Unregistered!)
|
|
||||||
- else
|
|
||||||
Unknown submitter
|
|
||||||
%td
|
|
||||||
- event.speakers_ordered.each do |speaker|
|
|
||||||
.speaker
|
|
||||||
= link_to speaker.name, admin_user_path(speaker)
|
|
||||||
|
|
||||||
- if @program.languages.present?
|
|
||||||
%td
|
|
||||||
= event.language
|
|
||||||
|
|
||||||
%td.text-center{ 'data-order' => "#{event.require_registration}" }
|
|
||||||
= event_switch_checkbox(event, :require_registration, @conference.short_title)
|
|
||||||
- if event.require_registration
|
|
||||||
= link_to registered_text(event), registrations_admin_conference_program_event_path(@conference.short_title, event), class: 'btn btn-xs btn-default'
|
|
||||||
|
|
||||||
%td.text-center{ 'data-order' => "#{event.is_highlight}" }
|
|
||||||
= event_switch_checkbox(event, :is_highlight, @conference.short_title)
|
|
||||||
%td
|
|
||||||
= event_type_dropdown(event, @event_types, @conference.short_title)
|
|
||||||
%td
|
|
||||||
= track_dropdown(event, @tracks, @conference.short_title)
|
|
||||||
%td
|
|
||||||
= difficulty_dropdown(event, @difficulty_levels, @conference.short_title)
|
|
||||||
%td
|
|
||||||
= state_dropdown(event, @conference.short_title, @conference.email_settings)
|
|
||||||
%td.text-center
|
|
||||||
= link_to "#{event.comments_count}", admin_conference_program_event_path(@conference.short_title, event), anchor: 'comments-div'
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue