Fixed hosting bug
This commit is contained in:
		
							parent
							
								
									bf11544c2a
								
							
						
					
					
						commit
						8bdb96777a
					
				| @ -123,13 +123,13 @@ class ConferencesController < ApplicationController | |||||||
|             @errors[:name] = :empty |             @errors[:name] = :empty | ||||||
|           end |           end | ||||||
| 
 | 
 | ||||||
|           if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? && (l = Geocoder.search(params[:location], language: 'en')).present? |           if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? | ||||||
|             corrected = view_context.location(l.first, @this_conference.locale) |             city = City.search(params[:location]) | ||||||
| 
 | 
 | ||||||
|             if corrected.present? |             if city.present? | ||||||
|               @registration.city = corrected |               @registration.city_id = city.id | ||||||
|               if params[:location].gsub(/[\s,]/, '').downcase != @registration.city.gsub(/[\s,]/, '').downcase |               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: corrected}) |                 @warnings << view_context._('warnings.messages.location_corrected', vars: {original: params[:location], corrected: view_context.location(city)}) | ||||||
|               end |               end | ||||||
|             else |             else | ||||||
|               @errors[:location] = :unknown |               @errors[:location] = :unknown | ||||||
| @ -330,7 +330,7 @@ class ConferencesController < ApplicationController | |||||||
|     steps -= [:questions] unless status == :open |     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? |     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 @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] |         steps -= [:questions] | ||||||
|          |          | ||||||
|         # if this is a housing provider that is not attending the conference, remove these steps |         # if this is a housing provider that is not attending the conference, remove these steps | ||||||
|  | |||||||
| @ -239,7 +239,7 @@ module ApplicationHelper | |||||||
|   def registration_steps(conference = @conference) |   def registration_steps(conference = @conference) | ||||||
|     { |     { | ||||||
|       pre: [:policy, :contact_info, :workshops], |       pre: [:policy, :contact_info, :workshops], | ||||||
|       open: [:policy, :contact_info, :questions, :payment, :workshops] |       open: [:policy, :contact_info, :questions, :hosting, :payment, :workshops] | ||||||
|     }[@this_conference.registration_status] |     }[@this_conference.registration_status] | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -7,6 +7,13 @@ module RegistrationHelper | |||||||
|     disable_steps = false |     disable_steps = false | ||||||
|     completed_steps = registration.steps_completed || [] |     completed_steps = registration.steps_completed || [] | ||||||
|     registration_complete = registration_complete?(registration) |     registration_complete = registration_complete?(registration) | ||||||
|  | 
 | ||||||
|  |     if registration.city_id == registration.conference.city_id | ||||||
|  |       steps -= [:questions] | ||||||
|  |     else | ||||||
|  |       steps -= [:hosting] | ||||||
|  |     end | ||||||
|  |      | ||||||
|     steps.each do | step | |     steps.each do | step | | ||||||
|       # disable the step if we've already found an incomplete step |       # disable the step if we've already found an incomplete step | ||||||
|       enabled = !disable_steps || registration_complete |       enabled = !disable_steps || registration_complete | ||||||
|  | |||||||
| @ -29,6 +29,10 @@ class ConferenceRegistration < ActiveRecord::Base | |||||||
|     [:vegan, :smoking, :pets, :quiet] |     [:vegan, :smoking, :pets, :quiet] | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  |   def city | ||||||
|  |     city_id.present? ? City.find(city_id) : nil | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|   def status(was = false) |   def status(was = false) | ||||||
|     return :unregistered if user.nil? || user.firstname.blank? || self.send(was ? :city_was : :city).blank? |     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?) |     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?) | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
|   %p=_'articles.conference_registration.paragraphs.Contact_Info', :s, 2 |   %p=_'articles.conference_registration.paragraphs.Contact_Info', :s, 2 | ||||||
|   = form_tag register_path(@this_conference.slug) do |   = form_tag register_path(@this_conference.slug) do | ||||||
|     = textfield :name, @name, required: true, heading: 'articles.conference_registration.headings.name', big: true |     = 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' |     = checkboxes :languages, User.AVAILABLE_LANGUAGES, (current_user.languages || [I18n.locale]).map(&:to_sym), 'languages', heading: 'articles.conference_registration.headings.languages' | ||||||
|     .actions.next-prev |     .actions.next-prev | ||||||
|       = button_tag (params[:step] == :save ? :save : :next), value: :contact_info |       = button_tag (params[:step] == :save ? :save : :next), value: :contact_info | ||||||
|  | |||||||
| @ -1364,6 +1364,7 @@ en: | |||||||
|   forms: |   forms: | ||||||
|     labels: |     labels: | ||||||
|       generic: |       generic: | ||||||
|  |         hosting_dates: When will you be in town? | ||||||
|         type: Type |         type: Type | ||||||
|         year: Year |         year: Year | ||||||
|         is_public: Public |         is_public: Public | ||||||
|  | |||||||
| @ -996,6 +996,7 @@ es: | |||||||
|   forms: |   forms: | ||||||
|     labels: |     labels: | ||||||
|       generic: |       generic: | ||||||
|  |         hosting_dates: ¿Cuándo estarás en la ciudad? | ||||||
|         title: Título de la taller |         title: Título de la taller | ||||||
|         info: Descripción |         info: Descripción | ||||||
|         allergies: Alérgicx |         allergies: Alérgicx | ||||||
|  | |||||||
| @ -0,0 +1,5 @@ | |||||||
|  | class AddCityIdToConferenceRegistrations < ActiveRecord::Migration | ||||||
|  |   def change | ||||||
|  |     add_column :conference_registrations, :city_id, :integer | ||||||
|  |   end | ||||||
|  | end | ||||||
							
								
								
									
										12
									
								
								db/schema.rb
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								db/schema.rb
									
									
									
									
									
								
							| @ -11,11 +11,20 @@ | |||||||
| # | # | ||||||
| # It's strongly recommended that you check this file into your version control system. | # 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 |   # These are extensions that must be enabled in order to support this database | ||||||
|   enable_extension "plpgsql" |   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| |   create_table "authentications", force: :cascade do |t| | ||||||
|     t.integer  "user_id",    null: false |     t.integer  "user_id",    null: false | ||||||
|     t.string   "provider",   null: false |     t.string   "provider",   null: false | ||||||
| @ -120,6 +129,7 @@ ActiveRecord::Schema.define(version: 20161211065022) do | |||||||
|     t.json     "steps_completed" |     t.json     "steps_completed" | ||||||
|     t.boolean  "can_provide_housing" |     t.boolean  "can_provide_housing" | ||||||
|     t.json     "housing_data" |     t.json     "housing_data" | ||||||
|  |     t.integer  "city_id" | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   create_table "conference_types", force: :cascade do |t| |   create_table "conference_types", force: :cascade do |t| | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user