Adding social and exit reasons
This commit is contained in:
parent
2231d124a6
commit
880488c73e
|
@ -9,13 +9,15 @@ 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, :hidden, :marketing_source, :payee, :accountant #TODO: make admin/instructor/member/etc not accessible
|
||||
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, :marketing_source, :payee, :accountant, :exit_reason, :twitter_url, :facebook_url, :github_url, :website_url, :email_visible, :phone_visible #TODO: make admin/instructor/member/etc not accessible
|
||||
|
||||
has_many :cards
|
||||
has_many :user_certifications
|
||||
has_many :certifications, :through => :user_certifications
|
||||
has_many :payments
|
||||
|
||||
validates_format_of [:twitter_url, :facebook_url, :github_url, :website_url], :with => URI::regexp(%w(http https))
|
||||
|
||||
after_create :send_new_user_email
|
||||
|
||||
def absorb_user(user_to_absorb)
|
||||
|
@ -45,6 +47,7 @@ class User < ActiveRecord::Base
|
|||
user_to_absorb.payments.each {|payment|
|
||||
Rails.logger.info "PAYMENT BEFORE: "+payment.inspect
|
||||
payment.user_id = self.id
|
||||
payment.amount = 0 if payment.amount.nil? # Bypass validation on amount
|
||||
payment.save!
|
||||
Rails.logger.info "PAYMENT AFTER: "+payment.inspect
|
||||
}
|
||||
|
@ -104,6 +107,10 @@ class User < ActiveRecord::Base
|
|||
return "<img src='/#{results[:icon]}#{results[:flair]}-coin.png' title='#{results[:message]}' class='member-status-symbol' />"
|
||||
end
|
||||
|
||||
def last_payment_date
|
||||
self.payments.maximum(:date)
|
||||
end
|
||||
|
||||
def delinquency
|
||||
if self.payments.count > 0
|
||||
paydate = self.payments.maximum(:date)
|
||||
|
|
|
@ -13,11 +13,13 @@
|
|||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<% if ((can? :read, @recent_user_names) && (@recent_user_names.count > 1)) then %>
|
||||
<% if ((can? :read, User) && (@recent_user_names.count > 1)) then %>
|
||||
<h2>New People: <em>(say hi!)</em></h2>
|
||||
<ul>
|
||||
<% @recent_user_names.each do |user| %>
|
||||
<li><%= link_to user.name, user %> <%= raw(user.member_status_symbol) %> <em>(Signed up <%= user.created_at.strftime("%b %d") %>)</em></li>
|
||||
<% if can? :read, user %>
|
||||
<li><%= link_to user.name, user %> <%= raw(user.member_status_symbol) %> <em>(Signed up <%= user.created_at.strftime("%b %d") %>)</em></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Payee</th>
|
||||
<th>User</th>
|
||||
<th>Paid for month <br/>beginning</th>
|
||||
<th>Member level</th>
|
||||
<th>Last Payment</th>
|
||||
<th>Amount</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
|
@ -19,8 +21,10 @@
|
|||
|
||||
<% @payments.each do |payment| %>
|
||||
<tr>
|
||||
<td><%= link_to payment.user.name_with_payee_and_member_level, payment.user unless payment.user.blank? %></td>
|
||||
<td><%= payment.human_date %></td>
|
||||
<td><%= payment.user.payee unless payment.user.blank? %></td>
|
||||
<td><%= link_to payment.user.name, payment.user unless payment.user.blank? %></td>
|
||||
<td><%= payment.user.member_level_string unless payment.user.blank? %></td>
|
||||
<td><%= payment.date %></td>
|
||||
<td><%= payment.amount %></td>
|
||||
<td><%= link_to 'Details', payment %></td>
|
||||
<td><%= link_to 'Edit', edit_payment_path(payment) %></td>
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email %>
|
||||
<%= f.check_box :email_visible %>
|
||||
<%= f.label :email_visible, "Show Email to All Members?" %>
|
||||
</div>
|
||||
<% if @user.id.blank? || !params[:password].nil? %>
|
||||
<div class="field">
|
||||
|
@ -38,6 +40,22 @@
|
|||
<a href="?password=edit">Change Password</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="field">
|
||||
<%= f.label :phone %><br />
|
||||
<%= f.text_field :phone %>
|
||||
<%= f.check_box :phone_visible %>
|
||||
<%= f.label :phone_visible, "Show Phone to All Members?" %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :twitter_url %>
|
||||
<%= f.text_field :twitter_url, :placeholder => "https://twitter.com/heatsynclabs" %><br/>
|
||||
<%= f.label :facebook_url %>
|
||||
<%= f.text_field :facebook_url, :placeholder => "https://www.facebook.com/HeatSyncLabs" %><br/>
|
||||
<%= f.label :github_url %>
|
||||
<%= f.text_field :github_url, :placeholder => "https://github.com/heatsynclabs" %><br/>
|
||||
<%= f.label :website_url %>
|
||||
<%= f.text_field :website_url, :placeholder => "http://www.heatsynclabs.org" %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :waiver %><br />
|
||||
<%= f.date_select :waiver, :include_blank => 'true', :default => 'nil' %>
|
||||
|
@ -69,10 +87,6 @@
|
|||
<%= f.label :payee %><br />
|
||||
<%= f.text_field :payee%>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :phone %><br />
|
||||
<%= f.text_field :phone %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :current_skills, "What skills, knowledge and experience do you bring to the community?" %><br />
|
||||
<%= f.text_area :current_skills %>
|
||||
|
@ -85,6 +99,10 @@
|
|||
<%= f.label :marketing_source, "How'd you find out about HeatSync?" %><br />
|
||||
<%= f.text_area :marketing_source %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :exit_reason, "Reason for Leaving" %><br />
|
||||
<%= f.text_area :exit_reason %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :instructor, "Instructor?" %><br />
|
||||
<%= f.check_box :instructor %>
|
||||
|
|
|
@ -1,31 +1,43 @@
|
|||
<%= image_tag @user.gravatar_url(:default => "http://members.heatsynclabs.org/assets/nil.png") %>
|
||||
|
||||
<p>
|
||||
<%= raw(@user.member_status_symbol) %>
|
||||
<%= link_to image_tag 'twitter.png', @user.twitter_url if @user.twitter_url.present? %>
|
||||
<%= link_to image_tag 'facebook.png', @user.facebook_url if @user.facebook_url.present? %>
|
||||
<%= link_to image_tag 'github.png', @user.github_url if @user.github_url.present? %>
|
||||
<%= link_to image_tag 'website.png', @user.website_url if @user.website_url.present? %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
<%= @user.name %>
|
||||
</p>
|
||||
|
||||
<% if current_user.admin? || @user.email_visible %>
|
||||
<p>
|
||||
<b>Email:</b>
|
||||
<%= @user.email %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if current_user.admin? || @user.phone_visible %>
|
||||
<p>
|
||||
<b>Phone:</b>
|
||||
<%= @user.phone %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<b>Waiver?</b>
|
||||
<%= @user.waiver.strftime("%B %d %Y") unless @user.waiver.blank? %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Current Member?</b>
|
||||
<%= raw(@user.member_status_symbol) %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Instructor?</b>
|
||||
<%= @user.instructor? %>
|
||||
</p>
|
||||
|
||||
<% if current_user.admin? then %>
|
||||
<p>
|
||||
<b>Email:</b>
|
||||
<%= @user.email %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Orientation?</b>
|
||||
<%= @user.orientation.strftime("%B %d %Y") unless @user.orientation.blank? %>
|
||||
|
@ -44,7 +56,7 @@
|
|||
</p>
|
||||
<p>
|
||||
<b>Desired Member Level:</b>
|
||||
<%= @user.member_level %>
|
||||
<%= @user.member_level_string %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Payment Method:</b>
|
||||
|
@ -54,10 +66,6 @@
|
|||
<b>Payee:</b>
|
||||
<%= @user.payee %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Phone:</b>
|
||||
<%= @user.phone %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
<b>Current Skills:</b>
|
||||
|
@ -72,6 +80,10 @@
|
|||
<b>Found HeatSync via:</b>
|
||||
<%= simple_format @user.marketing_source %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Left HeatSync because:</b>
|
||||
<%= simple_format @user.exit_reason %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p>
|
||||
<b>Card: </b><%= link_to "+ Add", (new_card_path+"?user="+@user.id.to_s), :class => 'btn' if can? :create, Card %>
|
||||
|
@ -94,16 +106,24 @@
|
|||
<% if @user.certifications.blank? %><li>n/a</li><% end %>
|
||||
</ul>
|
||||
|
||||
<% if current_user.admin? then %>
|
||||
<p>
|
||||
<b>Payments:</b>
|
||||
<ul>
|
||||
<% @payments.each do |payment| %>
|
||||
<li><%= payment.date %></li>
|
||||
<% if current_user.admin? then %>
|
||||
<b>Payments:</b>
|
||||
<ul>
|
||||
<% @payments.each do |payment| %>
|
||||
<li><%= link_to payment.date, payment %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<b>Last Payment:</b>
|
||||
<% last_payment = @user.delinquency %>
|
||||
<% if last_payment < 30 %>
|
||||
Less than a month ago
|
||||
<% else %>
|
||||
<%= last_payment/30 %> months ago
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if current_user.admin? then %>
|
||||
<p>
|
||||
|
|
5
db/migrate/20130829070500_add_exit_reason_to_users.rb
Normal file
5
db/migrate/20130829070500_add_exit_reason_to_users.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddExitReasonToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :exit_reason, :string
|
||||
end
|
||||
end
|
10
db/migrate/20130829074549_add_social_media_to_users.rb
Normal file
10
db/migrate/20130829074549_add_social_media_to_users.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class AddSocialMediaToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :twitter_url, :string
|
||||
add_column :users, :facebook_url, :string
|
||||
add_column :users, :github_url, :string
|
||||
add_column :users, :website_url, :string
|
||||
add_column :users, :email_visible, :boolean
|
||||
add_column :users, :phone_visible, :boolean
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -1,3 +1,4 @@
|
|||
# encoding: UTF-8
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
|
@ -10,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130828104240) do
|
||||
ActiveRecord::Schema.define(:version => 20130829074549) do
|
||||
|
||||
create_table "cards", :force => true do |t|
|
||||
t.string "card_number"
|
||||
|
@ -155,6 +156,13 @@ ActiveRecord::Schema.define(:version => 20130828104240) do
|
|||
t.string "marketing_source"
|
||||
t.string "payee"
|
||||
t.boolean "accountant"
|
||||
t.string "exit_reason"
|
||||
t.string "twitter_url"
|
||||
t.string "facebook_url"
|
||||
t.string "github_url"
|
||||
t.string "website_url"
|
||||
t.boolean "email_visible"
|
||||
t.boolean "phone_visible"
|
||||
end
|
||||
|
||||
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||
|
|
Loading…
Reference in New Issue
Block a user