|
@ -17,7 +17,7 @@ class Conference < ActiveRecord::Base |
|
|
|
|
|
|
|
|
accepts_nested_attributes_for :conference_host_organizations, reject_if: proc {|u| u[:organization_id].blank?}, allow_destroy: true |
|
|
accepts_nested_attributes_for :conference_host_organizations, reject_if: proc {|u| u[:organization_id].blank?}, allow_destroy: true |
|
|
|
|
|
|
|
|
before_create :make_slug |
|
|
before_create :make_slug, :make_title |
|
|
|
|
|
|
|
|
def to_param |
|
|
def to_param |
|
|
slug |
|
|
slug |
|
@ -97,6 +97,18 @@ class Conference < ActiveRecord::Base |
|
|
) |
|
|
) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def make_title(reset = false) |
|
|
|
|
|
if reset |
|
|
|
|
|
self.title = nil |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
self.title ||= Conference.generate_title( |
|
|
|
|
|
conferencetype || :annual, |
|
|
|
|
|
conference_year, |
|
|
|
|
|
city_name.gsub(/\s/, '') |
|
|
|
|
|
) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
def city_name |
|
|
def city_name |
|
|
return city.city if city.present? |
|
|
return city.city if city.present? |
|
|
return location.present? ? location.city : nil |
|
|
return location.present? ? location.city : nil |
|
@ -117,20 +129,24 @@ class Conference < ActiveRecord::Base |
|
|
|
|
|
|
|
|
def self.conference_types |
|
|
def self.conference_types |
|
|
{ |
|
|
{ |
|
|
annual: '%{city}%{year}', |
|
|
annual: { slug: '%{city}%{year}', title: 'Bike!Bike! %{year}'}, |
|
|
n: 'North%{year}', |
|
|
n: { slug: 'North%{year}', title: 'Bike!Bike! North %{year}'}, |
|
|
s: 'South%{year}', |
|
|
s: { slug: 'South%{year}', title: 'Bike!Bike! South %{year}'}, |
|
|
e: 'East%{year}', |
|
|
e: { slug: 'East%{year}', title: 'Bike!Bike! East %{year}'}, |
|
|
w: 'West%{year}', |
|
|
w: { slug: 'West%{year}', title: 'Bike!Bike! West %{year}'}, |
|
|
ne: 'Northeast%{year}', |
|
|
ne: { slug: 'Northeast%{year}', title: 'Bike!Bike! Northeast %{year}'}, |
|
|
nw: 'Northwest%{year}', |
|
|
nw: { slug: 'Northwest%{year}', title: 'Bike!Bike! Northwest %{year}'}, |
|
|
se: 'Southeast%{year}', |
|
|
se: { slug: 'Southeast%{year}', title: 'Bike!Bike! Southeast %{year}'}, |
|
|
sw: 'Southwest%{year}' |
|
|
sw: { slug: 'Southwest%{year}', title: 'Bike!Bike! Southwest %{year}'} |
|
|
} |
|
|
} |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def self.generate_slug(type, year, city) |
|
|
def self.generate_slug(type, year, city) |
|
|
Conference.conference_types[(type || :annual).to_sym].gsub('%{city}', city).gsub('%{year}', year.to_s) |
|
|
Conference.conference_types[(type || :annual).to_sym][:slug].gsub('%{city}', city).gsub('%{year}', year.to_s) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def self.generate_title(type, year, city) |
|
|
|
|
|
Conference.conference_types[(type || :annual).to_sym][:title].gsub('%{city}', city).gsub('%{year}', year.to_s) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
end |
|
|
end |
|
|