Added conference list page, administration tools, and re-designed conference administration

This commit is contained in:
Godwin
2016-12-11 20:02:24 -08:00
parent 08244444b0
commit 1dc608bf58
175 changed files with 12225 additions and 11806 deletions
@@ -0,0 +1,5 @@
class AddTypeToConference < ActiveRecord::Migration
def change
add_column :conferences, :type, :string
end
end
@@ -0,0 +1,14 @@
class CreateCities < ActiveRecord::Migration
def change
create_table :cities do |t|
t.string :city
t.string :territory
t.string :country
t.float :latitude
t.float :longitude
t.string :locale
t.timestamps null: false
end
end
end
@@ -0,0 +1,10 @@
class CreateCityMatches < ActiveRecord::Migration
def change
create_table :city_matches do |t|
t.string :search
t.integer :city_id
t.timestamps null: false
end
end
end
@@ -0,0 +1,5 @@
class AddYearToConference < ActiveRecord::Migration
def change
add_column :conferences, :year, :integer
end
end
@@ -0,0 +1,5 @@
class AddCityIdToConference < ActiveRecord::Migration
def change
add_column :conferences, :city_id, :integer
end
end
@@ -0,0 +1,9 @@
class AddIsPublicToConference < ActiveRecord::Migration
def change
add_column :conferences, :is_public, :boolean
Conference.all.each do |c|
c.update_attribute :is_public, true
end
end
end
@@ -0,0 +1,9 @@
class AddIsFeaturedToConference < ActiveRecord::Migration
def change
add_column :conferences, :is_featured, :boolean
Conference.all.each do |c|
c.update_attribute :is_featured, (c.slug == 'Detroit2016')
end
end
end
@@ -0,0 +1,9 @@
class RenameConferenceType < ActiveRecord::Migration
def change
rename_column :conferences, :type, :conferencetype
Conference.all.each do |c|
c.update_attribute :conferencetype, (c.conference_type == 5 ? 'regional' : 'annual')
end
end
end
@@ -0,0 +1,39 @@
require 'geocoder/calculations'
class RenameCityMatches < ActiveRecord::Migration
def change
rename_table :city_matches, :city_cache
Conference.all.each do |c|
conference_location = c.location
if conference_location.present?
location = Geocoder.search("#{conference_location.city}, #{conference_location.territory}, #{conference_location.country}", language: 'en').first
component_alises = {
'locality' => :city,
'administrative_area_level_1' => :territory,
'country' => :country
}
city_data = {
locale: :en,
latitude: location.data['geometry']['location']['lat'],
longitude: location.data['geometry']['location']['lng']
}
location.data['address_components'].each do | component |
property = component_alises[component['types'].first]
city_data[property] = component['short_name'] if property.present?
end
city = City.where(city: city_data[:city], territory: city_data[:territory], country: city_data[:country]).first
unless city.present?
city = City.new(city_data)
city.save!
end
c.update_attribute :city_id, city.id
end
end
end
end
@@ -0,0 +1,13 @@
require 'geocoder/calculations'
class AddPlaceIdToCity < ActiveRecord::Migration
def change
add_column :cities, :place_id, :string
City.all.each do |c|
location = Geocoder.search(c.address, language: 'en').first
c.place_id = location.data['place_id']
c.save!
end
end
end
@@ -0,0 +1,11 @@
class AddCityIdToLocation < ActiveRecord::Migration
def change
add_column :locations, :city_id, :integer
Location.all.each do |l|
city = City.search(([l.city, l.territory, l.country] - [nil, '']).join(', '))
l.city_id = city.id
l.save!
end
end
end
@@ -0,0 +1,9 @@
class AddSpanishCityTranslations < ActiveRecord::Migration
def change
City.all.each do |c|
city = c.get_translation(:es)
c.set_column_for_locale(:city, :es, city, 0) unless city.blank? || city == c.get_column_for_locale(:city, :es)
c.save!
end
end
end
@@ -0,0 +1,20 @@
class SetConferenceTypes < ActiveRecord::Migration
def change
types = {
'Bike!Bike! 2013' => :annual,
'Bike!Bike! Southeast 2014' => :se,
'Bike!Bike! North 2014' => :n,
'Ohio! Ohio!' => :ne,
'Bike!Bike! 2014' => :annual,
'Bike!Bike! 2015' => :annual,
'Bike!Bike! 2016' => :annual
}
Conference.all.each do |c|
c.conferencetype = types[c.title] || :annual
c.year ||= c.end_date.year
c.slug = nil
c.make_slug
c.save!
end
end
end
@@ -0,0 +1,10 @@
class CreateConferenceAdministrators < ActiveRecord::Migration
def change
create_table :conference_administrators do |t|
t.integer :conference_id
t.integer :user_id
t.timestamps null: false
end
end
end
@@ -0,0 +1,6 @@
class ChangeConferenceDatetimesToDates < ActiveRecord::Migration
def change
change_column :conferences, :start_date, :date
change_column :conferences, :end_date, :date
end
end
@@ -0,0 +1,19 @@
class ReplaceMissingLocales < ActiveRecord::Migration
def change
Conference.where(locale: nil).each do |c|
c.update_attribute :locale, 'en'
end
Workshop.where(locale: nil).each do |c|
c.update_attribute :locale, 'en'
end
Event.where(locale: nil).each do |c|
c.update_attribute :locale, 'en'
end
City.where(locale: nil).each do |c|
c.update_attribute :locale, 'en'
end
end
end