Browse Source

Fixed registration status issues

development
Godwin 7 years ago
parent
commit
5118fa7135
  1. 8
      app/assets/javascripts/registrations.js
  2. 7
      app/controllers/conference_administration_controller.rb
  3. 10
      app/models/city.rb
  4. 7
      app/models/conference_registration.rb
  5. 2
      db/schema.rb

8
app/assets/javascripts/registrations.js

@ -69,9 +69,9 @@
}
function editTableCell(cell) {
if (selectorMatches(cell, 'tr[data-key].editable td')) {
if (cell && selectorMatches(cell, 'tr[data-key].editable td')) {
editTableRow(cell.parentElement, cell);
} else if (!selectorMatches(cell, 'tr[data-key].editable + tr, tr[data-key].editable + tr *')) {
} else if (!cell || !selectorMatches(cell, 'tr[data-key].editable + tr, tr[data-key].editable + tr *')) {
var currentRow = document.querySelector('tr[data-key].editable.editing');
if (currentRow) {
saveRow(currentRow);
@ -131,6 +131,10 @@
document.addEventListener("focus", function (event) { editTableCell(event.target); }, true);
}
window.onbeforeunload = function() {
editTableCell();
};
searchControl.addEventListener('keyup', filterTable);
searchControl.addEventListener('search', filterTable);

7
app/controllers/conference_administration_controller.rb

@ -867,7 +867,12 @@ class ConferenceAdministrationController < ApplicationController
params.each do | key, value |
case key.to_sym
when :city
registration.city = value.present? ? view_context.location(Geocoder.search(value, language: @this_conference.locale).first, @this_conference.locale) : nil
if value.present?
city = City.search(value)
if city.present?
registration.city_id = city.id
end
end
when :housing, :bike, :food, :allergies, :other
registration.send("#{key.to_s}=", value)
when :registration_fees_paid

10
app/models/city.rb

@ -50,6 +50,14 @@ class City < ActiveRecord::Base
return translation
end
def to_s
([
city,
territory.present? && country.present? ? I18n.t("geography.subregions.#{country}.#{territory}") : '',
country.present? ? I18n.t("geography.countries.#{country}") : ''
] - ['', nil]).join(', ')
end
def self.search(str)
cache = CityCache.search(str)
@ -66,7 +74,7 @@ class City < ActiveRecord::Base
# if we didn't find a match by place id, collect the city, territory, and country from the result
unless city.present?
# google nsames things differently than we do, we'll look for these itesm
# google names things differently than we do, we'll look for these items
component_alises = {
'locality' => :city,
'administrative_area_level_1' => :territory,

7
app/models/conference_registration.rb

@ -34,9 +34,10 @@ class ConferenceRegistration < ActiveRecord::Base
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?)
return :preregistered
return :unregistered if user.nil?
steps = ((was ? steps_completed_was : steps_completed) || []).map(&:to_sym)
return :registered if steps.include?(:hosting) || steps.include?(:questions)
return :preregistered if steps.include?(:contact_info)
end
around_update :check_status

2
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: 20170111013903) do
ActiveRecord::Schema.define(version: 20170111172147) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Loading…
Cancel
Save