From 7a04f3582f00e1a867848af75e1b19b4ca59f824 Mon Sep 17 00:00:00 2001 From: James Mason Date: Sat, 29 Dec 2018 15:36:17 -0800 Subject: [PATCH] Remove travel schedule from registration (cherry picked from commit d18cc02f0185df39bb4213d8a63a955dfb433dcb) Re: https://github.com/openSUSE/osem/issues/2333 --- CHANGES.md | 6 ++++ app/assets/javascripts/osem-datepickers.js | 34 ------------------- .../admin/registrations_controller.rb | 2 +- .../conference_registrations_controller.rb | 2 +- app/datatables/registration_datatable.rb | 4 --- app/models/registration.rb | 15 -------- app/views/admin/registrations/index.html.haml | 18 ---------- app/views/admin/registrations/index.pdf.prawn | 6 +--- .../admin/registrations/index.xlsx.axlsx | 5 +-- .../conference_registrations/_form.html.haml | 1 + .../_registration_info.html.haml | 6 ---- .../conference_registrations/show.html.haml | 22 ------------ ...ve_arrival_departure_from_registrations.rb | 6 ++++ db/schema.rb | 4 +-- ...conference_registration_controller_spec.rb | 20 ++++++----- spec/models/registration_spec.rb | 22 ------------ 16 files changed, 29 insertions(+), 144 deletions(-) create mode 100644 db/migrate/20181229233811_remove_arrival_departure_from_registrations.rb diff --git a/CHANGES.md b/CHANGES.md index db20a234..432cdcdf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,12 @@ Not release yet... ## Update from 1.0 +### Dropped travel information +We have dropped input and storage of travel schedules for event registrants. If +you would like to continue to collect travel schedules, please create a custom +survey for this purpose. +_Please be aware that existing travel data will be destroyed during migration._ + ### Multiple Schedules A conference can have multiple schedules now so it's easier for organizers to test schedules and collaborate on different versions. diff --git a/app/assets/javascripts/osem-datepickers.js b/app/assets/javascripts/osem-datepickers.js index b907aa0c..c11c61a9 100644 --- a/app/assets/javascripts/osem-datepickers.js +++ b/app/assets/javascripts/osem-datepickers.js @@ -13,40 +13,6 @@ $(function () { format: 'YYYY-MM-DD HH:mm' }); - $("#registration-arrival-datepicker").datetimepicker({ - useCurrent: false, - stepping: 15, - sideBySide: true, - format: "YYYY-MM-DD HH:mm", - // current_date <= arrival_date <= end_date - maxDate : $("#registration-arrival-datepicker").attr('end_date'), - minDate : today - }); - - $("#registration-departure-datepicker").datetimepicker({ - useCurrent: false, - stepping: 15, - sideBySide: true, - format: "YYYY-MM-DD HH:mm", - // departure_date > start_date - minDate : $("#registration-arrival-datepicker").attr('start_date') - }); - - $("#registration-arrival-datepicker").on("dp.change",function (e) { - // departure_date > start_date,arrival_date - if ((new Date(e.date).getTime()) > (new Date($("#registration-arrival-datepicker").attr('start_date')).getTime())){ - $('#registration-departure-datepicker').data("DateTimePicker").minDate(e.date); - } - else{ - $('#registration-departure-datepicker').data("DateTimePicker").minDate($("#registration-arrival-datepicker").attr('start_date')); - } - }); - - // departure_date >= arrival_date - $("#registration-departure-datepicker").on("dp.change",function (e) { - $('#registration-arrival-datepicker').data("DateTimePicker").maxDate(e.date); - }); - $("#conference-start-datepicker").datetimepicker({ useCurrent: false, format: "YYYY-MM-DD", diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 89c4d069..ef94ae2e 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -82,7 +82,7 @@ module Admin def registration_params params.require(:registration).permit( - :user_id, :conference_id, :arrival, :departure, :attended, + :user_id, :conference_id, :attended, :volunteer, :other_special_needs, :accepted_code_of_conduct, vchoice_ids: [], qanswer_ids: [], qanswers_attributes: [], event_ids: [] ) diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index 5c17d8dc..887d0ce1 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -110,7 +110,7 @@ class ConferenceRegistrationsController < ApplicationController def registration_params params.require(:registration) .permit( - :conference_id, :arrival, :departure, + :conference_id, :volunteer, :accepted_code_of_conduct, vchoice_ids: [], qanswer_ids: [], qanswers_attributes: [], diff --git a/app/datatables/registration_datatable.rb b/app/datatables/registration_datatable.rb index bdd97e72..a20fe3af 100644 --- a/app/datatables/registration_datatable.rb +++ b/app/datatables/registration_datatable.rb @@ -10,8 +10,6 @@ class RegistrationDatatable < AjaxDatatablesRails::Base roles: { source: 'Role.name' }, email: { source: 'User.email' }, accepted_code_of_conduct: { source: 'Registration.accepted_code_of_conduct', searchable: false }, - arrival: { source: 'Registration.arrival', searchable: false }, - departure: { source: 'Registration.departure', searchable: false }, actions: { source: 'Registration.id', searchable: false, orderable: false } } end @@ -36,8 +34,6 @@ class RegistrationDatatable < AjaxDatatablesRails::Base roles: conference_role_titles(record.user), email: record.email, accepted_code_of_conduct: !!record.accepted_code_of_conduct, # rubocop:disable Style/DoubleNegation - arrival: record.arrival&.utc, - departure: record.departure&.utc, questions: {}, edit_url: edit_admin_conference_registration_path(conference, record), DT_RowId: record.id diff --git a/app/models/registration.rb b/app/models/registration.rb index 84a9aba0..759003fd 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -28,8 +28,6 @@ class Registration < ApplicationRecord validates :user_id, uniqueness: { scope: :conference_id, message: 'already Registered!' } validate :registration_limit_not_exceed, on: :create - validate :registration_to_events_only_if_present - validates :accepted_code_of_conduct, acceptance: { if: -> { conference.try(:code_of_conduct).present? } } @@ -48,19 +46,6 @@ class Registration < ApplicationRecord private - ## - # If the user registers to attend events that are already scheduled, - # only allow registration to events if the user will be present - # (based on arrival and departure attributes) - # No validation if arrival/departure attributes are empty - def registration_to_events_only_if_present - if (arrival || departure) && events.pluck(:start_time).any? - errors.add(:arrival, 'is too late! You cannot register for events that take place before your arrival') if events.pluck(:start_time).compact.map { |x| x < arrival }.any? - - errors.add(:departure, 'is too early! You cannot register for events that take place after your departure') if events.pluck(:start_time).compact.map { |x| x > departure }.any? - end - end - def subscribe_to_conference Subscription.create(conference_id: conference.id, user_id: user.id) end diff --git a/app/views/admin/registrations/index.html.haml b/app/views/admin/registrations/index.html.haml index 8ea544d8..09f674e9 100644 --- a/app/views/admin/registrations/index.html.haml +++ b/app/views/admin/registrations/index.html.haml @@ -30,8 +30,6 @@ %th{ width: '0' } E-Mail %th{ width: '0' } %abbr{ title: 'Code of Conduct' } CoC - %th{ width: '0' } Arrival - %th{ width: '0' } Departure %th{ width: '0' } Actions %tbody @@ -81,22 +79,6 @@ "className": "code-of-conduct text-center", "searchable": false }, - { - "data": "arrival", - "searchable": false, - "render": function(data, type, row) { - if (data) { return moment(data).format('ll LT'); } - return ''; - } - }, - { - "data": "departure", - "searchable": false, - "render": function(data, type, row) { - if (data) { return moment(data).format('ll LT'); } - return ''; - } - }, { "data": null, "className": "actions", diff --git a/app/views/admin/registrations/index.pdf.prawn b/app/views/admin/registrations/index.pdf.prawn index d7c97ef2..3edebf04 100644 --- a/app/views/admin/registrations/index.pdf.prawn +++ b/app/views/admin/registrations/index.pdf.prawn @@ -4,9 +4,7 @@ prawn_document(force_download: true, filename: @pdf_filename, page_layout: :land 'Name', 'Nickname', 'Affiliation', - 'Email', - 'Arrival Date', - 'Departure Date'] + 'Email'] @conference.questions.each do |question| header_array << question.title end @@ -19,8 +17,6 @@ prawn_document(force_download: true, filename: @pdf_filename, page_layout: :land row << registration.nickname row << registration.affiliation row << registration.email - row << registration.arrival.to_s || '' - row << registration.departure.to_s || '' @conference.questions.each do |question| qa = registration.qanswers.find_by(question: question) diff --git a/app/views/admin/registrations/index.xlsx.axlsx b/app/views/admin/registrations/index.xlsx.axlsx index ee49eb4d..a95c163e 100644 --- a/app/views/admin/registrations/index.xlsx.axlsx +++ b/app/views/admin/registrations/index.xlsx.axlsx @@ -3,7 +3,7 @@ wb = xlsx_package.workbook wb.add_worksheet(name: 'registrations') do |sheet| bold_style = wb.styles.add_style(b: true) - row = ['Attended', 'Name', 'Nickname', 'Affilιation', 'Email', 'Arrival', 'Departure'] + row = ['Attended', 'Name', 'Nickname', 'Affilιation', 'Email'] @conference.questions.each do |question| row << question.title @@ -18,8 +18,6 @@ wb.add_worksheet(name: 'registrations') do |sheet| row << registration.nickname row << registration.affiliation row << registration.email - row << registration.arrival.to_s - row << registration.departure.to_s @conference.questions.each do |question| qa = registration.qanswers.find_by(question: question) answer = ( qa ? qa.answer.title : '' ) @@ -30,4 +28,3 @@ wb.add_worksheet(name: 'registrations') do |sheet| sheet.add_row row end end - diff --git a/app/views/conference_registrations/_form.html.haml b/app/views/conference_registrations/_form.html.haml index 971a613f..1dd5f175 100644 --- a/app/views/conference_registrations/_form.html.haml +++ b/app/views/conference_registrations/_form.html.haml @@ -22,6 +22,7 @@ = render partial: 'devise/shared/sign_up_form_embedded' = render partial: 'registration_info', locals: { f: f } + = f.input :conference_id, as: :hidden, value: @conference.id .row .col-md-12 %p.pull-right diff --git a/app/views/conference_registrations/_registration_info.html.haml b/app/views/conference_registrations/_registration_info.html.haml index a81f385d..5fdd9bf4 100644 --- a/app/views/conference_registrations/_registration_info.html.haml +++ b/app/views/conference_registrations/_registration_info.html.haml @@ -24,10 +24,4 @@ (Scheduled on: #{event.time.to_date}) %br - - -= f.inputs 'Your Travel Info' do - = f.input :arrival, as: :string, label: 'Your arrival time', hint: "Leave blank if not sure", input_html: { value: (f.object.arrival.to_formatted_s(:db_without_seconds) unless f.object.arrival.nil?), id: 'registration-arrival-datepicker',start_date: @conference.start_date,end_date: @conference.end_date } - = f.input :departure, as: :string, label: 'Your departure time', hint: "Leave blank if not sure", input_html: { value: (f.object.departure.to_formatted_s(:db_without_seconds) unless f.object.departure.nil?), id: 'registration-departure-datepicker' } - = render 'conferences/code_of_conduct', organization: @conference.organization diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index afb5b9e0..d060e412 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -33,28 +33,6 @@ data: { toggle: 'modal', target: '#modal-code-of-conduct'} = render 'conferences/code_of_conduct', organization: @conference.organization - .row - .col-md-12 - %h4 - %span.fa-stack - %i.fa.fa-square-o.fa-stack-2x - %i.fa.fa-plane.fa-stack-1x - Travel Schedule - %ul - %li - - if @registration.arrival.present? - arrive at - %strong - = @registration.arrival.strftime('%A, %B %-d. %Y %H:%M') - - else - You haven't scheduled your arrival - %li - - if @registration.departure.present? - depart at - %strong - = @registration.departure.strftime('%A, %B %-d. %Y %H:%M') - - else - You haven't scheduled your departure - if @conference.surveys.for_registration.any? .row .col-md-12 diff --git a/db/migrate/20181229233811_remove_arrival_departure_from_registrations.rb b/db/migrate/20181229233811_remove_arrival_departure_from_registrations.rb new file mode 100644 index 00000000..18f1398d --- /dev/null +++ b/db/migrate/20181229233811_remove_arrival_departure_from_registrations.rb @@ -0,0 +1,6 @@ +class RemoveArrivalDepartureFromRegistrations < ActiveRecord::Migration[5.0] + def change + remove_column :registrations, :arrival, :datetime + remove_column :registrations, :departure, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 2cb9ac88..2ad25c7e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20181113195810) do +ActiveRecord::Schema.define(version: 20181229233811) do create_table "answers", force: :cascade do |t| t.string "title" @@ -364,8 +364,6 @@ ActiveRecord::Schema.define(version: 20181113195810) do create_table "registrations", force: :cascade do |t| t.integer "conference_id" - t.datetime "arrival" - t.datetime "departure" t.datetime "created_at" t.datetime "updated_at" t.text "other_special_needs" diff --git a/spec/controllers/conference_registration_controller_spec.rb b/spec/controllers/conference_registration_controller_spec.rb index f2849c27..964acaac 100644 --- a/spec/controllers/conference_registration_controller_spec.rb +++ b/spec/controllers/conference_registration_controller_spec.rb @@ -290,14 +290,15 @@ describe ConferenceRegistrationsController, type: :controller do before do @registration = create(:registration, conference: conference, - user: user, - arrival: Date.new(2014, 04, 25)) + user: user) end context 'updates successfully' do before do - patch :update, params: { registration: attributes_for(:registration, arrival: Date.new(2014, 04, 29)), - conference_id: conference.short_title } + patch :update, params: { + registration: attributes_for(:registration, volunteer: true), + conference_id: conference.short_title + } end it 'redirects to registration show path' do @@ -309,16 +310,17 @@ describe ConferenceRegistrationsController, type: :controller do end it 'updates the registration' do - @registration.reload - expect(@registration.arrival).to eq Date.new(2014, 04, 29) + expect{ @registration.reload }.to change(@registration, :updated_at) end end context 'update fails' do before do allow_any_instance_of(Registration).to receive(:update_attributes).and_return(false) - patch :update, params: { registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)), - conference_id: conference.short_title } + patch :update, params: { + registration: attributes_for(:registration, volunteer: true), + conference_id: conference.short_title + } end it 'renders edit template' do @@ -331,7 +333,7 @@ describe ConferenceRegistrationsController, type: :controller do it 'does not update the registration' do @registration.reload - expect(@registration.arrival).to eq Date.new(2014, 04, 25) + expect { @registration.reload }.not_to change(@registration, :updated_at) end end end diff --git a/spec/models/registration_spec.rb b/spec/models/registration_spec.rb index 9f710416..d6c86838 100644 --- a/spec/models/registration_spec.rb +++ b/spec/models/registration_spec.rb @@ -51,26 +51,4 @@ describe Registration do expect(subject).to receive(:send_registration_mail) end end - - describe 'registration_to_events_only_if_present' do - context 'valid' do - it 'when user registers for events happening while user is at the conference' do - registration.arrival = conference.start_date - registration.departure = conference.end_date - registration.events << create(:event, program: conference.program, start_time: conference.end_date) - - expect(registration.valid?).to eq true - end - end - - context 'invalid' do - it 'when user registers for events happening while user is not at the conference' do - registration.arrival = conference.start_date - registration.departure = conference.start_date - registration.events << create(:event, program: conference.program, start_time: conference.end_date) - - expect(registration.valid?).to eq false - end - end - end end