Skip to content

Commit

Permalink
Merge branch 'master' of github.com:advance2030/advance2030
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Solorio committed Jun 27, 2010
2 parents 0c6d7d9 + b4e2aa1 commit 705044a
Show file tree
Hide file tree
Showing 28 changed files with 334 additions and 104 deletions.
34 changes: 23 additions & 11 deletions app/controllers/registrations_controller.rb
Expand Up @@ -13,27 +13,39 @@ def create
session[:registration_params].deep_merge!(params[:registration]) if params[:registration]
@registration = Registration.new(session[:registration_params])
@registration.current_step = session[:registration_step]
#logger.info("Current step is #{@registration.current_step}")
if @registration.valid?
# registration_converter = ConvertsRegistrationToAccountInformation.new
# registration_converter.do_it(@registration)

# render :action => :show
#redirect_to account_url
@registration.next_step
session[:registration_step] = @registration.current_step
if (@registration.current_step == 'personal_info')
@registration.save!
registration_converter = ConvertsRegistrationToAccountInformation.new
registration_converter.do_it(@registration)
else
@registration.next_step
session[:registration_step] = @registration.current_step
end
# logger.info("Current step is #{@registration.current_step}")
end

if @registration.new_record?
render "new"
else
session[:registration_step] = session[:registration_params] = nil
flash[:notice] = "Registration saved!"
render "show"
#Continue from here -> the 3rd step should render "show"
render "review"
#session[:registration_step] = session[:registration_params] = nil
#flash[:notice] = "Registration saved!"
#render "show"
end
end

def start_over
session[:registration_params] = nil
session[:registration_step] = nil
redirect_to new_registration_path
end

def review
# logger.info("The current_user is #{@current_user}")
end

def show
end

Expand Down
4 changes: 0 additions & 4 deletions app/helpers/registrations_helper.rb
Expand Up @@ -2,7 +2,3 @@ module RegistrationsHelper
EMAIL_REGEX = /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
end

def title_string(step)
return "Registration: Membership Dues" if step == 'review'
"Registration"
end
2 changes: 2 additions & 0 deletions app/models/email_address.rb
@@ -1,2 +1,4 @@
class EmailAddress < ActiveRecord::Base
belongs_to :user
end

6 changes: 6 additions & 0 deletions app/models/registration.rb
Expand Up @@ -15,6 +15,7 @@ class Registration < ActiveRecord::Base

validates_presence_of :address, :city, :state, :zip, :phone_number,
:if => lambda { |r| r.current_step == 'personal_info' }
validates_length_of :password, :minimum => 4, :if => :password?

def validate
errors.add('password', 'and confirmation do not match') unless password_confirmation == password
Expand Down Expand Up @@ -44,5 +45,10 @@ def last_step?
current_step == steps.last
end

def password?
return true unless @password == nil || @password.strip == ''
false
end

end

2 changes: 2 additions & 0 deletions app/models/user.rb
Expand Up @@ -4,6 +4,7 @@ class User < ActiveRecord::Base
has_many :roles, :through => :users_roles
has_one :account
has_one :user_profile
has_one :user_address

named_scope :managers, lambda {{
:joins => :users_roles,
Expand All @@ -24,3 +25,4 @@ def login
end

end

2 changes: 2 additions & 0 deletions app/models/user_address.rb
@@ -1,2 +1,4 @@
class UserAddress < ActiveRecord::Base
belongs_to :user
end

9 changes: 5 additions & 4 deletions app/views/layouts/application.html.erb
Expand Up @@ -24,12 +24,12 @@
</div>
<div id="loginSection">
<% if !@current_user.nil? and @current_user.logged_in? %>
<%= @current_user.login %> |
<a href="javscript:void();">Account</a> |
<%= @current_user.login %> |
<a href="javscript:void();">Account</a> |
<%= link_to "Sign out", user_session_url(@current_user), :method => :delete %>
<% else %>
<a href="/user_sessions/new/" title="login" class="login">Login</a> | New Here?
<a href="/registrations/new/" title="register">Register</a>
<a href="/registration/new/" title="register">Register</a>
<% end %>
</div>
</div>
Expand All @@ -45,11 +45,12 @@
<div id="content">
<%= yield %>
</div>

<footer>
The Cleveland Professional 20/30 Club, 600 Superior Avenue, Suite 1300, Cleveland, OH 44114 &nbsp;<a href="mailto:info@cleveland2030.org">info@cleveland2030.org</a></footer>
</div>
</div>
</div>
</body>
</html>

11 changes: 4 additions & 7 deletions app/views/registrations/new.html.erb
@@ -1,14 +1,11 @@
<div class="twoColumns-0">
<h1><%= title_string(@registration.current_step) %> <a href="/user_sessions/new/" class="tiny right">I already have an account</a></h1>
<div class="twoColumns-0">
<h1>Registration <a href="/user_sessions/new/" class="tiny right">I already have an account</a></h1>
<% form_for @registration, :url => registration_path do |f| %>
<%= f.error_messages %>
<%= render "#{@registration.current_step}_form", :f => f %>
<div class="formAction clear">
<% if @registration.current_step == 'review' %>
<input type="image" src="images/paypal.gif" />
<% else %>
<%= f.submit "Continue" %>
<% end %>
<%= f.submit "Continue" %> or <%= link_to 'Start Over', registration_start_over_path %>
</div>
<% end %>
</div>

10 changes: 10 additions & 0 deletions app/views/registrations/review.html.erb
@@ -0,0 +1,10 @@
<div class="twoColumns-0">
<h1>Registration: Membership Dues <a href="/user_sessions/new/" class="tiny right">I already have an account</a></h1>
<form>
<%= render "review_form" %>
<div class="formAction clear">
<%= image_submit_tag 'paypal.gif' %>
</div>
</form>
</div>

6 changes: 5 additions & 1 deletion config/routes.rb
Expand Up @@ -24,7 +24,7 @@

# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller

# Sample resource route with more complex sub-resources
# map.resources :products do |products|
# products.resources :comments
Expand All @@ -49,6 +49,9 @@
map.resource :account
map.resource :alert
map.resource :registration
map.registration_review 'registration/review', :controller => 'registrations', :action => 'review'
map.registration_start_over 'registration/start_over', :controller => 'registrations', :action => 'start_over'

map.calendar 'calendar/:year/:month/:day',
:controller => 'calendar',
:action => 'index',
Expand All @@ -67,3 +70,4 @@
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end

10 changes: 10 additions & 0 deletions db/migrate/20100619121800_add_active_column_to_accounts.rb
@@ -0,0 +1,10 @@
class AddActiveColumnToAccounts < ActiveRecord::Migration
def self.up
add_column :accounts, :active, :boolean, :default => false
end

def self.down
remove_column :accounts, :active
end
end

@@ -0,0 +1,10 @@
class RenameStreetToAddress2InUserAddresses < ActiveRecord::Migration
def self.up
rename_column :user_addresses, :street, :address2
end

def self.down
rename_column :user_addresses, :address2, :street
end
end

@@ -0,0 +1,11 @@
class RemovePostalCodeIdFromUserAddresses < ActiveRecord::Migration
def self.up
remove_column :user_addresses, :postal_code_id
end

def self.down
add_column :user_addresses, :postal_code_id, :integer, :null => false
add_index :user_addresses, :postal_code_id
end
end

16 changes: 16 additions & 0 deletions db/migrate/20100619125555_add_missing_columns_to_user_addresses.rb
@@ -0,0 +1,16 @@
class AddMissingColumnsToUserAddresses < ActiveRecord::Migration
def self.up
add_column :user_addresses, :address, :string
add_column :user_addresses, :city, :string
add_column :user_addresses, :state_code, :string
add_column :user_addresses, :zip, :string
end

def self.down
remove_column :user_addresses, :address
remove_column :user_addresses, :city
remove_column :user_addresses, :state_code
remove_column :user_addresses, :zip
end
end

@@ -0,0 +1,16 @@
class ChangeNewColumnsNonNullableInUserAddresses < ActiveRecord::Migration
def self.up
change_column :user_addresses, :address, :string, :null => false
change_column :user_addresses, :city, :string, :null => false
change_column :user_addresses, :state_code, :string, :null => false
change_column :user_addresses, :zip, :string, :null => false
end

def self.down
change_column :user_addresses, :address, :string, :null => true
change_column :user_addresses, :city, :string, :null => true
change_column :user_addresses, :state_code, :string, :null => true
change_column :user_addresses, :zip, :string, :null => true
end
end

27 changes: 15 additions & 12 deletions db/schema.rb
Expand Up @@ -9,17 +9,17 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20100613212120) do
ActiveRecord::Schema.define(:version => 20100619133911) do

create_table "accounts", :force => true do |t|
t.string "login", :null => false
t.string "crypted_password", :null => false
t.string "password_salt", :null => false
t.string "persistence_token", :null => false
t.string "single_access_token", :null => false
t.string "perishable_token", :null => false
t.integer "login_count", :default => 0, :null => false
t.integer "failed_login_count", :default => 0, :null => false
t.string "login", :null => false
t.string "crypted_password", :null => false
t.string "password_salt", :null => false
t.string "persistence_token", :null => false
t.string "single_access_token", :null => false
t.string "perishable_token", :null => false
t.integer "login_count", :default => 0, :null => false
t.integer "failed_login_count", :default => 0, :null => false
t.datetime "last_request_at"
t.datetime "current_login_at"
t.datetime "last_login_at"
Expand All @@ -30,6 +30,7 @@
t.datetime "updated_at"
t.datetime "joined_at"
t.datetime "expired_at"
t.boolean "active", :default => false
end

create_table "address_types", :force => true do |t|
Expand Down Expand Up @@ -453,17 +454,19 @@

create_table "user_addresses", :force => true do |t|
t.integer "user_id", :null => false
t.text "street"
t.integer "postal_code_id", :null => false
t.text "address2"
t.integer "address_type_id", :null => false
t.boolean "is_primary", :default => false
t.integer "sort_order"
t.datetime "created_at"
t.datetime "updated_at"
t.string "address", :null => false
t.string "city", :null => false
t.string "state_code", :null => false
t.string "zip", :null => false
end

add_index "user_addresses", ["address_type_id"], :name => "index_user_addresses_on_address_type_id"
add_index "user_addresses", ["postal_code_id"], :name => "index_user_addresses_on_postal_code_id"
add_index "user_addresses", ["user_id"], :name => "index_user_addresses_on_user_id"

create_table "user_phone_numbers", :force => true do |t|
Expand Down
34 changes: 20 additions & 14 deletions db/seeds.rb
Expand Up @@ -2,28 +2,33 @@
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name => 'Daley', :city => cities.first)
states = [
[ "Alabama", "AL" ], [ "Alaska", "AK" ], [ "Arizona", "AZ" ], [ "Arkansas", "AR" ],
[ "California", "CA" ], [ "Colorado", "CO" ], [ "Connecticut", "CT" ], [ "Delaware", "DE" ],
[ "District Of Columbia", "DC" ], [ "Florida", "FL" ], [ "Georgia", "GA" ], [ "Hawaii", "HI" ],
[ "Idaho", "ID" ], [ "Illinois", "IL" ], [ "Indiana", "IN" ], [ "Iowa", "IA" ],
[ "Kansas", "KS" ], [ "Kentucky", "KY" ], [ "Louisiana", "LA" ], [ "Maine", "ME" ],
[ "Maryland", "MD" ], [ "Massachusetts", "MA" ], [ "Michigan", "MI" ], [ "Minnesota", "MN" ],
[ "Mississippi", "MS" ], [ "Missouri", "MO" ], [ "Montana", "MT" ], [ "Nebraska", "NE" ],
[ "Nevada", "NV" ], [ "New Hampshire", "NH" ], [ "New Jersey", "NJ" ], [ "New Mexico", "NM" ],
[ "New York", "NY" ], [ "North Carolina", "NC" ], [ "North Dakota", "ND" ], [ "Ohio", "OH" ],
[ "Oklahoma", "OK" ], [ "Oregon", "OR" ], [ "Pennsylvania", "PA" ], [ "Rhode Island", "RI" ],
[ "South Carolina", "SC" ], [ "South Dakota", "SD" ], [ "Tennessee", "TN" ], [ "Texas", "TX" ],
[ "Utah", "UT" ], [ "Vermont", "VT" ], [ "Virginia", "VA" ], [ "Washington", "WA" ],
[ "Alabama", "AL" ], [ "Alaska", "AK" ], [ "Arizona", "AZ" ], [ "Arkansas", "AR" ],
[ "California", "CA" ], [ "Colorado", "CO" ], [ "Connecticut", "CT" ], [ "Delaware", "DE" ],
[ "District Of Columbia", "DC" ], [ "Florida", "FL" ], [ "Georgia", "GA" ], [ "Hawaii", "HI" ],
[ "Idaho", "ID" ], [ "Illinois", "IL" ], [ "Indiana", "IN" ], [ "Iowa", "IA" ],
[ "Kansas", "KS" ], [ "Kentucky", "KY" ], [ "Louisiana", "LA" ], [ "Maine", "ME" ],
[ "Maryland", "MD" ], [ "Massachusetts", "MA" ], [ "Michigan", "MI" ], [ "Minnesota", "MN" ],
[ "Mississippi", "MS" ], [ "Missouri", "MO" ], [ "Montana", "MT" ], [ "Nebraska", "NE" ],
[ "Nevada", "NV" ], [ "New Hampshire", "NH" ], [ "New Jersey", "NJ" ], [ "New Mexico", "NM" ],
[ "New York", "NY" ], [ "North Carolina", "NC" ], [ "North Dakota", "ND" ], [ "Ohio", "OH" ],
[ "Oklahoma", "OK" ], [ "Oregon", "OR" ], [ "Pennsylvania", "PA" ], [ "Rhode Island", "RI" ],
[ "South Carolina", "SC" ], [ "South Dakota", "SD" ], [ "Tennessee", "TN" ], [ "Texas", "TX" ],
[ "Utah", "UT" ], [ "Vermont", "VT" ], [ "Virginia", "VA" ], [ "Washington", "WA" ],
[ "West Virginia", "WV" ], [ "Wisconsin", "WI" ], [ "Wyoming", "WY" ] ]

states.each{ |state| State.create(:title => state[0], :code => state[1]) }

AddressType.create([
{:title => 'personal', :description => 'Personal email address'},
{:title => 'corporate', :description => 'Corporate email address'}
])

events = Event.create([
{:name => "National City Night on the Town",
{:name => "National City Night on the Town",
:start_datetime => Time.now.advance(:days => 5),
:end_datetime => Time.now.advance(:days =>5, :minutes => 30),
:sponsor => true
Expand All @@ -40,3 +45,4 @@
:start_datetime => Time.now.advance(:days => 6),
:end_datetime => Time.now.advance(:days => 6, :minutes => 30),
:sponsor => false}])

15 changes: 15 additions & 0 deletions features/step_definitions/user_login_steps.rb
Expand Up @@ -2,6 +2,21 @@
registration_converter = ConvertsRegistrationToAccountInformation.new
table.hashes.each do |hash|
registration = Registration.new(hash)
registration.password_confirmation = hash["password"]

# add address info
user_address = Factory(:user_address)
registration.address = user_address.address
registration.address2 = user_address.address2
registration.city = user_address.city
registration.state = user_address.state_code
registration.zip = user_address.zip

registration_converter.do_it(registration)
# Activate the account for now...
account = Account.find_by_login(hash["login"])
account.active = true
account.save!
end
end

0 comments on commit 705044a

Please sign in to comment.