diff --git a/app/controllers/contracts_controller.rb b/app/controllers/contracts_controller.rb index 0b66c9c..02c8104 100644 --- a/app/controllers/contracts_controller.rb +++ b/app/controllers/contracts_controller.rb @@ -18,6 +18,7 @@ class ContractsController < ApplicationController def create Rails.logger.info "CONTRACT" Rails.logger.info @contract.inspect + @contract.created_by = current_user.id respond_to do |format| if @contract.save format.html { redirect_to @contract, :notice => 'Contract was successfully created.' } @@ -51,6 +52,6 @@ class ContractsController < ApplicationController end def load_users - @users = @users = User.accessible_by(current_ability).sort_by(&:name) + @users = User.accessible_by(current_ability).sort_by(&:name) end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 61422ed..7f7490c 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,38 +1,53 @@ class HomeController < ApplicationController + layout 'resources' -def index - @num_certs = UserCertification.count - @recent_certs = UserCertification.where("created_at > ?", DateTime.now - 7.days).count - @num_users = User.count - @recent_users = User.where("created_at > ?", DateTime.now - 7.days).count - # Payments: member levels are multipled by 10 to indicate current payment; 25 x 10 = 250 - @num_paid_users = User.all.select{|u| u.member_status >= 250 }.count - @num_plus_users = User.all.select{|u| u.member_status == 1000 }.count - @num_basic_users = User.all.select{|u| u.member_status == 500 }.count - @num_associate_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 - @recent_user_names = User.where("member_level > 10").accessible_by(current_ability).order('created_at desc').limit(5) - end - @num_door_opens = DoorLog.where("key = 'G'").count - @today_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 1.day).count - @recent_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 7.days).count - @num_door_denieds = DoorLog.where("key = 'D'").count - @recent_door_denieds = DoorLog.where("key = 'D' AND created_at > ?", DateTime.now - 1.month).count - @num_logins = User.sum('sign_in_count') - @recent_logins = User.where('current_sign_in_at > ?',Date.today - 7.days).count - @num_macs = Mac.count - @recent_macs = Mac.where("since > ?", DateTime.now - 1.day).count - - respond_to do |format| - format.html # index.html.erb + def index + # Alerts + if user_signed_in? && current_user.orientation.blank? then + flash[: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." + end + if user_signed_in? && current_user.member_status.between?(2,100) then + flash[:alert] = " + Looks like we haven't acknowledged a recent payment for you yet. This could be because we're slow, but if in doubt please see your profile for payment instructions, consider updating your membership level to something accurate, or contact us.
Thanks for supporting us!" end -end -def more_info - respond_to do |format| - format.html # more_info.html.erb + # Fun Stats + + @num_certs = UserCertification.count + @recent_certs = UserCertification.where("created_at > ?", DateTime.now - 7.days).count + @num_users = User.count + @recent_users = User.where("created_at > ?", DateTime.now - 7.days).count + # Payments: member levels are multipled by 10 to indicate current payment; 25 x 10 = 250 + @num_paid_users = User.all.select{|u| u.member_status >= 250 }.count + @num_plus_users = User.all.select{|u| u.member_status == 1000 }.count + @num_basic_users = User.all.select{|u| u.member_status == 500 }.count + @num_associate_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 + @recent_user_names = User.where("member_level > 10").accessible_by(current_ability).order('created_at desc').limit(5) + end + @num_door_opens = DoorLog.where("key = 'G'").count + @today_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 1.day).count + @recent_door_opens = DoorLog.where("key = 'G' AND created_at > ?", DateTime.now - 7.days).count + @num_door_denieds = DoorLog.where("key = 'D'").count + @recent_door_denieds = DoorLog.where("key = 'D' AND created_at > ?", DateTime.now - 1.month).count + @num_logins = User.sum('sign_in_count') + @recent_logins = User.where('current_sign_in_at > ?',Date.today - 7.days).count + @num_macs = Mac.count + @recent_macs = Mac.where("since > ?", DateTime.now - 1.day).count + + respond_to do |format| + format.html # index.html.erb + end + end + + def more_info + respond_to do |format| + format.html # more_info.html.erb + end end -end end diff --git a/app/models/contract.rb b/app/models/contract.rb index a588fe3..5df4b68 100644 --- a/app/models/contract.rb +++ b/app/models/contract.rb @@ -1,6 +1,9 @@ class Contract < ActiveRecord::Base belongs_to :user - attr_accessible :user_id, :first_name, :last_name, :cosigner, :signed_at, :document, :document_file_name, :document_content_type, :document_file_size, :document_updated_at + attr_accessible :user_id, :first_name, :last_name, :cosigner, + :signed_at, :document, :document_file_name, :document_content_type, + :document_file_size, :document_updated_at + # :created_by not accessible for security purposes validates_presence_of :first_name, :signed_at #, :last_name diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 70a0ed8..abdc4e6 100755 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -3,55 +3,43 @@ <%= simple_format Setting.welcome_body %> <% end %> - -<% if user_signed_in? && current_user.orientation.blank? then %> -

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.

-<% end %> -<% if user_signed_in? && current_user.member_status.between?(2,100) then %> -<%= current_user.member.inspect %> -<%= current_user.member_level.inspect %> -

Looks like we haven't acknowledged a recent payment for you yet. This could be because we're slow, or this app just got started, but if in doubt please see your profile for payment instructions, or consider updating your membership level to something accurate.
Thanks for supporting HeatSync!

-<% end %> - - - - - -
-<% if ((can? :read, User) && (@recent_user_names.count > 1)) then %> -

New People: (say hi!)

-
    -<% @recent_user_names.each do |user| %> - <% if can? :read, user %> -
  • <%= link_to user.name, user %> <%= raw(user.member_status_symbol) %> (Signed up <%= user.created_at.strftime("%b %d") %>)
  • +
    + <% if ((can? :read, User) && (@recent_user_names.count > 1)) then %> +

    New People: (say hi!)

    +
      + <% @recent_user_names.each do |user| %> + <% 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 %> -<% end %> -
-<% end %> -

Cool Stats:

-
-
# of People in this DB:
-
<%= @num_users %> (<%= @recent_users %> new in the last 7 days)
-
# of People Certified:
-
<%= @num_certs %> (<%= @recent_certs %> new in the last 7 days)
-
# of Current Paying Members:
-
<%= @num_paid_users %> (<%= @num_plus_users %> plus, <%= @num_basic_users %> basic, <%= @num_associate_users %> associate. <%= @num_delinquent_users %> not-current)
-
# of Door Accesses Granted:
-
<%= @num_door_opens %> (<%= @today_door_opens %> today, <%= @recent_door_opens %> in the last 7 days)
-
# of Door Accesses Denied:
-
<%= @num_door_denieds %> (<%= @recent_door_denieds %> in the last month)
-
# of Members DB Logins:
-
<%= @num_logins %> (<%= @recent_logins %> users last 7 days)
-
# of Computers in this DB:
-
<%= @num_macs %> (<%= @recent_macs %> seen today)
-
+ -
+
+

Cool Stats:

+
+
# of People in this DB:
+
<%= @num_users %> (<%= @recent_users %> new in the last 7 days)
+
# of People Certified:
+
<%= @num_certs %> (<%= @recent_certs %> new in the last 7 days)
+
# of Current Paying Members:
+
<%= @num_paid_users %> (<%= @num_plus_users %> plus, <%= @num_basic_users %> basic, <%= @num_associate_users %> associate. <%= @num_delinquent_users %> not-current)
+
# of Door Accesses Granted:
+
<%= @num_door_opens %> (<%= @today_door_opens %> today, <%= @recent_door_opens %> in the last 7 days)
+
# of Door Accesses Denied:
+
<%= @num_door_denieds %> (<%= @recent_door_denieds %> in the last month)
+
# of Members DB Logins:
+
<%= @num_logins %> (<%= @recent_logins %> users last 7 days)
+
# of Computers in this DB:
+
<%= @num_macs %> (<%= @recent_macs %> seen today)
+
+
-

Member Resources

-<% if can? :access_doors_remotely, :door_access %> -
  • <%= link_to "Remote Door Access", space_api_access_path %>
-<% end %> -<%= simple_format Setting.member_resources_inset %> - -
+
+

Member Resources

+ <% if can? :access_doors_remotely, :door_access %> + + <% end %> + <%= simple_format Setting.member_resources_inset %> +
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1e83331..a7f78e8 100755 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,6 +2,7 @@ hsl_members(<%= controller.controller_name %>.<%= controller.action_name %><%= "["+params[:id]+"]" unless params[:id].blank? %>) + <% if params[:controller] == "resources" %> diff --git a/app/views/layouts/resources.html.erb b/app/views/layouts/resources.html.erb index 2af4f5a..857eef0 100755 --- a/app/views/layouts/resources.html.erb +++ b/app/views/layouts/resources.html.erb @@ -10,6 +10,7 @@ +