diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index f7382bf..57e6cad 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 66b4dec..d5df90d 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -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
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index 941dbdd..b04529c 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -1,15 +1,17 @@
HeatSync People
<% 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) %>
diff --git a/app/views/users/new_member_report.html.erb b/app/views/users/new_member_report.html.erb
new file mode 100644
index 0000000..719ed71
--- /dev/null
+++ b/app/views/users/new_member_report.html.erb
@@ -0,0 +1,24 @@
+New Members
+<% if !@new_users.blank? %>
+ <% @new_users.sort_by(&:created_at).reverse!.group_by{|u| u.created_at.beginning_of_month}.each do |g| %>
+ <%= g.first.to_formatted_s(:month_and_year) %>
+ <% g.last.each do |user| %>
+ <%= user.name %> - <%= user.member_level_string %>
+ What skills, knowledge and experience do you bring to the community?
+ <%= user.current_skills %>
+
+
+ What skills, knowledge and experiences are you looking for in HeatSync?
+
+ <%= user.desired_skills %>
+
+
+ How'd you find out about HeatSync?
+
+ <%= user.marketing_source %>
+
+
+ <% end %>
+ <% end %>
+<% end %>
+
diff --git a/config/initializers/dates.rb b/config/initializers/dates.rb
new file mode 100644
index 0000000..cdcc4fc
--- /dev/null
+++ b/config/initializers/dates.rb
@@ -0,0 +1,2 @@
+Date::DATE_FORMATS[:month_and_year] = "%B %Y"
+Time::DATE_FORMATS[:month_and_year] = "%B %Y"
diff --git a/config/routes.rb b/config/routes.rb
index cd58166..2d123e4 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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