Paypal Registration
This commit is contained in:
@@ -7,8 +7,8 @@ class Conference < ActiveRecord::Base
|
||||
has_many :conference_host_organizations, :dependent => :destroy
|
||||
has_many :organizations, :through => :conference_host_organizations
|
||||
|
||||
has_many :conference_registration_form_fields, :order => 'position ASC', :dependent => :destroy#, :class_name => '::ConferenceRegistrationFormField'
|
||||
has_many :registration_form_fields, :through => :conference_registration_form_fields
|
||||
#has_many :conference_registration_form_fields, :order => 'position ASC', :dependent => :destroy#, :class_name => '::ConferenceRegistrationFormField'
|
||||
#has_many :registration_form_fields, :through => :conference_registration_form_fields
|
||||
|
||||
has_many :workshops
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
class Location < ActiveRecord::Base
|
||||
#attr_accessible :title, :country, :territory, :city, :street, :postal_code, :latitude, :longitude
|
||||
has_many :locations_organization
|
||||
has_many :organizations, :through => :locations_organization
|
||||
has_many :locations_organization
|
||||
has_many :organizations, :through => :locations_organization
|
||||
|
||||
geocoded_by :full_address
|
||||
|
||||
reverse_geocoded_by :latitude, :longitude, :address => :full_address
|
||||
after_validation :geocode, if: ->(obj){ obj.country_changed? or obj.territory_changed? or obj.city_changed? or obj.street_changed? or obj.postal_code_changed? }
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class Organization < ActiveRecord::Base
|
||||
|
||||
accepts_nested_attributes_for :locations, :reject_if => proc {|l| l[id].blank?}
|
||||
accepts_nested_attributes_for :user_organization_relationships, :reject_if => proc {|u| u[:user_id].blank?}, :allow_destroy => true
|
||||
before_create :make_slug
|
||||
|
||||
def location
|
||||
locations.first
|
||||
@@ -28,4 +29,33 @@ class Organization < ActiveRecord::Base
|
||||
slug
|
||||
end
|
||||
|
||||
def generate_slug(name, location = nil)
|
||||
s = name.gsub(/[^a-z1-9]+/i, '-').chomp('-').gsub(/\-([A-Z])/, '\1')
|
||||
if Organization.find_by(:slug => s).present? && !location.nil?
|
||||
if location.city.present?
|
||||
s += '-' + location.city
|
||||
end
|
||||
if Organization.find_by(:slug => s).present? && location.territory.present?
|
||||
s += '-' + location.territory
|
||||
end
|
||||
if Organization.find_by(:slug => s).present?
|
||||
s += '-' + location.country
|
||||
end
|
||||
end
|
||||
attempt = 1
|
||||
ss = s
|
||||
|
||||
while Organization.find_by(:slug => s)
|
||||
attempt += 1
|
||||
s = ss + '-' + attempt.to_s
|
||||
end
|
||||
s
|
||||
end
|
||||
|
||||
private
|
||||
def make_slug
|
||||
if !self.slug
|
||||
self.slug = generate_slug(self.name, self.locations && self.locations[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ class User < ActiveRecord::Base
|
||||
config.authentications_class = Authentication
|
||||
end
|
||||
|
||||
validates :password, presence: true, confirmation: true, length: { minimum: 3 }, unless: ("id?" || "password_confirmation?")
|
||||
validates :password_confirmation, presence: true, unless: ("id?" || "password?")
|
||||
#validates :password, presence: true, confirmation: true, length: { minimum: 3 }, unless: ("id?" || "password_confirmation?")
|
||||
#validates :password_confirmation, presence: true, unless: ("id?" || "password?")
|
||||
|
||||
validates :email, uniqueness: true
|
||||
|
||||
|
||||
@@ -1,7 +1,37 @@
|
||||
class Workshop < ActiveRecord::Base
|
||||
belongs_to :conference
|
||||
|
||||
has_many :workshop_facilitators, :dependent => :destroy
|
||||
has_many :users, :through => :workshop_facilitators
|
||||
|
||||
accepts_nested_attributes_for :workshop_facilitators, :reject_if => proc {|u| u[:user_id].blank?}, :allow_destroy => true
|
||||
|
||||
before_create :make_slug
|
||||
|
||||
def to_param
|
||||
slug
|
||||
end
|
||||
|
||||
private
|
||||
def make_slug
|
||||
if !self.slug
|
||||
s = self.title.gsub(/[^a-z1-9]+/i, '-').chomp('-').gsub(/\-([A-Z])/, '\1')
|
||||
if Organization.find_by(:slug => s) && self.locations && self.locations[0]
|
||||
s += '-' + self.locations[0].city
|
||||
if Organization.find_by(:slug => s) && locations[0].territory
|
||||
s += '-' + self.locations[0].territory
|
||||
end
|
||||
if Organization.find_by(:slug => s)
|
||||
s += '-' + self.locations[0].country
|
||||
end
|
||||
end
|
||||
attempt = 1
|
||||
ss = s
|
||||
while Organization.find_by(:slug => s)
|
||||
attempt += 1
|
||||
s = ss + '-' + attempt
|
||||
end
|
||||
self.slug = s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user