diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index a372f44..01b02af 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -123,13 +123,13 @@ class ConferencesController < ApplicationController @errors[:name] = :empty end - if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? && (l = Geocoder.search(params[:location], language: 'en')).present? - corrected = view_context.location(l.first, @this_conference.locale) + if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? + city = City.search(params[:location]) - if corrected.present? - @registration.city = corrected - if params[:location].gsub(/[\s,]/, '').downcase != @registration.city.gsub(/[\s,]/, '').downcase - @warnings << view_context._('warnings.messages.location_corrected', vars: {original: params[:location], corrected: corrected}) + if city.present? + @registration.city_id = city.id + if params[:location].gsub(/[\s,]/, '').downcase != view_context.location(city).gsub(/[\s,]/, '').downcase + @warnings << view_context._('warnings.messages.location_corrected', vars: {original: params[:location], corrected: view_context.location(city)}) end else @errors[:location] = :unknown @@ -330,7 +330,7 @@ class ConferencesController < ApplicationController steps -= [:questions] unless status == :open steps -= [:payment] unless status == :open && conference.paypal_email_address.present? && conference.paypal_username.present? && conference.paypal_password.present? && conference.paypal_signature.present? if @registration.present? - if view_context.same_city?(@registration.city, view_context.location(conference.location, conference.locale)) + if @registration.city_id == conference.city_id steps -= [:questions] # if this is a housing provider that is not attending the conference, remove these steps diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 89bf08f..e26f76d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -239,7 +239,7 @@ module ApplicationHelper def registration_steps(conference = @conference) { pre: [:policy, :contact_info, :workshops], - open: [:policy, :contact_info, :questions, :payment, :workshops] + open: [:policy, :contact_info, :questions, :hosting, :payment, :workshops] }[@this_conference.registration_status] end diff --git a/app/helpers/registration_helper.rb b/app/helpers/registration_helper.rb index 444c41c..b2695da 100644 --- a/app/helpers/registration_helper.rb +++ b/app/helpers/registration_helper.rb @@ -7,6 +7,13 @@ module RegistrationHelper disable_steps = false completed_steps = registration.steps_completed || [] registration_complete = registration_complete?(registration) + + if registration.city_id == registration.conference.city_id + steps -= [:questions] + else + steps -= [:hosting] + end + steps.each do | step | # disable the step if we've already found an incomplete step enabled = !disable_steps || registration_complete diff --git a/app/models/conference_registration.rb b/app/models/conference_registration.rb index 369de28..c34ed0a 100644 --- a/app/models/conference_registration.rb +++ b/app/models/conference_registration.rb @@ -29,6 +29,10 @@ class ConferenceRegistration < ActiveRecord::Base [:vegan, :smoking, :pets, :quiet] end + def city + city_id.present? ? City.find(city_id) : nil + end + def status(was = false) return :unregistered if user.nil? || user.firstname.blank? || self.send(was ? :city_was : :city).blank? return :registered if self.send(was ? :housing_was : :housing).present? || (self.send(was ? :can_provide_housing_was : :can_provide_housing) && (self.send(was ? :housing_data_was : :housing_data) || {})['availability'].present?) diff --git a/app/views/conferences/_contact_info.html.haml b/app/views/conferences/_contact_info.html.haml index ceb91be..d8a69f8 100644 --- a/app/views/conferences/_contact_info.html.haml +++ b/app/views/conferences/_contact_info.html.haml @@ -2,7 +2,7 @@ %p=_'articles.conference_registration.paragraphs.Contact_Info', :s, 2 = form_tag register_path(@this_conference.slug) do = textfield :name, @name, required: true, heading: 'articles.conference_registration.headings.name', big: true - = textfield :location, (params[:location] || @registration.city || location(lookup_ip_location)), required: true, heading: 'articles.conference_registration.headings.location' + = textfield :location, (params[:location] || location(@registration.city ||lookup_ip_location)), required: true, heading: 'articles.conference_registration.headings.location' = checkboxes :languages, User.AVAILABLE_LANGUAGES, (current_user.languages || [I18n.locale]).map(&:to_sym), 'languages', heading: 'articles.conference_registration.headings.languages' .actions.next-prev = button_tag (params[:step] == :save ? :save : :next), value: :contact_info diff --git a/config/locales/en.yml b/config/locales/en.yml index ad07b94..439cee9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1364,6 +1364,7 @@ en: forms: labels: generic: + hosting_dates: When will you be in town? type: Type year: Year is_public: Public diff --git a/config/locales/es.yml b/config/locales/es.yml index 5f16346..fe1ec17 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -996,6 +996,7 @@ es: forms: labels: generic: + hosting_dates: ¿Cuándo estarás en la ciudad? title: Título de la taller info: Descripción allergies: Alérgicx diff --git a/db/migrate/20170110061048_add_city_id_to_conference_registrations.rb b/db/migrate/20170110061048_add_city_id_to_conference_registrations.rb new file mode 100644 index 0000000..f086191 --- /dev/null +++ b/db/migrate/20170110061048_add_city_id_to_conference_registrations.rb @@ -0,0 +1,5 @@ +class AddCityIdToConferenceRegistrations < ActiveRecord::Migration + def change + add_column :conference_registrations, :city_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 554c7ae..ddeb1cd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,20 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161211065022) do +ActiveRecord::Schema.define(version: 20170110061048) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "applications", force: :cascade do |t| + t.string "slug" + t.string "name" + t.string "path" + t.string "url" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "authentications", force: :cascade do |t| t.integer "user_id", null: false t.string "provider", null: false @@ -120,6 +129,7 @@ ActiveRecord::Schema.define(version: 20161211065022) do t.json "steps_completed" t.boolean "can_provide_housing" t.json "housing_data" + t.integer "city_id" end create_table "conference_types", force: :cascade do |t|