mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
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
|
||||
belongs_to :program
|
||||
belongs_to :program, touch: true
|
||||
has_many :events, dependent: :nullify
|
||||
|
||||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class EventType < ApplicationRecord
|
||||
belongs_to :program
|
||||
belongs_to :program, touch: true
|
||||
has_many :events, dependent: :restrict_with_error
|
||||
|
||||
has_paper_trail meta: { conference_id: :conference_id }
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ class EventUser < ApplicationRecord
|
|||
# TODO: Do we need these roles?
|
||||
ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator]]
|
||||
|
||||
belongs_to :event
|
||||
belongs_to :event, touch: true
|
||||
belongs_to :user
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class Track < ApplicationRecord
|
|||
|
||||
resourcify :roles, dependent: :delete_all
|
||||
|
||||
belongs_to :program
|
||||
belongs_to :program, touch: true
|
||||
belongs_to :submitter, class_name: 'User'
|
||||
belongs_to :room
|
||||
belongs_to :selected_schedule, class_name: 'Schedule'
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ class User < ApplicationRecord
|
|||
|
||||
before_create :setup_role
|
||||
|
||||
after_save :touch_events
|
||||
|
||||
# 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)}
|
||||
|
||||
|
|
@ -231,6 +233,10 @@ class User < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def touch_events
|
||||
event_users.each(&:touch)
|
||||
end
|
||||
|
||||
##
|
||||
# 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
|
||||
.fa.fa-comment
|
||||
- @events.each do |event|
|
||||
%tr
|
||||
%td
|
||||
= event.id
|
||||
%td
|
||||
= link_to event.title, admin_conference_program_event_path(@conference.short_title, event)
|
||||
|
||||
- if @program.rating_enabled?
|
||||
%td.col-md-1{ data: { order: event.average_rating } }
|
||||
= render 'datatable_row_rating',
|
||||
event: event,
|
||||
show_votes: @program.show_voting?,
|
||||
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'
|
||||
= render 'datatable_row',
|
||||
event: event,
|
||||
conference_id: @conference.short_title,
|
||||
program: @program,
|
||||
rating_enabled: @program.rating_enabled?,
|
||||
show_votes: @program.show_voting?,
|
||||
max_rating: @program.rating,
|
||||
event_types: @event_types,
|
||||
tracks: @tracks,
|
||||
difficulty_levels: @difficulty_levels,
|
||||
email_settings: @conference.email_settings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue