Browse Source

Updates to schedule maker

development
Godwin 8 years ago
parent
commit
4ee45f013b
  1. 3
      app/assets/javascripts/housing.js
  2. 1
      app/assets/javascripts/registrations.js
  3. 139
      app/assets/javascripts/schedule.js
  4. 50
      app/assets/stylesheets/_application.scss
  5. 643
      app/controllers/application_controller.rb
  6. 1841
      app/controllers/conferences_controller.rb
  7. 2
      app/helpers/application_helper.rb
  8. 125
      app/views/conferences/admin/_schedule.html.haml

3
app/assets/javascripts/housing.js

@ -1,6 +1,7 @@
(function() {
function closeGuestSelector() {
document.getElementById('guest-selector').classList.remove('open');
document.body.classList.remove('modal-open');
}
function _post(form, params, f) {
var request = new XMLHttpRequest();
@ -16,7 +17,6 @@
params['authenticity_token'] = form.querySelector('[name="authenticity_token"]').value;
var data = [];
for (var key in params) {
//data.push(key + '=' + encodeURI(params[key]));
data.push(key + '=' + params[key]);
}
request.send(data.join('&'));
@ -29,6 +29,7 @@
document.getElementById('guest-selector').classList.add('open');
var table = document.getElementById('table');
table.classList.add('loading');
document.body.classList.add('modal-open');
_post(
document.getElementById('housing-table-form'),
{

1
app/assets/javascripts/registrations.js

@ -129,7 +129,6 @@
document.observe("focusin", function (event) { editTableCell(event.target); });
} else {
document.addEventListener("focus", function (event) { editTableCell(event.target); }, true);
// document.addEventListener("focus", function (event) { editTableCell(event.target); }, true);
}
searchControl.addEventListener('keyup', filterTable);

139
app/assets/javascripts/schedule.js

@ -1,39 +1,114 @@
(function() {
function initSchedule() {
forEachElement('table.schedule td.workshop.empty', function(block) {
block.addEventListener('click', function(event) {
console.log('clicked');
});
});
function closeWorkshopSelector() {
document.getElementById('workshop-selector').classList.remove('open');
document.body.classList.remove('modal-open');
}
document.getElementById('workshop-selector').addEventListener('click', function(event) {
if (event.target.id == 'workshop-selector') {
closeWorkshopSelector();
}
});
function _post(form, params, f) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 200) {
f(request.responseText);
}
}
}
request.open('POST', form.getAttribute('action'), true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
params['authenticity_token'] = form.querySelector('[name="authenticity_token"]').value;
var data = [];
for (var key in params) {
data.push(key + '=' + params[key]);
}
request.send(data.join('&'));
}
function selectorMatches(el, selector) {
var p = Element.prototype;
var f = p.matches || p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector || function(s) {
return [].indexOf.call(document.querySelectorAll(s), this) !== -1;
};
return f.call(el, selector);
}
function updateSchedule(html) {
var schedule = document.getElementById('schedule-preview');
var s = document.createElement('div');
s.innerHTML = html;
schedule.innerHTML = s.children[0].innerHTML;
schedule.classList.remove('requesting');
}
initSchedule();
/*var body = document.querySelector('body');
var primaryContent = document.getElementById('primary-content');
var eventDlg = document.getElementById('event-dlg');
forEachElement('.event-detail-link', function(link) {
var eventDetails = link.parentElement.querySelector('.event-details');
var moreDetails = eventDlg.querySelector('.more-details');
link.addEventListener('click', function(event) {
document.body.addEventListener('submit', function (event) {
if (event.target.classList.contains('deschedule-workshop')) {
event.preventDefault();
eventDlg.querySelector('.event-details').innerHTML = eventDetails.innerHTML;
var href = eventDetails.getAttribute('data-href');
if (href) {
moreDetails.setAttribute('href', href);
moreDetails.classList.remove('hidden');
} else {
moreDetails.classList.add('hidden');
var schedule = document.getElementById('schedule-preview');
var form = event.target;
schedule.classList.add('requesting');
_post(
form,
{
id: form.querySelector('[name="id"]').value,
button: 'deschedule_workshop'
},
updateSchedule
);
}
});
document.body.addEventListener('click', function (event) {
//console.log(event.target);
if (selectorMatches(event.target, 'td.workshop.open, td.workshop.open *')) {
//event.stopPropagation();
var button = event.target;
while (button && button.tagName && button.tagName !== 'TD') {
button = button.parentElement;
}
window.openOverlay(eventDlg, primaryContent, body);
var closeDlg = function(event) {
event.preventDefault();
window.closeOverlay(eventDlg, primaryContent, body);
};
eventDlg.querySelector('.close-btn').onclick = closeDlg;
document.getElementById('overlay').onclick = closeDlg;
});
});*/
document.getElementById('workshop-selector').classList.add('open');
var table = document.getElementById('table');
table.classList.add('loading');
document.body.classList.add('modal-open');
var block = button.getAttribute('data-block');
var day = button.getAttribute('data-day');
var location = button.getAttribute('data-location');
_post(
document.getElementById('workshop-table-form'),
{
block: block,
day: day,
location: location,
button: 'get-workshop-list'
},
function (response) {
var table = document.getElementById('table');
table.innerHTML = response;
table.classList.remove('loading');
forEachElement('tr.selectable', function(row) {
row.addEventListener('click', function(event) {
var schedule = document.getElementById('schedule-preview');
schedule.classList.add('requesting');
closeWorkshopSelector();
var form = document.getElementById('workshop-table-form');
_post(
form,
{
workshop: row.getAttribute('data-workshop'),
block: block,
day: day,
location: form.querySelector('#event_location').value,
button: 'set-workshop'
},
updateSchedule
);
});
}, table);
}
);
}
}, true);
})();

50
app/assets/stylesheets/_application.scss

@ -1761,7 +1761,7 @@ ul.warnings li,
}
}
#admin-housing {
#admin-housing, #admin-schedule {
.guests-housed {
margin-bottom: 1em;
text-align: right;
@ -1873,7 +1873,19 @@ ul.warnings li,
}
}
#guest-selector {
#workshop-selector {
td, th {
white-space: nowrap;
}
td .text {
max-width: 50em;
overflow: hidden;
text-overflow: ellipsis;
}
}
#guest-selector, #workshop-selector {
display: none;
position: fixed;
top: 0;
@ -1888,7 +1900,7 @@ ul.warnings li,
display: block;
}
.guest-dlg {
.guest-dlg, .workshop-dlg {
position: absolute;
top: 0;
right: 0;
@ -1931,7 +1943,7 @@ ul.warnings li,
}
table {
min-width: 100em;
margin: 0 0 2em;
}
h4 {
@ -2035,6 +2047,10 @@ ul.warnings li,
}
#admin-housing {
#table table {
min-width: 100em;
}
#hosts {
background-color: $white;
@ -2208,9 +2224,8 @@ table.schedule {
&.locations-6 td.workshop.filled {
width: 16.66667%;
}
td {
position: relative;
//position: relative;
text-align: center;
&.empty {
@ -2249,21 +2264,20 @@ table.schedule {
}
.event-detail-link {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: inline-block;
display: inline-flex;
position: relative;
height: 100%;
width: 100%;
color: inherit;
align-items: center;
@include after {
display: none;
}
&:hover {
outline: 0.33rem solid #02CA9E;
outline-offset: 0.25rem;
z-index: 1;
.details {
flex: 1;
}
}
@ -2329,6 +2343,12 @@ table.schedule {
}
}
body.home table.schedule td .event-detail-link:hover {
outline: 0.33rem solid #02CA9E;
outline-offset: 0.25rem;
z-index: 1;
}
.event-dlg {
@include _-(flex, 0);
position: relative;

643
app/controllers/application_controller.rb

@ -1,643 +0,0 @@
module ActiveRecord
class PremissionDenied < RuntimeError
end
end
class ApplicationController < LinguaFrancaApplicationController
include ScheduleHelper
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception, :except => [:do_confirm, :js_error, :admin_update]
before_filter :capture_page_info
@@test_host
@@test_location
def capture_page_info
if request.method == "GET" && (params[:controller] != 'application' || params[:action] != 'contact')
session[:last_request]
request_info = {
'params' => params,
'request' => {
'remote_ip' => request.remote_ip,
'uuid' => request.uuid,
'original_url' => request.original_url,
'env' => Hash.new
}
}
request.env.each do | key, value |
request_info['request']['env'][key.to_s] = value.to_s
end
session['request_info'] = request_info
end
# set the translator to the current user if we're logged in
I18n.config.translator = current_user
I18n.config.callback = self
# get the current confernece and set it globally
@conference = Conference.order("start_date DESC").first
# add some style sheets
@stylesheets ||= Array.new
# add the translations stylesheet if translating
@stylesheets << params[:controller] if params[:controller] == 'translations'
@_inline_scripts ||= []
@_inline_scripts << Rails.application.assets.find_asset('main.js').to_s
ActionMailer::Base.default_url_options = {:host => "#{request.protocol}#{request.host_with_port}"}
if request.post? && params[:action] == 'do_confirm'
halt_redirection!
end
@alt_lang_urls = {}
I18n.backend.enabled_locales.each do |locale|
locale = locale.to_s
@alt_lang_urls[locale] = view_context.url_for_locale(locale) # don't show the current locale
end
# give each environment a different icon and theme colour so that we can easily see where we are. See https://css-tricks.com/give-development-domain-different-favicon-production
@favicon = Rails.env.development? || Rails.env.preview? ? "favicon-#{Rails.env.to_s}.ico" : 'favicon.ico'
@theme_colour = Rails.env.preview? ? '#EF57B4' : (Rails.env.development? ? '#D89E59' : '#00ADEF')
# call the base method to detect the language
super
end
def home
@workshops = Workshop.where(:conference_id => @conference.id)
if @conference.workshop_schedule_published
@event_dlg = true
view_context.add_inline_script :schedule
get_scheule_data#(false)
# @events = Event.where(:conference_id => @conference.id)
# schedule = get_schedule_data
# @schedule = schedule[:schedule]
# @locations = Hash.new
# EventLocation.where(:conference_id => @conference.id).each do |l|
# @locations[l.id.to_s] = l
# end
# @day_parts = @conference.day_parts ? JSON.parse(@conference.day_parts) : {:morning => 0, :afternoon => 13, :evening => 18}
end
end
def policy
@is_policy_page = true
end
def robots
render :text => File.read("config/robots-#{Rails.env.production? ? 'live' : 'dev'}.txt"), :content_type => 'text/plain'
end
def humans
render :text => File.read("config/humans.txt"), :content_type => 'text/plain'
end
def self.set_host(host)
@@test_host = host
end
def self.set_location(location)
@@test_location = location
end
def self.get_location()
@@test_location
end
def do_404
error_404(status: 404)
end
def error_404(args = {})
params[:_original_action] = params[:action]
params[:action] = 'error-404'
@page_title = 'page_titles.404.Page_Not_Found'
@main_title = 'error.404.title'
render 'application/404', args
end
def do_403(template = nil)
@template = template
@page_title ||= 'page_titles.403.Access_Denied'
@main_title ||= @page_title
params[:_original_action] = params[:action]
params[:action] = 'error-403'
render 'application/permission_denied', status: 403
end
def error_500(exception = nil)
@page_title = 'page_titles.500.An_Error_Occurred'
@main_title = 'error.500.title'
params[:_original_action] = params[:action]
params[:action] = 'error-500'
render 'application/500', status: 500
end
def js_error
# send and email if this is production
report = "A JavaScript error has occurred on <code>#{params[:location]}</code>"
if params[:location] == params[:url]
report += " on line <code>#{params[:lineNumber]}</code>"
else
report += " in <code>#{params[:url]}:#{params[:lineNumber]}</code>"
end
begin
# log the error
logger.info exception.to_s
logger.info exception.backtrace.join("\n")
UserMailer.send_mail(:error_report) do
[
"A JavaScript error has occurred",
report,
params[:message],
nil,
request,
params,
current_user,
Time.now.strftime("%d/%m/%Y %H:%M")
]
end if Rails.env.preview? || Rails.env.production?
rescue exception2
logger.info exception2.to_s
logger.info exception2.backtrace.join("\n")
end
render json: {}
end
rescue_from ActiveRecord::RecordNotFound do |exception|
do_404
end
rescue_from ActiveRecord::PremissionDenied do |exception|
do_403
end
rescue_from AbstractController::ActionNotFound do |exception|
@banner_image = 'grafitti.jpg'
if current_user
@page_title = nil#'page_titles.Please_Login'
do_403 'not_a_translator'
#return
else
@page_title = 'page_titles.403.Please_Login'
do_403 'translator_login'
end
end
def locale_not_enabled!(locale = nil)
locale_not_available!(locale)
end
def locale_not_available!(locale = nil)
set_default_locale
params[:_original_action] = params[:action]
params[:action] = 'error-locale-not-available'
@page_title = 'page_titles.404.Locale_Not_Available'
@main_title_vars = { vars: { language: view_context.language_name(locale) } }
@main_title = 'error.locale_not_available.title'
render 'application/locale_not_available', status: 404
end
rescue_from StandardError do |exception|
# log the error
logger.info exception.to_s
logger.info exception.backtrace.join("\n")
# send and email if this is production
suppress(Exception) do
UserMailer.send_mail(:error_report) do
[
"An error has occurred in #{Rails.env}",
nil,
exception.to_s,
exception.backtrace.join("\n"),
request,
params,
current_user,
Time.now.strftime("%d/%m/%Y %H:%M")
]
end if Rails.env.preview? || Rails.env.production?
end
# raise the error if we are in development so that we can debug it
raise exception if Rails.env.development?
# show the error page
error_500 exception
end
def generate_confirmation(user, url, expiry = nil)
if user.is_a? String
user = User.find_by_email(user)
# if the user doesn't exist, just show them a 403
do_403 unless user.present?
end
expiry ||= (Time.now + 12.hours)
session[:confirm_uid] = user.id
unless user.locale.present?
user.locale = I18n.locale
user.save
end
# send the confirmation email and make sure it get sent as quickly as possible
UserMailer.send_mail :email_confirmation do
EmailConfirmation.create(user_id: user.id, expiry: expiry, url: url)
end
end
def user_settings
@conferences = Array.new
if logged_in?
Conference.all.each do | conference |
@conferences << conference if conference.host? current_user
end
end
@main_title = @page_title = 'page_titles.user_settings.Your_Account'
end
def contact
@main_title = @page_title = 'page_titles.contact.Contact_Us'
end
def contact_send
email_list = ['Godwin <goodgodwin@hotmail.com>']
if params[:reason] == 'conference'
@conference.organizations.each do | org |
org.users.each do | user |
email_list << user.named_email
end
end
end
UserMailer.send_mail(:contact) do
[
current_user || params[:email],
params[:subject],
params[:message],
email_list
]
end
request_info = session['request_info'] || { 'request' => request, 'params' => params }
UserMailer.send_mail(:contact_details) do
[
current_user || params[:email],
params[:subject],
params[:message],
request_info['request'],
request_info['params']
]
end
redirect_to contact_sent_path
end
def contact_sent
@main_title = @page_title = 'page_titles.contact.Contact_Us'
@sent = true
render 'contact'
end
def update_user_settings
return do_403 unless logged_in?
current_user.firstname = params[:name]
current_user.lastname = nil
current_user.languages = params[:languages].keys
current_user.is_subscribed = params[:email_subscribe].present?
current_user.save
redirect_to settings_path
end
def do_confirm(settings = nil)
settings ||= {:template => 'login_confirmation_sent'}
if params[:email]
# see if we've already sent the confirmation email and are just confirming
# the email address
if params[:token]
user = User.find_by_email(params[:email])
confirm(user)
return
end
user = User.find_by_email(params[:email])
unless user.present?
user = User.create(:email => params[:email], locale: I18n.locale)
end
# generate the confirmation, send the email and show the 403
referrer = params[:dest] || (request.present? && request.referer.present? ? request.referer.gsub(/^.*?\/\/.*?\//, '/') : settings_path)
generate_confirmation(params[:email], referrer)
template = 'login_confirmation_sent'
@page_title ||= 'page_titles.403.Please_Check_Email'
if (request.present? && request.referrer.present? && conference = /^\/conferences\/(\w+)\/register\/?$/.match(request.referrer.gsub(/^https?:\/\/.*?\//, '/')))
@this_conference = Conference.find_by!(slug: conference[1])
@banner_image = @this_conference.cover_url
template = 'conferences/email_confirm'
end
end
if request.post?
@banner_image ||= 'grafitti.jpg'
@page_title ||= 'page_titles.403.Please_Login'
do_403 (template || 'translator_login')
else
do_404
end
end
def confirm(uid = nil)
@confirmation = EmailConfirmation.find_by_token(params[:token])
unless @confirmation.present?
@token_not_found = true
return do_404
end
confirm_user = nil
if uid.is_a?(User)
confirm_user = uid
uid = confirm_user.id
end
# check to see if we were given a user id to confirm against
# if we were, make sure it was the same one
if (uid ||= (params[:uid] || session[:confirm_uid]))
if uid == @confirmation.user_id
session[:uid] = nil
confirm_user ||= User.find uid
auto_login(confirm_user)
else
@confirmation.delete
end
redirect_to (@confirmation.url || '/')
return
end
@banner_image = 'grafitti.jpg'
@page_title = 'page_titles.403.Please_Confirm_Email'
do_403 'login_confirm'
end
def translator_request
@banner_image = 'grafitti.jpg'
@page_title = 'page_titles.403.Translator_Request_Sent'
do_403 'translator_request_sent'
end
def user_logout
logout()
redirect_to (params[:url] || '/')
end
def login_user(u)
auto_login(u)
end
def on_translation_change(object, data, locale, translator_id)
translator = User.find(translator_id)
mailer = "#{object.class.table_name.singularize}_translated"
if object.respond_to?(:get_translators)
object.get_translators(data, locale).each do |id, user|
if user.id != current_user.id && user.id != translator_id
UserMailer.send_mail mailer, user.locale do
{ :args => [object, data, locale, user, translator] }
end
end
end
end
end
def on_translatable_content_change(object, data)
mailer = "#{object.class.table_name.singularize}_original_content_changed"
if object.respond_to?(:get_translators)
object.get_translators(data).each do |id, user|
if user.id != current_user.id
UserMailer.send_mail mailer, user.locale do
{ :args => [object, data, user, current_user] }
end
end
end
end
end
def i18n_exception(str, exception, locale, key)
# log it
logger.info "Missing translation found for: #{key}"
# send and email if this is production
begin
UserMailer.send_mail(:error_report) do
[
"A missing translation found in #{Rails.env}",
"<p>A translation for <code>#{key}</code> in <code>#{locale.to_s}</code> was found. The text that was rendered to the user was:</p><blockquote>#{str || 'nil'}</blockquote>",
exception.to_s,
nil,
request,
params,
current_user,
Time.now.strftime("%d/%m/%Y %H:%M")
]
end if Rails.env.preview? || Rails.env.production?
rescue exception2
logger.info exception2.to_s
logger.info exception2.backtrace.join("\n")
end
end
def get_block_data
conference = @this_conference || @conference
@workshop_blocks = conference.workshop_blocks || []
@block_days = []
day = conference.start_date
while day <= conference.end_date
@block_days << day.wday
day += 1.day
end
end
def get_scheule_data(do_analyze = true)
conference = @this_conference || @conference
@meals = Hash[(conference.meals || {}).map{ |k, v| [k.to_i, v] }].sort.to_h
@events = Event.where(:conference_id => conference.id).order(start_time: :asc)
@workshops = Workshop.where(:conference_id => conference.id).order(start_time: :asc)
@locations = {}
get_block_data
@schedule = {}
day_1 = conference.start_date.wday
@workshop_blocks.each_with_index do | info, block |
info['days'].each do | block_day |
day_diff = block_day.to_i - day_1
day_diff += 7 if day_diff < 0
day = (conference.start_date + day_diff.days).to_date
time = info['time'].to_f
@schedule[day] ||= { times: {}, locations: {} }
@schedule[day][:times][time] ||= {}
@schedule[day][:times][time][:type] = :workshop
@schedule[day][:times][time][:length] = info['length'].to_f
@schedule[day][:times][time][:item] = { block: block, workshops: {} }
end
end
@workshops.each do | workshop |
if workshop.block.present?
block = @workshop_blocks[workshop.block['block'].to_i]
day_diff = workshop.block['day'].to_i - day_1
day_diff += 7 if day_diff < 0
day = (conference.start_date + day_diff.days).to_date
if @schedule[day].present? && @schedule[day][:times].present? && @schedule[day][:times][block['time'].to_f].present?
@schedule[day][:times][block['time'].to_f][:item][:workshops][workshop.event_location_id] = { workshop: workshop, status: { errors: [], warnings: [], conflict_score: nil } }
@schedule[day][:locations][workshop.event_location_id] ||= workshop.event_location if workshop.event_location.present?
end
end
end
@meals.each do | time, meal |
day = meal['day'].to_date
time = meal['time'].to_f
@schedule[day] ||= {}
@schedule[day][:times] ||= {}
@schedule[day][:times][time] ||= {}
@schedule[day][:times][time][:type] = :meal
@schedule[day][:times][time][:length] = (meal['length'] || 1.0).to_f
@schedule[day][:times][time][:item] = meal
end
@events.each do | event |
day = event.start_time.midnight.to_date
time = event.start_time.hour.to_f + (event.start_time.min / 60.0)
@schedule[day] ||= {}
@schedule[day][:times] ||= {}
@schedule[day][:times][time] ||= {}
@schedule[day][:times][time][:type] = :event
@schedule[day][:times][time][:length] = (event.end_time - event.start_time) / 3600.0
@schedule[day][:times][time][:item] = event
end
@schedule = @schedule.sort.to_h
@schedule.each do | day, data |
@schedule[day][:times] = data[:times].sort.to_h
end
@schedule.each do | day, data |
last_event = nil
data[:times].each do | time, time_data |
if last_event.present?
@schedule[day][:times][last_event][:next_event] = time
end
last_event = time
end
@schedule[day][:num_locations] = (data[:locations] || []).size
end
@schedule.deep_dup.each do | day, data |
data[:times].each do | time, time_data |
if time_data[:next_event].present? || time_data[:length] > 0.5
span = 0.5
length = time_data[:next_event].present? ? time_data[:next_event] - time : time_data[:length]
while span < length
@schedule[day][:times][time + span] ||= {
type: (span >= time_data[:length] ? :empty : :nil),
length: 0.5
}
span += 0.5
end
end
end
end
@schedule = @schedule.sort.to_h
return unless do_analyze
@schedule.each do | day, data |
@schedule[day][:times] = data[:times].sort.to_h
@schedule[day][:locations][0] = :add if (@schedule[day][:locations] || []).size > 0
data[:times].each do | time, time_data |
if time_data[:type] == :workshop && time_data[:item].present? && time_data[:item][:workshops].present?
ids = time_data[:item][:workshops].keys
(0..ids.length).each do | i |
if time_data[:item][:workshops][ids[i]].present?
workshop_i = time_data[:item][:workshops][ids[i]][:workshop]
conflicts = {}
(i+1..ids.length).each do | j |
workshop_j = time_data[:item][:workshops][ids[j]].present? ? time_data[:item][:workshops][ids[j]][:workshop] : nil
if workshop_i.present? && workshop_j.present?
workshop_i.active_facilitators.each do | facilitator_i |
workshop_j.active_facilitators.each do | facilitator_j |
if facilitator_i.id == facilitator_j.id
@schedule[day][:times][time][:status] ||= {}
@schedule[day][:times][time][:item][:workshops][ids[j]][:status][:errors] << {
name: :common_facilitator,
facilitator: facilitator_i,
workshop: workshop_i,
i18nVars: {
facilitator_name: facilitator_i.name,
workshop_title: workshop_i.title
}
}
end
end
end
end
end
(0..ids.length).each do | j |
workshop_j = time_data[:item][:workshops][ids[j]].present? ? time_data[:item][:workshops][ids[j]][:workshop] : nil
if workshop_i.present? && workshop_j.present? && workshop_i.id != workshop_j.id
workshop_i.interested.each do | interested_i |
workshop_j.interested.each do | interested_j |
conflicts[interested_i.id] ||= true
end
end
end
end
location = workshop_i.event_location || EventLocation.new
needs = JSON.parse(workshop_i.needs || '[]').map &:to_sym
amenities = JSON.parse(location.amenities || '[]').map &:to_sym
needs.each do | need |
@schedule[day][:times][time][:item][:workshops][ids[i]][:status][:errors] << {
name: :need_not_available,
need: need,
location: location,
workshop: workshop_i,
i18nVars: {
need: need.to_s,
location: location.title,
workshop_title: workshop_i.title
}
} unless amenities.include? need
end
@schedule[day][:times][time][:item][:workshops][ids[i]][:status][:conflict_score] = workshop_i.interested.present? ? (conflicts.length / workshop_i.interested.size) : 0
end
end
end
end
end
end
end

1841
app/controllers/conferences_controller.rb

File diff suppressed because it is too large

2
app/helpers/application_helper.rb

@ -822,7 +822,7 @@ module ApplicationHelper
locations = []
if @this_conference.event_locations.present?
@this_conference.event_locations.each do | location |
locations << [ location.title, location.id ]
locations << [ location.title, location.id ] unless ((args[:invalid_locations] || []).include? location.id)
end
end
selectfield :event_location, value, locations, args

125
app/views/conferences/admin/_schedule.html.haml

@ -1,9 +1,9 @@
- add_inline_script :schedule
- conference = @this_conference || @conference
- if conference.event_locations.blank? && @entire_page
.warning-info=_'articles.admin.schedule.no_locations_warning'
- else
- if @entire_page
- add_inline_script :schedule
= form_tag administration_update_path(conference.slug, :schedule) do
- if conference.workshop_schedule_published
%p=_'articles.conference_registration.paragraphs.admin.schedule.published', :p
@ -16,7 +16,7 @@
- @schedule.each do | day, data |
%h4=date(day, :weekday)
%table.schedule{class: [data[:locations].present? ? 'has-locations' : 'no-locations', "locations-#{data[:num_locations]}"]}
- if data[:locations].present?
- if data[:locations].present? && data[:locations].values.first != :add
%thead
%tr
%th.corner
@ -29,40 +29,36 @@
- rowspan = (time_data[:length] * 2).to_i
%th=time(time)
- if time_data[:type] == :workshop
- if time_data[:item][:workshops].present?
- data[:locations].each do | id, location |
- if time_data[:item][:workshops][id].present?
- workshop = time_data[:item][:workshops][id][:workshop]
- status = time_data[:item][:workshops][id][:status]
- else
- workshop = status = nil
%td{class: [time_data[:type], workshop.present? ? :filled : :open], rowspan: rowspan, data: workshop.present? ? nil : { block: (time_data[:item][:block] + 1), day: day }}
- if workshop.present? && workshop.event_location.present?
= link_to off_screen(workshop.title), view_workshop_path(@conference.slug, workshop.id), class: 'event-detail-link'
%template.event-details{data: { href: view_workshop_path(@conference.slug, workshop.id) }}
%h1.title=workshop.title
%p.address
= workshop.event_location.title + _!(': ')
= location_link workshop.event_location
.workshop-description= richtext workshop.info, 1
.title=workshop.title
- if @can_edit
= form_tag administration_update_path(conference.slug, :schedule), class: 'js-xhr' do
.status
.conflict-score
%span.title Conflict Score:
%span.value="#{status[:conflict_score] * 100.0}%"
- if status[:errors].present?
.errors
- status[:errors].each do | error |
.error=_"errors.messages.schedule.#{error[:name].to_s}", vars: error[:i18nVars]
= hidden_field_tag :id, workshop.id
= button_tag :deschedule, value: :deschedule_workshop, class: [:delete, :small]
- elsif @can_edit
.title="Block #{time_data[:item][:block] + 1}"
- else
%td{class: [time_data[:type], :open], rowspan: rowspan, colspan: data[:locations].present? ? data[:locations].size : 1, data: { block: (time_data[:item][:block] + 1), day: day }}
- if @can_edit
- data[:locations].each do | id, location |
- if time_data[:item][:workshops][id].present?
- workshop = time_data[:item][:workshops][id][:workshop]
- status = time_data[:item][:workshops][id][:status]
- else
- workshop = status = nil
%td{class: [time_data[:type], workshop.present? ? :filled : :open], rowspan: rowspan, data: workshop.present? ? nil : { block: time_data[:item][:block], day: day, location: id }}
- if workshop.present? && workshop.event_location.present?
= link_to view_workshop_path(@conference.slug, workshop.id), class: 'event-detail-link' do
.details
.title=workshop.title
%template.event-details{data: { href: view_workshop_path(@conference.slug, workshop.id) }}
%h1.title=workshop.title
%p.address
= workshop.event_location.title + _!(': ')
= location_link workshop.event_location
.workshop-description= richtext workshop.info, 1
- if @can_edit
= form_tag administration_update_path(conference.slug, :schedule), class: 'deschedule-workshop' do
.status
.conflict-score
%span.title Conflict Score:
%span.value="#{status[:conflict_score] * 100.0}%"
- if status[:errors].present?
.errors
- status[:errors].each do | error |
.error=_"errors.messages.schedule.#{error[:name].to_s}", vars: error[:i18nVars]
= hidden_field_tag :id, workshop.id
= button_tag :deschedule, value: :deschedule_workshop, class: [:delete, :small]
- elsif @can_edit
.title="Block #{time_data[:item][:block] + 1}"
%td.status{rowspan: rowspan}
- if time_data[:status].present? && time_data[:status][:errors].present?
@ -75,63 +71,30 @@
- when :meal
- location = EventLocation.where(id: time_data[:item]['location'].to_i).first
- if location.present?
%a.event-detail-link=off_screen(time_data[:item]['title'])
%a.event-detail-link
.details
.title= time_data[:item]['title']
.location= location.title
%template.event-details
%h1.title=time_data[:item]['title']
%p.address
= location.title + _!(': ')
= location_link location
.title= time_data[:item]['title']
.location= location.title
- when :event
- if time_data[:item].event_location.present?
%a.event-detail-link=off_screen(time_data[:item][:title])
%a.event-detail-link
.details
.title= time_data[:item][:title]
.location= time_data[:item].event_location.title
%template.event-details
%h1.title=time_data[:item][:title]
%p.address
= time_data[:item].event_location.title + _!(': ')
= location_link time_data[:item].event_location
= richtext time_data[:item][:info], 1
.title= time_data[:item][:title]
.location= time_data[:item].event_location.title
%td.status{rowspan: rowspan}
- if @entire_page
%ul.workshops-to-schedule
- @workshops.each do | workshop |
%li{id: "workshop-#{workshop.id}", class: workshop.block.present? ? 'booked' : 'not-booked'}
%h4.title= workshop.title
= form_tag administration_update_path(conference.slug, :schedule), class: 'js-xhr' do
.already-booked
.field-error='This block is already booked'
.workshop-description
.details
= data_set(:h5, 'articles.workshops.headings.interested_count') do
= workshop.interested_count
= data_set(:h5, 'articles.workshops.headings.facilitators') do
- facilitators = []
- workshop.active_facilitators.each do | facilitator |
- facilitators << facilitator.name
= facilitators.join ', '
= data_set(:h5, 'articles.workshops.headings.needs') do
- needs = []
- JSON.parse(workshop.needs || '[]').each do | need |
- needs << (_"workshop.options.needs.#{need}")
= _!(needs.join ', ')
= data_set(:h5, 'articles.workshops.headings.theme') do
= Workshop.all_themes.include?((workshop.theme || '').to_sym) ? (_"workshop.options.theme.#{workshop.theme}") : workshop.theme
= data_set(:h5, 'articles.workshops.headings.space') do
= workshop.space.present? ? (_"workshop.options.space.#{workshop.space}") : ''
= data_set(:h5, 'forms.labels.generic.info') do
= link_info_dlg truncate(workshop.info), (richtext workshop.info.html_safe), workshop.title
- if workshop.notes.present? && strip_tags(workshop.notes).length > 0
= data_set(:h5, 'forms.labels.generic.notes') do
= link_info_dlg truncate(workshop.notes), (richtext workshop.notes.html_safe), workshop.title
= hidden_field_tag :id, workshop.id
.drop-downs
= location_select workshop.event_location_id, small: true
= block_select workshop.block.present? ? "#{workshop.block['day']}:#{workshop.block['block']}" : nil, small: true
.actions.next-prev
= button_tag :deschedule, value: :deschedule_workshop, class: [:delete, 'booked-only', :small]
= button_tag :reschedule, value: :schedule_workshop, class: [:secondary, 'booked-only', :small]
= button_tag :schedule_workshop, value: :schedule_workshop, class: ['not-booked-only', :small]
#workshop-selector
= form_tag administration_update_path(@this_conference.slug, :schedule), class: 'workshop-dlg', id: 'workshop-table-form' do
%h3 Select a Workshop
#table

Loading…
Cancel
Save