Finishing touches on abilities and registration form
This commit is contained in:
parent
2327340b71
commit
3d00bbed03
|
@ -16,12 +16,12 @@ class Ability
|
||||||
# Instructors can manage certs and see users
|
# Instructors can manage certs and see users
|
||||||
if user.instructor?
|
if user.instructor?
|
||||||
can :manage, Certification
|
can :manage, Certification
|
||||||
can :read, User
|
can [:create,:read], User
|
||||||
can :manage, UserCertification
|
can :manage, UserCertification
|
||||||
end
|
end
|
||||||
# Users can see others' stuff if they've been oriented
|
# Users can see others' stuff if they've been oriented
|
||||||
unless user.orientation.blank?
|
unless user.orientation.blank?
|
||||||
can :read, User
|
can :read, User, :hidden => [nil,false]
|
||||||
can :read, UserCertification
|
can :read, UserCertification
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class User < ActiveRecord::Base
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
# Setup accessible (or protected) attributes for your model
|
# 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 :cards
|
||||||
has_many :user_certifications
|
has_many :user_certifications
|
||||||
|
|
58
app/views/devise/registrations/_user.html.erb
Normal file
58
app/views/devise/registrations/_user.html.erb
Normal 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 %>
|
|
@ -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">
|
<%= render :partial => "user", :locals => { :resource => resource, :html => { :method => :put }, :button_label => "Update Profile" } %>
|
||||||
<%= f.label :name %><br />
|
|
||||||
<%= f.text_field :name %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div><%= f.label :email %><br />
|
<%= render "devise/shared/links" %>
|
||||||
<%= f.email_field :email %></div>
|
|
||||||
|
|
||||||
<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 %>
|
<%= link_to "Back", :back %>
|
||||||
|
|
|
@ -1,23 +1,7 @@
|
||||||
<h2>Sign up</h2>
|
<h2>Sign up</h2>
|
||||||
|
|
||||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
|
||||||
<%= devise_error_messages! %>
|
<%= devise_error_messages! %>
|
||||||
|
|
||||||
<div class="field">
|
<%= render :partial => "user", :locals => { :resource => resource, :button_label => "Sign Up", :html => nil } %>
|
||||||
<%= 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 "devise/shared/links" %>
|
<%= render "devise/shared/links" %>
|
||||||
|
|
|
@ -90,6 +90,10 @@
|
||||||
<%= f.label :admin, "Admin?" %><br />
|
<%= f.label :admin, "Admin?" %><br />
|
||||||
<%= f.check_box :admin %>
|
<%= f.check_box :admin %>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label :hidden, "Hidden?" %><br />
|
||||||
|
<%= f.check_box :hidden %>
|
||||||
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<h3>Cards</h3>
|
<h3>Cards</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -4,7 +4,18 @@ Dooraccess::Application.routes.draw do
|
||||||
|
|
||||||
resources :certifications
|
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
|
resources :users
|
||||||
match 'users/create' => 'users#create', :via => :post # Use POST users/create instead of POST users to avoid devise conflict
|
match 'users/create' => 'users#create', :via => :post # Use POST users/create instead of POST users to avoid devise conflict
|
||||||
|
|
||||||
|
|
5
db/migrate/20130125185724_add_hidden_to_users.rb
Normal file
5
db/migrate/20130125185724_add_hidden_to_users.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddHiddenToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :hidden, :boolean
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# 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|
|
create_table "cards", :force => true do |t|
|
||||||
t.string "card_number"
|
t.string "card_number"
|
||||||
|
@ -71,6 +71,7 @@ ActiveRecord::Schema.define(:version => 20130125133237) do
|
||||||
t.string "current_skills"
|
t.string "current_skills"
|
||||||
t.string "desired_skills"
|
t.string "desired_skills"
|
||||||
t.boolean "instructor"
|
t.boolean "instructor"
|
||||||
|
t.boolean "hidden"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user