Adding new member report

This commit is contained in:
Will Bradley 2013-10-05 19:53:31 -07:00
parent d61289abaf
commit 04bab84293
6 changed files with 39 additions and 5 deletions

View File

@ -54,6 +54,11 @@ class UsersController < ApplicationController
@new_users = User.where(:created_at => 3.months.ago..Date.today)
@cardless_users = User.includes('cards').where(['users.member_level >= ?','50']).where('cards.id IS NULL')
end
# New members (for emailing out)
def new_member_report
@new_users = User.where(:created_at => 3.months.ago..Date.today).where(:hidden => false).where(['member_level >= ?','1'])
end
# GET /users/1
# GET /users/1.json

View File

@ -13,7 +13,7 @@ class Ability
can :read_details, Mac
can [:update], Mac, :user_id => nil
can [:create,:update], Mac, :user_id => user.id
can :read, User, :id => user.id #TODO: why can users update themselves?
can [:read,:new_member_report], User, :id => user.id #TODO: why can users update themselves? Maybe because Devise doesn't check users/edit?
can :read, UserCertification, :user_id => user.id
# Instructors can manage certs and see users

View File

@ -1,15 +1,17 @@
<h1>HeatSync People</h1>
<% if can? :create, User %>
<%= link_to 'New User', new_user_path %>
<%= link_to 'New User', new_user_path %> |
<% end %>
<% if can? :manage, User %>
| <%= link_to 'Merge Users', users_merge_path %>
<%= link_to 'Merge Users', users_merge_path %> |
<% end %>
<% if current_user.admin? %>
| <%= link_to 'Inactive Users', users_inactive_path %>
| <%= link_to 'Recent Activity', users_activity_path %>
<%= link_to 'Inactive Users', users_inactive_path %> |
<%= link_to 'Recent Activity', users_activity_path %> |
<% end %>
<%= link_to 'New Members Report', users_new_member_report_path %>
<% @certifications = Certification.all.sort_by(&:id) %>
<table>
<col />

View File

@ -0,0 +1,24 @@
<h1>New Members</h1>
<% if !@new_users.blank? %>
<% @new_users.sort_by(&:created_at).reverse!.group_by{|u| u.created_at.beginning_of_month}.each do |g| %>
<h2><%= g.first.to_formatted_s(:month_and_year) %></h2>
<% g.last.each do |user| %>
<p><b><%= user.name %> - <%= user.member_level_string %></b></p>
<p><b>What skills, knowledge and experience do you bring to the community?</b><br/>
<%= user.current_skills %>
</p>
<p><b>
What skills, knowledge and experiences are you looking for in HeatSync?
</b><br/>
<%= user.desired_skills %>
</p>
<p><b>
How'd you find out about HeatSync?
</b><br/>
<%= user.marketing_source %>
</p>
<p>&nbsp;</p>
<% end %>
<% end %>
<% end %>

View File

@ -0,0 +1,2 @@
Date::DATE_FORMATS[:month_and_year] = "%B %Y"
Time::DATE_FORMATS[:month_and_year] = "%B %Y"

View File

@ -31,6 +31,7 @@ Dooraccess::Application.routes.draw do
match 'user_summary/:id' => 'users#user_summary' # User summary view
match 'users/activity' => 'users#activity' # User activity
match 'users/new_member_report' => 'users#new_member_report' # New member report (For emailing)
match 'users/merge' => 'users#merge_view', :via => :get # Merge view
match 'users/merge' => 'users#merge_action', :via => :post # Merge action
match 'users/inactive' => 'users#inactive' # Inactive users report