Handle cancelation of scheduled events

This commit is contained in:
Nishanth Vijayan 2016-07-13 18:36:22 +05:30
parent 63750345e7
commit a071d4497b
5 changed files with 50 additions and 0 deletions

View file

@ -193,6 +193,14 @@ td.no-padding{
color: #D8D8D8 !important; color: #D8D8D8 !important;
} }
.schedule-label{
height: 14px;
line-height: 11px;
overflow: hidden;
display: inline-block;
white-space: normal;
}
/* Small devices (tablets, 768px and up) */ /* Small devices (tablets, 768px and up) */
@media (min-width: 768px) { @media (min-width: 768px) {
.room, .event-title{ .room, .event-title{
@ -227,6 +235,11 @@ td.no-padding{
td.event{ td.event{
padding: 3px 5px !important; padding: 3px 5px !important;
} }
.schedule-label{
height: 15px;
line-height: 12px;
}
} }
/* Large devices (large desktops, 1200px and up) */ /* Large devices (large desktops, 1200px and up) */

View file

@ -38,6 +38,8 @@ class Event < ActiveRecord::Base
validate :max_attendees_no_more_than_room_size validate :max_attendees_no_more_than_room_size
scope :confirmed, -> { where(state: 'confirmed') } scope :confirmed, -> { where(state: 'confirmed') }
scope :canceled, -> { where(state: 'canceled') }
scope :withdrawn, -> { where(state: 'withdrawn') }
scope :highlighted, -> { where(is_highlight: true) } scope :highlighted, -> { where(is_highlight: true) }
state_machine initial: :new do state_machine initial: :new do
@ -230,6 +232,13 @@ class Event < ActiveRecord::Base
self.start_time + self.event_type.length.minutes self.start_time + self.event_type.length.minutes
end end
##
# Returns events that are scheduled in the same room and start_time as event
#
def intersecting_events
room.events.where(start_time: start_time).where.not(id: id)
end
private private
## ##

View file

@ -33,6 +33,11 @@
- span -= 1 - span -= 1
- else - else
- event = events.find{|e| e.start_time <= start_room_time and e.end_time > start_room_time} - event = events.find{|e| e.start_time <= start_room_time and e.end_time > start_room_time}
- if event && (event.state == 'canceled' || event.state == 'withdrawn') && !event.intersecting_events.confirmed.empty?
- replacement_event = event.intersecting_events.confirmed.first
- event = (replacement_event.start_time <= start_room_time && replacement_event.end_time > start_room_time) ? replacement_event : nil
- if event - if event
/ There is an event, calculate the span and show it / There is an event, calculate the span and show it
- event_span = (event.end_time.to_i - start_room_time.to_i) / 60 / EventType::LENGTH_STEP - event_span = (event.end_time.to_i - start_room_time.to_i) / 60 / EventType::LENGTH_STEP

View file

@ -4,7 +4,14 @@
%a.unstyled-link{href: url_for(conference_program_proposal_path(@conference.short_title, event.id))} %a.unstyled-link{href: url_for(conference_program_proposal_path(@conference.short_title, event.id))}
%div{ class: "elipsis break-words event-title", | %div{ class: "elipsis break-words event-title", |
style: "-webkit-line-clamp: #{ event_lines(@rooms) }; height: #{ event_height(@rooms) }px;"} | style: "-webkit-line-clamp: #{ event_lines(@rooms) }; height: #{ event_height(@rooms) }px;"} |
- if event.state == 'canceled' || event.state == 'withdrawn'
%span.label.label-danger.schedule-label CANCELED
- elsif event.state == 'confirmed' && (!event.intersecting_events.canceled.empty? || !event.intersecting_events.withdrawn.empty?)
%span.label.label-info.schedule-label REPLACEMENT
= event.title = event.title
- if speaker = event.speakers.first - if speaker = event.speakers.first
= image_tag speaker.gravatar_url, :class => "img-circle pull-right speaker-pic", | = image_tag speaker.gravatar_url, :class => "img-circle pull-right speaker-pic", |
:alt => speaker.name, | :alt => speaker.name, |

View file

@ -14,6 +14,12 @@
= link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary" = link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary"
- if can? :schedule, @conference - if can? :schedule, @conference
= link_to "Schedule", schedule_conference_path(@conference.short_title), :class =>"btn btn-success" = link_to "Schedule", schedule_conference_path(@conference.short_title), :class =>"btn btn-success"
- if @event.state == 'canceled' || @event.state == 'withdrawn'
%span.label.label-danger CANCELED
- elsif @event.state == 'confirmed' && (!@event.intersecting_events.canceled.empty? || !@event.intersecting_events.withdrawn.empty?)
%span.label.label-info REPLACEMENT
.row .row
.col-md-3 .col-md-3
.speakerinfo .speakerinfo
@ -34,6 +40,16 @@
.col-md-9 .col-md-9
.row .row
.col-md-12 .col-md-12
.lead
- if @event.state == 'confirmed' && !@event.intersecting_events.withdrawn.empty?
= "Please note that this talk replaces"
= link_to @event.intersecting_events.withdrawn.first.title,
conference_program_proposal_path(@conference.short_title, @event.intersecting_events.withdrawn.first.id)
- elsif @event.state == 'confirmed' && !@event.intersecting_events.canceled.empty?
= "Please note that this talk replaces"
= link_to @event.intersecting_events.canceled.first.title,
conference_program_proposal_path(@conference.short_title, @event.intersecting_events.canceled.first.id)
- if @event.commercials.empty? - if @event.commercials.empty?
%h5.text-warning %h5.text-warning
No video of the event yet, sorry! No video of the event yet, sorry!