diff --git a/app/models/user.rb b/app/models/user.rb index ec6875f..92518b5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 "" end + def last_payment_date + self.payments.maximum(:date) + end + def delinquency if self.payments.count > 0 paydate = self.payments.maximum(:date) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 6be51a1..319a16f 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -13,11 +13,13 @@
-<% if ((can? :read, @recent_user_names) && (@recent_user_names.count > 1)) then %> +<% if ((can? :read, User) && (@recent_user_names.count > 1)) then %>

New People: (say hi!)

    <% @recent_user_names.each do |user| %> -
  • <%= link_to user.name, user %> <%= raw(user.member_status_symbol) %> (Signed up <%= user.created_at.strftime("%b %d") %>)
  • + <% if can? :read, user %> +
  • <%= link_to user.name, user %> <%= raw(user.member_status_symbol) %> (Signed up <%= user.created_at.strftime("%b %d") %>)
  • + <% end %> <% end %>
<% end %> diff --git a/app/views/payments/index.html.erb b/app/views/payments/index.html.erb index a12862a..0a45b4a 100644 --- a/app/views/payments/index.html.erb +++ b/app/views/payments/index.html.erb @@ -9,8 +9,10 @@ + - + + @@ -19,8 +21,10 @@ <% @payments.each do |payment| %> - - + + + + diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 73140e4..963bfb9 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -23,6 +23,8 @@
<%= f.label :email %>
<%= f.email_field :email %> + <%= f.check_box :email_visible %> + <%= f.label :email_visible, "Show Email to All Members?" %>
<% if @user.id.blank? || !params[:password].nil? %>
@@ -38,6 +40,22 @@ Change Password
<% end %> +
+ <%= f.label :phone %>
+ <%= f.text_field :phone %> + <%= f.check_box :phone_visible %> + <%= f.label :phone_visible, "Show Phone to All Members?" %> +
+
+ <%= f.label :twitter_url %> + <%= f.text_field :twitter_url, :placeholder => "https://twitter.com/heatsynclabs" %>
+ <%= f.label :facebook_url %> + <%= f.text_field :facebook_url, :placeholder => "https://www.facebook.com/HeatSyncLabs" %>
+ <%= f.label :github_url %> + <%= f.text_field :github_url, :placeholder => "https://github.com/heatsynclabs" %>
+ <%= f.label :website_url %> + <%= f.text_field :website_url, :placeholder => "http://www.heatsynclabs.org" %> +
<%= f.label :waiver %>
<%= f.date_select :waiver, :include_blank => 'true', :default => 'nil' %> @@ -69,10 +87,6 @@ <%= f.label :payee %>
<%= f.text_field :payee%>
-
- <%= f.label :phone %>
- <%= f.text_field :phone %> -
<%= f.label :current_skills, "What skills, knowledge and experience do you bring to the community?" %>
<%= f.text_area :current_skills %> @@ -85,6 +99,10 @@ <%= f.label :marketing_source, "How'd you find out about HeatSync?" %>
<%= f.text_area :marketing_source %>
+
+ <%= f.label :exit_reason, "Reason for Leaving" %>
+ <%= f.text_area :exit_reason %> +
<%= f.label :instructor, "Instructor?" %>
<%= f.check_box :instructor %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index fe5e953..c3c60c9 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,31 +1,43 @@ <%= image_tag @user.gravatar_url(:default => "http://members.heatsynclabs.org/assets/nil.png") %> +

+ <%= 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? %> +

+

Name: <%= @user.name %>

+<% if current_user.admin? || @user.email_visible %> +

+ Email: + <%= @user.email %> +

+<% end %> + +<% if current_user.admin? || @user.phone_visible %> +

+ Phone: + <%= @user.phone %> +

+<% end %> +

Waiver? <%= @user.waiver.strftime("%B %d %Y") unless @user.waiver.blank? %>

-

- Current Member? - <%= raw(@user.member_status_symbol) %> -

-

Instructor? <%= @user.instructor? %>

<% if current_user.admin? then %> -

- Email: - <%= @user.email %> -

-

Orientation? <%= @user.orientation.strftime("%B %d %Y") unless @user.orientation.blank? %> @@ -44,7 +56,7 @@

Desired Member Level: - <%= @user.member_level %> + <%= @user.member_level_string %>

Payment Method: @@ -54,10 +66,6 @@ Payee: <%= @user.payee %>

-

- Phone: - <%= @user.phone %> -

<% end %>

Current Skills: @@ -72,6 +80,10 @@ Found HeatSync via: <%= simple_format @user.marketing_source %>

+

+ Left HeatSync because: + <%= simple_format @user.exit_reason %> +

<% end %>

Card: <%= 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? %>

  • n/a
  • <% end %> -<% if current_user.admin? then %>

    - Payments: -

      - <% @payments.each do |payment| %> -
    • <%= payment.date %>
    • + <% if current_user.admin? then %> + Payments: +
        + <% @payments.each do |payment| %> +
      • <%= link_to payment.date, payment %>
      • + <% end %> +
      + <% else %> + Last Payment: + <% last_payment = @user.delinquency %> + <% if last_payment < 30 %> + Less than a month ago + <% else %> + <%= last_payment/30 %> months ago + <% end %> <% end %> -

    -<% end %> <% if current_user.admin? then %>

    diff --git a/db/migrate/20130829070500_add_exit_reason_to_users.rb b/db/migrate/20130829070500_add_exit_reason_to_users.rb new file mode 100644 index 0000000..46e238d --- /dev/null +++ b/db/migrate/20130829070500_add_exit_reason_to_users.rb @@ -0,0 +1,5 @@ +class AddExitReasonToUsers < ActiveRecord::Migration + def change + add_column :users, :exit_reason, :string + end +end diff --git a/db/migrate/20130829074549_add_social_media_to_users.rb b/db/migrate/20130829074549_add_social_media_to_users.rb new file mode 100644 index 0000000..8502219 --- /dev/null +++ b/db/migrate/20130829074549_add_social_media_to_users.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 3cb31fb..21e3651 100644 --- a/db/schema.rb +++ b/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

    Payee UserPaid for month
    beginning
    Member levelLast Payment Amount
    <%= link_to payment.user.name_with_payee_and_member_level, payment.user unless payment.user.blank? %><%= payment.human_date %><%= payment.user.payee unless payment.user.blank? %><%= link_to payment.user.name, payment.user unless payment.user.blank? %><%= payment.user.member_level_string unless payment.user.blank? %><%= payment.date %> <%= payment.amount %> <%= link_to 'Details', payment %> <%= link_to 'Edit', edit_payment_path(payment) %>