Finishing touches on abilities and registration form

This commit is contained in:
Will Bradley 2013-01-25 13:47:44 -07:00
parent 2327340b71
commit 3d00bbed03
9 changed files with 89 additions and 46 deletions

View File

@ -16,12 +16,12 @@ class Ability
# Instructors can manage certs and see users
if user.instructor?
can :manage, Certification
can :read, User
can [:create,:read], User
can :manage, UserCertification
end
# Users can see others' stuff if they've been oriented
unless user.orientation.blank?
can :read, User
can :read, User, :hidden => [nil,false]
can :read, UserCertification
end
end

View File

@ -6,7 +6,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :admin, :instructor, :member, :emergency_name, :emergency_phone, :current_skills, :desired_skills, :waiver, :emergency_email, :phone, :payment_method, :orientation, :member_level, :certifications
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :admin, :instructor, :member, :emergency_name, :emergency_phone, :current_skills, :desired_skills, :waiver, :emergency_email, :phone, :payment_method, :orientation, :member_level, :certifications, :hidden
has_many :cards
has_many :user_certifications

View File

@ -0,0 +1,58 @@
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => html) do |f| %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email %>
</div>
<div class="field">
<%= f.label :phone %><br />
<%= f.text_field :phone %>
</div>
<div class="field">
<%= f.label :emergency_name, "Emergency contact" %><br />
<%= f.text_field :emergency_name %>
</div>
<div class="field">
<%= f.label :emergency_phone %><br />
<%= f.text_field :emergency_phone %>
</div>
<div class="field">
<%= f.label :emergency_email %><br />
<%= f.text_field :emergency_email %>
</div>
<div class="field">
<%= f.label :member_level, "Membership Level" %><br />
<%= f.select :member_level, [[nil],["None",0],["Unable",1],["Volunteer",10],["Associate ($25)",25],["Basic ($50)",50],["Plus ($100)",100]] %>
</div>
<div class="field">
<%= f.label :payment_method %> <i>(after changing this, please update your payment method to match.)</i><br />
<%= f.select :payment_method, [[nil],["PayPal"],["Dwolla"],["Bill Pay"],["Check"],["Cash"],["Other"]] %>
</div>
<div class="field">
<%= f.label :current_skills %><br />
<%= f.text_area :current_skills %>
</div>
<div class="field">
<%= f.label :desired_skills %><br />
<%= f.text_area :desired_skills %>
</div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<% if params[:action]!='new' %>
<div><%= f.label :current_password %><br />
<%= f.password_field :current_password %></div>
<% end %>
<div><%= f.submit button_label %></div>
<% end %>

View File

@ -1,30 +1,10 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<h2>Edit Your Profile</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<%= render :partial => "user", :locals => { :resource => resource, :html => { :method => :put }, :button_label => "Update Profile" } %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<%= render "devise/shared/links" %>
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, :autocomplete => "off" %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></div>
<div><%= f.submit "Update" %></div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>
<%= link_to "Back", :back %>

View File

@ -1,23 +1,7 @@
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.submit "Sign up" %></div>
<% end %>
<%= render :partial => "user", :locals => { :resource => resource, :button_label => "Sign Up", :html => nil } %>
<%= render "devise/shared/links" %>

View File

@ -90,6 +90,10 @@
<%= f.label :admin, "Admin?" %><br />
<%= f.check_box :admin %>
</div>
<div class="field">
<%= f.label :hidden, "Hidden?" %><br />
<%= f.check_box :hidden %>
</div>
<div class="field">
<h3>Cards</h3>
<ul>

View File

@ -4,7 +4,18 @@ Dooraccess::Application.routes.draw do
resources :certifications
devise_for :users
devise_for :users, :skip => :registrations
devise_scope :user do
resource :registration,
:only => [:new, :create, :edit, :update],
:path => 'users',
:path_names => { :new => 'sign_up' },
:controller => 'devise/registrations',
:as => :user_registration do
get :cancel
end
end
resources :users
match 'users/create' => 'users#create', :via => :post # Use POST users/create instead of POST users to avoid devise conflict

View File

@ -0,0 +1,5 @@
class AddHiddenToUsers < ActiveRecord::Migration
def change
add_column :users, :hidden, :boolean
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130125133237) do
ActiveRecord::Schema.define(:version => 20130125185724) do
create_table "cards", :force => true do |t|
t.string "card_number"
@ -71,6 +71,7 @@ ActiveRecord::Schema.define(:version => 20130125133237) do
t.string "current_skills"
t.string "desired_skills"
t.boolean "instructor"
t.boolean "hidden"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true