From 3d00bbed039686f3a1e9d6eebe17f2ee27734891 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Fri, 25 Jan 2013 13:47:44 -0700 Subject: [PATCH] Finishing touches on abilities and registration form --- app/models/ability.rb | 4 +- app/models/user.rb | 2 +- app/views/devise/registrations/_user.html.erb | 58 +++++++++++++++++++ app/views/devise/registrations/edit.html.erb | 28 ++------- app/views/devise/registrations/new.html.erb | 18 +----- app/views/users/_form.html.erb | 4 ++ config/routes.rb | 13 ++++- .../20130125185724_add_hidden_to_users.rb | 5 ++ db/schema.rb | 3 +- 9 files changed, 89 insertions(+), 46 deletions(-) create mode 100644 app/views/devise/registrations/_user.html.erb create mode 100644 db/migrate/20130125185724_add_hidden_to_users.rb diff --git a/app/models/ability.rb b/app/models/ability.rb index 1353a0b..57035eb 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 6c41f9f..d3b3644 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/devise/registrations/_user.html.erb b/app/views/devise/registrations/_user.html.erb new file mode 100644 index 0000000..346cb2e --- /dev/null +++ b/app/views/devise/registrations/_user.html.erb @@ -0,0 +1,58 @@ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => html) do |f| %> +
+ <%= f.label :name %>
+ <%= f.text_field :name %> +
+ +
+ <%= f.label :email %>
+ <%= f.email_field :email %> +
+ +
+ <%= f.label :phone %>
+ <%= f.text_field :phone %> +
+
+ <%= f.label :emergency_name, "Emergency contact" %>
+ <%= f.text_field :emergency_name %> +
+
+ <%= f.label :emergency_phone %>
+ <%= f.text_field :emergency_phone %> +
+
+ <%= f.label :emergency_email %>
+ <%= f.text_field :emergency_email %> +
+
+ <%= f.label :member_level, "Membership Level" %>
+ <%= f.select :member_level, [[nil],["None",0],["Unable",1],["Volunteer",10],["Associate ($25)",25],["Basic ($50)",50],["Plus ($100)",100]] %> +
+
+ <%= f.label :payment_method %> (after changing this, please update your payment method to match.)
+ <%= f.select :payment_method, [[nil],["PayPal"],["Dwolla"],["Bill Pay"],["Check"],["Cash"],["Other"]] %> +
+
+ <%= f.label :current_skills %>
+ <%= f.text_area :current_skills %> +
+
+ <%= f.label :desired_skills %>
+ <%= f.text_area :desired_skills %> +
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ + <% if params[:action]!='new' %> +
<%= f.label :current_password %>
+ <%= f.password_field :current_password %>
+ <% end %> + +
<%= f.submit button_label %>
+ +<% end %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index fbbc622..328e723 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,30 +1,10 @@ -

Edit <%= resource_name.to_s.humanize %>

+

Edit Your Profile

-<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> - <%= devise_error_messages! %> +<%= devise_error_messages! %> -
- <%= f.label :name %>
- <%= f.text_field :name %> -
+<%= render :partial => "user", :locals => { :resource => resource, :html => { :method => :put }, :button_label => "Update Profile" } %> -
<%= f.label :email %>
- <%= f.email_field :email %>
+<%= render "devise/shared/links" %> -
<%= f.label :password %> (leave blank if you don't want to change it)
- <%= f.password_field :password, :autocomplete => "off" %>
- -
<%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation %>
- -
<%= f.label :current_password %> (we need your current password to confirm your changes)
- <%= f.password_field :current_password %>
- -
<%= f.submit "Update" %>
-<% end %> - -

Cancel my account

- -

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.

<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index df3407c..134179a 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,23 +1,7 @@

Sign up

-<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> -
- <%= f.label :name %>
- <%= f.text_field :name %> -
- -
<%= f.label :email %>
- <%= f.email_field :email %>
- -
<%= f.label :password %>
- <%= f.password_field :password %>
- -
<%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation %>
- -
<%= f.submit "Sign up" %>
-<% end %> + <%= render :partial => "user", :locals => { :resource => resource, :button_label => "Sign Up", :html => nil } %> <%= render "devise/shared/links" %> diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 54e9f5c..aae514d 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -90,6 +90,10 @@ <%= f.label :admin, "Admin?" %>
<%= f.check_box :admin %> +
+ <%= f.label :hidden, "Hidden?" %>
+ <%= f.check_box :hidden %> +

Cards