Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 25c0d1e1cb | |||
| e8e024c042 | |||
| 10a1e4eb84 | |||
| 211d79cbcd |
35
.rvmrc
Normal file
35
.rvmrc
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
||||||
|
# development environment upon cd'ing into the directory
|
||||||
|
|
||||||
|
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
||||||
|
# Only full ruby name is supported here, for short names use:
|
||||||
|
# echo "rvm use 1.8.7" > .rvmrc
|
||||||
|
environment_id="ruby-1.9.3-p385@members-hsl"
|
||||||
|
|
||||||
|
# Uncomment the following lines if you want to verify rvm version per project
|
||||||
|
# rvmrc_rvm_version="1.18.8 (stable)" # 1.10.1 seams as a safe start
|
||||||
|
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
||||||
|
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
||||||
|
# return 1
|
||||||
|
# }
|
||||||
|
|
||||||
|
# First we attempt to load the desired environment directly from the environment
|
||||||
|
# file. This is very fast and efficient compared to running through the entire
|
||||||
|
# CLI and selector. If you want feedback on which environment was used then
|
||||||
|
# insert the word 'use' after --create as this triggers verbose mode.
|
||||||
|
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
||||||
|
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
||||||
|
then
|
||||||
|
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
||||||
|
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
||||||
|
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
||||||
|
else
|
||||||
|
# If the environment file has not yet been created, use the RVM CLI to select.
|
||||||
|
rvm --create "$environment_id" || {
|
||||||
|
echo "Failed to create RVM environment '${environment_id}'."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
4
Gemfile
4
Gemfile
@@ -1,6 +1,6 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
#ruby '1.9.3'
|
ruby '1.9.3'
|
||||||
|
|
||||||
gem 'rails', '3.2.3'
|
gem 'rails', '3.2.3'
|
||||||
|
|
||||||
@@ -46,3 +46,5 @@ gem 'bcrypt-ruby', '~> 3.0.0'
|
|||||||
|
|
||||||
#gem "paperclip", "~> 3.0"
|
#gem "paperclip", "~> 3.0"
|
||||||
gem 'gravtastic'
|
gem 'gravtastic'
|
||||||
|
|
||||||
|
gem 'passenger'
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ GEM
|
|||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.3.3)
|
coffee-script-source (1.3.3)
|
||||||
|
daemon_controller (1.1.5)
|
||||||
devise (2.1.1)
|
devise (2.1.1)
|
||||||
bcrypt-ruby (~> 3.0)
|
bcrypt-ruby (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
@@ -63,6 +64,10 @@ GEM
|
|||||||
mime-types (1.19)
|
mime-types (1.19)
|
||||||
multi_json (1.3.6)
|
multi_json (1.3.6)
|
||||||
orm_adapter (0.1.0)
|
orm_adapter (0.1.0)
|
||||||
|
passenger (4.0.14)
|
||||||
|
daemon_controller (>= 1.1.0)
|
||||||
|
rack
|
||||||
|
rake (>= 0.8.1)
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
rack (1.4.1)
|
rack (1.4.1)
|
||||||
rack-cache (1.2)
|
rack-cache (1.2)
|
||||||
@@ -124,6 +129,7 @@ DEPENDENCIES
|
|||||||
gravtastic
|
gravtastic
|
||||||
jquery-rails
|
jquery-rails
|
||||||
json
|
json
|
||||||
|
passenger
|
||||||
rails (= 3.2.3)
|
rails (= 3.2.3)
|
||||||
sass-rails (~> 3.2.3)
|
sass-rails (~> 3.2.3)
|
||||||
sqlite3
|
sqlite3
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ def index
|
|||||||
@recent_certs = UserCertification.where("created_at > ?", DateTime.now - 7.days).count
|
@recent_certs = UserCertification.where("created_at > ?", DateTime.now - 7.days).count
|
||||||
@num_users = User.count
|
@num_users = User.count
|
||||||
@recent_users = User.where("created_at > ?", DateTime.now - 7.days).count
|
@recent_users = User.where("created_at > ?", DateTime.now - 7.days).count
|
||||||
|
@num_paid_users = User.all.select{|u| u.member_status >= 250 }.count
|
||||||
|
@num_delinquent_users = User.all.select{|u| !u.payment_status }.count
|
||||||
if can? :read, User then
|
if can? :read, User then
|
||||||
@recent_user_names = User.where("member_level > 10").accessible_by(current_ability).order('created_at desc').limit(5)
|
@recent_user_names = User.where("member_level > 10").accessible_by(current_ability).order('created_at desc').limit(5)
|
||||||
end
|
end
|
||||||
|
|||||||
28
app/controllers/paypal_csvs_controller.rb
Normal file
28
app/controllers/paypal_csvs_controller.rb
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
class PaypalCsvsController < ApplicationController
|
||||||
|
load_and_authorize_resource :paypal_csv
|
||||||
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
PaypalCsv.batch_import_from_csv(params[:file].path)
|
||||||
|
redirect_to paypal_csvs_path, :notice => 'Paypal CSV batch was successfully loaded.'
|
||||||
|
end
|
||||||
|
|
||||||
|
def link
|
||||||
|
result = @paypal_csv.link_payment
|
||||||
|
if result.first
|
||||||
|
redirect_to paypal_csvs_url, :notice => 'Payment was successfully linked.'
|
||||||
|
else
|
||||||
|
redirect_to paypal_csvs_url, :notice => result.last
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -33,6 +33,10 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inactive
|
||||||
|
@users = @users.all.select{|u| u if u.payment_status == false }.sort_by{ |u| -u.delinquency }
|
||||||
|
end
|
||||||
|
|
||||||
# GET /users/1
|
# GET /users/1
|
||||||
# GET /users/1.json
|
# GET /users/1.json
|
||||||
def show
|
def show
|
||||||
|
|||||||
@@ -35,9 +35,11 @@ class Ability
|
|||||||
can :read, UserCertification
|
can :read, UserCertification
|
||||||
end
|
end
|
||||||
|
|
||||||
# Accountants can manage all
|
# Accountants can manage payments
|
||||||
if user.accountant?
|
if user.accountant?
|
||||||
can :manage, Payment
|
can :manage, Payment
|
||||||
|
can :manage, Ipn
|
||||||
|
can :manage, PaypalCsv
|
||||||
end
|
end
|
||||||
|
|
||||||
# Admins can manage all
|
# Admins can manage all
|
||||||
|
|||||||
@@ -5,6 +5,14 @@ class Ipn < ActiveRecord::Base
|
|||||||
|
|
||||||
after_create :create_payment
|
after_create :create_payment
|
||||||
|
|
||||||
|
def date_parsed
|
||||||
|
begin
|
||||||
|
Date.strptime(self.payment_date, "%H:%M:%S %b %e, %Y %Z")
|
||||||
|
rescue
|
||||||
|
Date.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.new_from_dynamic_params(params)
|
def self.new_from_dynamic_params(params)
|
||||||
ipn = Ipn.new()
|
ipn = Ipn.new()
|
||||||
|
|
||||||
@@ -37,6 +45,7 @@ class Ipn < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
unless response == "VERIFIED"
|
unless response == "VERIFIED"
|
||||||
Rails.logger.error "Invalid IPN: #{response}"
|
Rails.logger.error "Invalid IPN: #{response}"
|
||||||
|
Rails.logger.error "Data: #{self.data}"
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -50,8 +59,8 @@ class Ipn < ActiveRecord::Base
|
|||||||
private
|
private
|
||||||
def create_payment
|
def create_payment
|
||||||
# find user by email, then by payee
|
# find user by email, then by payee
|
||||||
user = User.find_by_email(self.payer_email)
|
user = User.where("lower(email) = ?", self._from_email_address.downcase).first
|
||||||
user = User.find_by_payee(self.payer_email) if user.nil? && self.payer_email.present?
|
user = User.where("lower(payee) = ?", self._from_email_address.downcase).first if user.nil? && self._from_email_address.present?
|
||||||
|
|
||||||
# Only create payments if the IPN matches a member
|
# Only create payments if the IPN matches a member
|
||||||
if user.present?
|
if user.present?
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
class Payment < ActiveRecord::Base
|
class Payment < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_one :ipn
|
has_one :ipn
|
||||||
|
has_one :paypal_csv
|
||||||
attr_accessible :date, :user_id, :created_by, :amount
|
attr_accessible :date, :user_id, :created_by, :amount
|
||||||
|
|
||||||
validates_presence_of :user_id, :date, :amount # not created_by
|
validates_presence_of :user_id, :date, :amount # not created_by
|
||||||
validates_uniqueness_of :date, :scope => :user_id, :message => ' of payment already exists for this user.'
|
validates_uniqueness_of :date, :scope => :user_id, :message => ' of payment already exists for this user.'
|
||||||
|
|
||||||
|
|
||||||
def human_date
|
def human_date
|
||||||
if date.year < DateTime.now.year
|
if date.year < DateTime.now.year
|
||||||
date.strftime("%b %e, %y")
|
date.strftime("%b %e, %y")
|
||||||
|
|||||||
73
app/models/paypal_csv.rb
Normal file
73
app/models/paypal_csv.rb
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
require 'csv'
|
||||||
|
class PaypalCsv < ActiveRecord::Base
|
||||||
|
attr_accessible :data, :_address_status, :_counterparty_status, :_currency, :_fee, :_from_email_address, :_gross, :_item_id, :_item_title, :_name, :_net, :_status, :_time, :_time_zone, :_to_email_address, :_transaction_id, :_type, :date, :string
|
||||||
|
belongs_to :payment
|
||||||
|
|
||||||
|
after_create :create_payment
|
||||||
|
|
||||||
|
def date_parsed
|
||||||
|
begin
|
||||||
|
Date.strptime(self._date, "%m/%d/%Y")
|
||||||
|
rescue
|
||||||
|
Date.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.batch_import_from_csv(filename)
|
||||||
|
csv = CSV.table(filename)
|
||||||
|
csv.each do |row|
|
||||||
|
paypal_csv = PaypalCsv.new()
|
||||||
|
|
||||||
|
paypal_csv.attributes.each do |c|
|
||||||
|
unless row[c.first.to_sym].nil?
|
||||||
|
paypal_csv[c.first.to_sym] = row[c.first.to_sym]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
paypal_csv.data = row.to_json
|
||||||
|
paypal_csv.save
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_payment
|
||||||
|
create_payment
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def create_payment
|
||||||
|
# find user by email, then by payee
|
||||||
|
user = User.where("lower(email) = ?", self._from_email_address.downcase).first
|
||||||
|
user = User.where("lower(payee) = ?", self._from_email_address.downcase).first if user.nil? && self._from_email_address.present?
|
||||||
|
|
||||||
|
# Only create payments if the CSV matches a member
|
||||||
|
if user.present?
|
||||||
|
# And is a payment (not a cancellation, etc)
|
||||||
|
payment_types = ["Recurring Payment Received","Payment Received"]
|
||||||
|
if payment_types.include?(self._type)
|
||||||
|
# And a member level
|
||||||
|
if User.member_levels[self._gross.to_i].present?
|
||||||
|
payment = Payment.new
|
||||||
|
payment.date = Date.strptime(self._date, "%m/%d/%Y") #7/6/2013 for Jul 06
|
||||||
|
payment.user_id = user.id
|
||||||
|
payment.amount = self._gross
|
||||||
|
if payment.save
|
||||||
|
self.payment_id = payment.id
|
||||||
|
self.save!
|
||||||
|
else
|
||||||
|
return [false, "Unable to link payment. Payment error: #{payment.errors.full_messages.first}"]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return [false, "Unable to link payment. Couldn't find membership level '#{self._gross.to_i}'."]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return [false, "Unable to link payment. Transaction is a '#{self._type}' instead of '#{payment_types.inspect}'."]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return [false, "Unable to link payment. Couldn't find user/payee '#{self._from_email_address}'."]
|
||||||
|
end
|
||||||
|
|
||||||
|
return [true]
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -89,6 +89,11 @@ class User < ActiveRecord::Base
|
|||||||
{25 => "Associate", 50 => "Basic", 75 => "Basic", 100 => "Plus"}
|
{25 => "Associate", 50 => "Basic", 75 => "Basic", 100 => "Plus"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def payment_status
|
||||||
|
results = payment_status_calculation
|
||||||
|
return results[:paid]
|
||||||
|
end
|
||||||
|
|
||||||
def member_status
|
def member_status
|
||||||
results = member_status_calculation
|
results = member_status_calculation
|
||||||
return results[:rank]
|
return results[:rank]
|
||||||
@@ -99,6 +104,15 @@ class User < ActiveRecord::Base
|
|||||||
return "<img src='/#{results[:icon]}#{results[:flair]}-coin.png' title='#{results[:message]}' />"
|
return "<img src='/#{results[:icon]}#{results[:flair]}-coin.png' title='#{results[:message]}' />"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delinquency
|
||||||
|
if self.payments.count > 0
|
||||||
|
paydate = self.payments.maximum(:date)
|
||||||
|
(Date.today - paydate).to_i
|
||||||
|
else
|
||||||
|
(Date.today - self.created_at.to_date).to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def member_status_calculation
|
def member_status_calculation
|
||||||
@@ -112,7 +126,7 @@ class User < ActiveRecord::Base
|
|||||||
case self.member_level.to_i
|
case self.member_level.to_i
|
||||||
when 0..9
|
when 0..9
|
||||||
if self.payments.count > 0 then
|
if self.payments.count > 0 then
|
||||||
message = "Former Member (#{(DateTime.now - self.payments.last.date).to_i} days ago)"
|
message = "Former Member (#{(DateTime.now - self.payments.maximum(:date)).to_i/30} months ago)"
|
||||||
icon = :timeout
|
icon = :timeout
|
||||||
rank = 1
|
rank = 1
|
||||||
else
|
else
|
||||||
@@ -138,26 +152,40 @@ class User < ActiveRecord::Base
|
|||||||
rank = 1000
|
rank = 1000
|
||||||
end
|
end
|
||||||
|
|
||||||
|
payment_results = payment_status_calculation
|
||||||
|
flair = payment_results[:flair]
|
||||||
|
rank = rank/10 unless payment_results[:paid]
|
||||||
|
message = payment_results[:message] unless payment_results[:message].blank?
|
||||||
|
|
||||||
|
return {:message => message, :icon => icon, :flair => flair, :rank => rank}
|
||||||
|
end
|
||||||
|
|
||||||
|
def payment_status_calculation
|
||||||
|
flair = ""
|
||||||
|
message = ""
|
||||||
|
paid = true
|
||||||
|
|
||||||
# Second status item is payment status
|
# Second status item is payment status
|
||||||
case self.member_level.to_i
|
case self.member_level.to_i
|
||||||
when 25..999
|
when 25..999
|
||||||
# There are payments
|
# There are payments
|
||||||
if self.payments.count > 0 then
|
if self.payments.count > 0 then
|
||||||
# They're on time
|
# They're on time
|
||||||
if self.payments.last.date > (DateTime.now - 60.days)
|
if self.payments.maximum(:date) > (DateTime.now - 60.days)
|
||||||
flair = "-paid"
|
flair = "-paid"
|
||||||
|
paid = true
|
||||||
else
|
else
|
||||||
message = "Last Payment #{(DateTime.now - self.payments.last.date).to_i/30} months ago"
|
message = "Last Payment #{(DateTime.now - self.payments.maximum(:date)).to_i/30} months ago"
|
||||||
rank = rank/10
|
paid = false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
message = "No Payments Recorded"
|
message = "No Payments Recorded"
|
||||||
rank = rank/10
|
paid = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return {:message => message, :paid => paid, :flair => flair}
|
||||||
|
end
|
||||||
|
|
||||||
return {:message => message, :icon => icon, :flair => flair, :rank => rank}
|
|
||||||
end
|
|
||||||
|
|
||||||
def send_new_user_email
|
def send_new_user_email
|
||||||
Rails.logger.info UserMailer.new_user_email(self).deliver
|
Rails.logger.info UserMailer.new_user_email(self).deliver
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
<dd><%= @num_users %> (<%= @recent_users %> new in the last 7 days)</dd>
|
<dd><%= @num_users %> (<%= @recent_users %> new in the last 7 days)</dd>
|
||||||
<dt># of People Certified:</dt>
|
<dt># of People Certified:</dt>
|
||||||
<dd><%= @num_certs %> (<%= @recent_certs %> new in the last 7 days)</dd>
|
<dd><%= @num_certs %> (<%= @recent_certs %> new in the last 7 days)</dd>
|
||||||
|
<dt># of Current Paying Members:</dt>
|
||||||
|
<dd><%= @num_paid_users %> (<%= @num_delinquent_users %> not-current)</dd>
|
||||||
<dt># of Door Accesses Granted:</dt>
|
<dt># of Door Accesses Granted:</dt>
|
||||||
<dd><%= @num_door_opens %> (<%= @today_door_opens %> today, <%= @recent_door_opens %> in the last 7 days)</dd>
|
<dd><%= @num_door_opens %> (<%= @today_door_opens %> today, <%= @recent_door_opens %> in the last 7 days)</dd>
|
||||||
<dt># of Door Accesses Denied:</dt>
|
<dt># of Door Accesses Denied:</dt>
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<html><body>
|
<h2>PayPal IPN Records</h2>
|
||||||
|
<p>
|
||||||
|
<em>Automatically loaded from PayPal's servers</em>
|
||||||
|
</p>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
@@ -6,7 +9,7 @@
|
|||||||
<th>Item</th>
|
<th>Item</th>
|
||||||
<th>Amount</th>
|
<th>Amount</th>
|
||||||
</tr>
|
</tr>
|
||||||
<% @ipns.reverse!.each do |ipn| %>
|
<% @ipns.sort_by(&:date_parsed).reverse!.each do |ipn| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= ipn.payment_date %></td>
|
<td><%= ipn.payment_date %></td>
|
||||||
<td><%= ipn.first_name %> <%= ipn.last_name %></td>
|
<td><%= ipn.first_name %> <%= ipn.last_name %></td>
|
||||||
@@ -30,4 +33,3 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
</body></html>
|
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
<h1>Listing payments</h1>
|
<h1>Listing payments</h1>
|
||||||
|
|
||||||
<%= link_to 'New Payment', new_payment_path %>
|
<p>
|
||||||
<br />
|
<b>Create Payments:</b>
|
||||||
|
<%= link_to 'Manually', new_payment_path %> |
|
||||||
|
<%= link_to 'Batched CSV', paypal_csvs_path %> |
|
||||||
|
<%= link_to 'IPN', ipns_path %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
|
|||||||
@@ -35,7 +35,12 @@
|
|||||||
|
|
||||||
<% if @payment.ipn.present? %>
|
<% if @payment.ipn.present? %>
|
||||||
<p>
|
<p>
|
||||||
<%= link_to "Paid via PayPal", @payment.ipn %>
|
<%= link_to "Paid via PayPal (IPN)", @payment.ipn %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% if @payment.paypal_csv.present? %>
|
||||||
|
<p>
|
||||||
|
<%= link_to "Paid via PayPal (CSV)", @payment.paypal_csv %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
35
app/views/paypal_csvs/index.html.erb
Normal file
35
app/views/paypal_csvs/index.html.erb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<h2>PayPal CSV Records</h2>
|
||||||
|
<p>
|
||||||
|
<%= link_to "Upload CSV", new_paypal_csv_path %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Item</th>
|
||||||
|
<th>Amount</th>
|
||||||
|
</tr>
|
||||||
|
<% @paypal_csvs.sort_by(&:date_parsed).reverse!.each do |paypal_csv| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= paypal_csv.date %></td>
|
||||||
|
<td><%= paypal_csv._name %></td>
|
||||||
|
<td><%= paypal_csv._item_title %></td>
|
||||||
|
<td>
|
||||||
|
<% if paypal_csv._gross.blank? %>
|
||||||
|
<%= paypal_csv._type %>
|
||||||
|
<% else %>
|
||||||
|
<%= paypal_csv._gross %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if paypal_csv.payment.present? %>
|
||||||
|
<%= link_to "Linked Payment", paypal_csv.payment %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to "Try to link email '#{paypal_csv._from_email_address}' at membership level '#{paypal_csv._gross.to_i}'", link_paypal_csv_path(paypal_csv) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td><%= link_to "Details", paypal_csv %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
15
app/views/paypal_csvs/new.html.erb
Normal file
15
app/views/paypal_csvs/new.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<style type="text/css">
|
||||||
|
label {
|
||||||
|
width: 10em;
|
||||||
|
display: inline-block;}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<%= form_tag('/paypal_csvs', :multipart => true) do |f| %>
|
||||||
|
<div class="field">
|
||||||
|
<%= label_tag :file %>
|
||||||
|
<%= file_field_tag :file %>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<%= submit_tag %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
17
app/views/paypal_csvs/show.html.erb
Normal file
17
app/views/paypal_csvs/show.html.erb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<h2>PayPal CSV Item Details</h2>
|
||||||
|
<% @paypal_csv.attributes.except("data","payment_id").each do |attr| %>
|
||||||
|
<p>
|
||||||
|
<b><%= attr.first.to_s %>:</b>
|
||||||
|
<%= @paypal_csv.attributes[attr.first] %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<% if @paypal_csv.payment.present? %>
|
||||||
|
<%= link_to "Linked Payment", @paypal_csv.payment %>
|
||||||
|
<% else %>
|
||||||
|
<span class="alert">Couldn't link automatically. Please create payment manually or adjust the user account and try again to <%= link_to "link email '#{@paypal_csv._from_email_address}' at membership level '#{@paypal_csv._gross.to_i}'", link_paypal_csv_path(@paypal_csv) %>.</span>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<%= link_to "Back", paypal_csvs_path %>
|
||||||
65
app/views/users/inactive.html.erb
Normal file
65
app/views/users/inactive.html.erb
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<h1>Inactive Users</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<col />
|
||||||
|
<col />
|
||||||
|
<% if current_user.admin? then %><col /><% end %>
|
||||||
|
<col />
|
||||||
|
<% if current_user.admin? %><col />
|
||||||
|
<col class="col_highlight" /><% end %>
|
||||||
|
<col />
|
||||||
|
<col class="col_highlight" />
|
||||||
|
<col />
|
||||||
|
<col class="col_highlight" />
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>Name</th>
|
||||||
|
<% if current_user.admin? then %><th>Email</th><% end %>
|
||||||
|
<th>Certifications</th>
|
||||||
|
<% if current_user.admin? then %>
|
||||||
|
<th>Orientation?</th>
|
||||||
|
<% end %>
|
||||||
|
<th>Card?</th>
|
||||||
|
<th>Pmt Method</th>
|
||||||
|
<th>Desired Level</th>
|
||||||
|
<th>Last Payment</th>
|
||||||
|
<th>Joined</th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% if !@users.blank? %>
|
||||||
|
<% @users.each do |user| %>
|
||||||
|
<tr<%= " class='hidden'" if user.hidden? %>>
|
||||||
|
<td><%= image_tag user.gravatar_url(:default => "http://members.heatsynclabs.org/assets/nil.png"), :class => :avatar %></td>
|
||||||
|
<td><%= link_to user.name, user %></td>
|
||||||
|
<% if current_user.admin? then %><td><%= user.email %></td><% end %>
|
||||||
|
<td><% user.certifications.each do |c| %>
|
||||||
|
<%= link_to c.name, c %><%= "," unless c.id == user.certifications.last.id %>
|
||||||
|
<% end %></td>
|
||||||
|
<% if current_user.admin? then %><td>
|
||||||
|
<%= unless user.orientation.blank? then raw("<span class='hoverinfo' title='"+user.orientation.strftime("%B %d %Y")+"'>✓</span>") end %>
|
||||||
|
</td><% end %>
|
||||||
|
<td><%= unless user.cards.blank? then raw("<span class='iconinfo'>✓</span>") end %></td>
|
||||||
|
<td><%= user.payment_method %></td>
|
||||||
|
<td><%= user.member_level %></td>
|
||||||
|
<td><% delinquency = user.delinquency %>
|
||||||
|
<% if delinquency == 9999 %>
|
||||||
|
No Payments
|
||||||
|
<% else %>
|
||||||
|
<%= (delinquency/30).to_s+" mo. ago" %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td><%= user.created_at.to_date %></td>
|
||||||
|
<td><%= link_to 'Edit', edit_user_path(user) if can? :update, user %></td>
|
||||||
|
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure? WARNING: THIS DOES NOT REMOVE THE USER FROM THE DOOR SYSTEM! DISABLE THEM FIRST.', :method => :delete if can? :destroy, user %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<% if current_user.orientation.blank? then %>
|
||||||
|
<p class="alert">There's a lot more to see here, but our records show you haven't completed the new member orientation yet. If that's incorrect, please contact a volunteer.</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<br />
|
||||||
@@ -6,6 +6,9 @@
|
|||||||
<% if can? :manage, User %>
|
<% if can? :manage, User %>
|
||||||
| <%= link_to 'Merge Users', users_merge_path %>
|
| <%= link_to 'Merge Users', users_merge_path %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if current_user.admin? %>
|
||||||
|
| <%= link_to 'Inactive Users', users_inactive_path %>
|
||||||
|
<% end %>
|
||||||
<table>
|
<table>
|
||||||
<col />
|
<col />
|
||||||
<col />
|
<col />
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ Dooraccess::Application.routes.draw do
|
|||||||
match 'ipns/:id/link' => 'ipns#link', :as => :link_ipn
|
match 'ipns/:id/link' => 'ipns#link', :as => :link_ipn
|
||||||
match 'ipns/:id/validate' => 'ipns#validate', :as => :validate_ipn
|
match 'ipns/:id/validate' => 'ipns#validate', :as => :validate_ipn
|
||||||
|
|
||||||
|
resources :paypal_csvs
|
||||||
|
match 'paypal_csvs/:id/link' => 'paypal_csvs#link', :as => :link_paypal_csv
|
||||||
|
|
||||||
resources :payments
|
resources :payments
|
||||||
|
|
||||||
resources :user_certifications
|
resources :user_certifications
|
||||||
@@ -25,6 +28,7 @@ Dooraccess::Application.routes.draw do
|
|||||||
match 'user_summary/:id' => 'users#user_summary' # User summary view
|
match 'user_summary/:id' => 'users#user_summary' # User summary view
|
||||||
match 'users/merge' => 'users#merge_view', :via => :get # Merge view
|
match 'users/merge' => 'users#merge_view', :via => :get # Merge view
|
||||||
match 'users/merge' => 'users#merge_action', :via => :post # Merge action
|
match 'users/merge' => 'users#merge_action', :via => :post # Merge action
|
||||||
|
match 'users/inactive' => 'users#inactive' # Inactive users report
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
28
db/migrate/20130828104240_create_paypal_csvs.rb
Normal file
28
db/migrate/20130828104240_create_paypal_csvs.rb
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
class CreatePaypalCsvs < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :paypal_csvs do |t|
|
||||||
|
t.integer :payment_id
|
||||||
|
t.text :data
|
||||||
|
t.string :date
|
||||||
|
t.string :_time
|
||||||
|
t.string :_time_zone
|
||||||
|
t.string :_name
|
||||||
|
t.string :_type
|
||||||
|
t.string :_status
|
||||||
|
t.string :_currency
|
||||||
|
t.string :_gross
|
||||||
|
t.string :_fee
|
||||||
|
t.string :_net
|
||||||
|
t.string :_from_email_address
|
||||||
|
t.string :_to_email_address
|
||||||
|
t.string :_transaction_id
|
||||||
|
t.string :_counterparty_status
|
||||||
|
t.string :_address_status
|
||||||
|
t.string :_item_title
|
||||||
|
t.string :_item_id
|
||||||
|
t.string :string
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
27
db/schema.rb
27
db/schema.rb
@@ -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 => 20130824072157) do
|
ActiveRecord::Schema.define(:version => 20130828104240) do
|
||||||
|
|
||||||
create_table "cards", :force => true do |t|
|
create_table "cards", :force => true do |t|
|
||||||
t.string "card_number"
|
t.string "card_number"
|
||||||
@@ -90,6 +90,31 @@ ActiveRecord::Schema.define(:version => 20130824072157) do
|
|||||||
|
|
||||||
add_index "payments", ["user_id"], :name => "index_payments_on_user_id"
|
add_index "payments", ["user_id"], :name => "index_payments_on_user_id"
|
||||||
|
|
||||||
|
create_table "paypal_csvs", :force => true do |t|
|
||||||
|
t.integer "payment_id"
|
||||||
|
t.text "data"
|
||||||
|
t.string "date"
|
||||||
|
t.string "_time"
|
||||||
|
t.string "_time_zone"
|
||||||
|
t.string "_name"
|
||||||
|
t.string "_type"
|
||||||
|
t.string "_status"
|
||||||
|
t.string "_currency"
|
||||||
|
t.string "_gross"
|
||||||
|
t.string "_fee"
|
||||||
|
t.string "_net"
|
||||||
|
t.string "_from_email_address"
|
||||||
|
t.string "_to_email_address"
|
||||||
|
t.string "_transaction_id"
|
||||||
|
t.string "_counterparty_status"
|
||||||
|
t.string "_address_status"
|
||||||
|
t.string "_item_title"
|
||||||
|
t.string "_item_id"
|
||||||
|
t.string "string"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "user_certifications", :force => true do |t|
|
create_table "user_certifications", :force => true do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "certification_id"
|
t.integer "certification_id"
|
||||||
|
|||||||
41
test/fixtures/paypal_csvs.yml
vendored
Normal file
41
test/fixtures/paypal_csvs.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
date: MyString
|
||||||
|
_time: MyString
|
||||||
|
_time_zone: MyString
|
||||||
|
_name: MyString
|
||||||
|
_type: MyString
|
||||||
|
_status: MyString
|
||||||
|
_currency: MyString
|
||||||
|
_gross: MyString
|
||||||
|
_fee: MyString
|
||||||
|
_net: MyString
|
||||||
|
_from_email_address: MyString
|
||||||
|
_to_email_address: MyString
|
||||||
|
_transaction_id: MyString
|
||||||
|
_counterparty_status: MyString
|
||||||
|
_address_status: MyString
|
||||||
|
_item_title: MyString
|
||||||
|
_item_id: MyString
|
||||||
|
string: MyString
|
||||||
|
|
||||||
|
two:
|
||||||
|
date: MyString
|
||||||
|
_time: MyString
|
||||||
|
_time_zone: MyString
|
||||||
|
_name: MyString
|
||||||
|
_type: MyString
|
||||||
|
_status: MyString
|
||||||
|
_currency: MyString
|
||||||
|
_gross: MyString
|
||||||
|
_fee: MyString
|
||||||
|
_net: MyString
|
||||||
|
_from_email_address: MyString
|
||||||
|
_to_email_address: MyString
|
||||||
|
_transaction_id: MyString
|
||||||
|
_counterparty_status: MyString
|
||||||
|
_address_status: MyString
|
||||||
|
_item_title: MyString
|
||||||
|
_item_id: MyString
|
||||||
|
string: MyString
|
||||||
7
test/unit/paypal_csv_test.rb
Normal file
7
test/unit/paypal_csv_test.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class PaypalCsvTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user