From e57bfb28e4ee5043c012f079988cbf3de9b5e327 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 19 Aug 2017 08:35:18 -0700 Subject: [PATCH] Deschedule workshops when blocks are removed --- Gemfile | 2 +- app/controllers/application_controller.rb | 2 +- .../conference_administration_controller.rb | 7 +++++-- app/controllers/conferences_controller.rb | 7 +++++++ app/views/conferences/register.html.haml | 2 +- config/locales/en.yml | 1 + config/routes.rb | 5 +++++ db/schema.rb | 12 +++++++++++- 8 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 43a7aac..89c16d4 100644 --- a/Gemfile +++ b/Gemfile @@ -43,7 +43,7 @@ gem 'redcarpet' gem 'to_spreadsheet', git: 'https://github.com/glebm/to_spreadsheet.git' group :development do - gem 'better_errors' + gem 'better_errors', '2.2.0' gem 'binding_of_caller' gem 'meta_request' diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f352be1..c0f4b18 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -423,7 +423,7 @@ class ApplicationController < BaseController 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? + if block.present? && @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 diff --git a/app/controllers/conference_administration_controller.rb b/app/controllers/conference_administration_controller.rb index 741b2ca..e0a6666 100644 --- a/app/controllers/conference_administration_controller.rb +++ b/app/controllers/conference_administration_controller.rb @@ -491,12 +491,12 @@ class ConferenceAdministrationController < ApplicationController end def administrate_locations - @locations = EventLocation.where(:conference_id => @this_conference.id) + @locations = EventLocation.where(conference_id: @this_conference.id) end def administrate_events @event = Event.new(locale: I18n.locale) - @events = Event.where(:conference_id => @this_conference.id) + @events = Event.where(conference_id: @this_conference.id) @day = nil @time = nil @length = 1.5 @@ -1409,6 +1409,7 @@ class ConferenceAdministrationController < ApplicationController when 'delete' location = EventLocation.find_by! id: params[:id].to_i, conference_id: @this_conference.id location.destroy + @this_conference.validate_workshop_blocks when 'create' empty_param = get_empty(params, [:title, :address, :space]) if empty_param.present? @@ -1506,11 +1507,13 @@ class ConferenceAdministrationController < ApplicationController @this_conference.save set_success_message :block_saved end + @this_conference.validate_workshop_blocks return false when 'delete_block' @this_conference.workshop_blocks ||= [] @this_conference.workshop_blocks.delete_at(params[:workshop_block].to_i) @this_conference.save + @this_conference.validate_workshop_blocks set_success_message :block_deleted return false end diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index fc04a8d..d7029b3 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -109,6 +109,13 @@ class ConferencesController < ApplicationController end end + def survey + return do_404 + # set_conference + # do_403 unless @this_conference.is_public || @this_conference.host?(current_user) + # do_403 if @this_conference.registration_open + end + helper_method :registration_complete? def registration_steps(conference = nil) diff --git a/app/views/conferences/register.html.haml b/app/views/conferences/register.html.haml index 5f0f11a..5ac336d 100644 --- a/app/views/conferences/register.html.haml +++ b/app/views/conferences/register.html.haml @@ -1,4 +1,4 @@ -= render :partial => 'conferences/page_header', :locals => {:page_key => 'Conference_Registration'} += render partial: 'conferences/page_header', locals: {page_key: 'Conference_Registration'} - if @warnings.present? = row class: 'warnings', tag: :ul do - @warnings.each do |warning| diff --git a/config/locales/en.yml b/config/locales/en.yml index 89eb1ce..e260243 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1298,6 +1298,7 @@ en: success: messages: admin: + block_deleted: Workshop block successfully removed block_saved: Workshop block saved successfully administrators: Organizations updated dates: Conference dates updated successfully diff --git a/config/routes.rb b/config/routes.rb index 71da3d6..9d8e78b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,11 @@ BikeBike::Application.routes.draw do get 'check_in/:id' => 'conference_administration#check_in', as: :check_in, constraints: { id: /.+/ } end + scope :survey do + root 'conferences#survey', as: :conference_survey + post 'save' => 'conferences#save_survey', as: :conference_survey_save + end + # Workshops scope :workshops do root 'workshops#workshops', as: :workshops diff --git a/db/schema.rb b/db/schema.rb index 1f6fe54..edf5f7f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170719024801) do +ActiveRecord::Schema.define(version: 20170817000540) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -110,6 +110,7 @@ ActiveRecord::Schema.define(version: 20170719024801) do t.boolean "is_participant" t.boolean "is_volunteer" t.string "confirmation_token" + t.binary "data_old" t.string "email" t.boolean "complete" t.boolean "completed" @@ -131,6 +132,7 @@ ActiveRecord::Schema.define(version: 20170719024801) do t.json "housing_data" t.integer "city_id" t.json "data" + t.boolean "survey_taken" end create_table "conference_types", force: :cascade do |t| @@ -391,6 +393,14 @@ ActiveRecord::Schema.define(version: 20170719024801) do add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", unique: true, using: :btree add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree + create_table "surveys", force: :cascade do |t| + t.string "name" + t.string "version" + t.json "results" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "translation_followers", force: :cascade do |t| t.string "key" t.integer "user_id"