Fixing issue #19 and also styling homepage

This commit is contained in:
Will Bradley 2014-04-10 19:45:29 -07:00
parent 83442c4bff
commit 13e72fef23
8 changed files with 98 additions and 83 deletions

View File

@ -18,6 +18,7 @@ class ContractsController < ApplicationController
def create def create
Rails.logger.info "CONTRACT" Rails.logger.info "CONTRACT"
Rails.logger.info @contract.inspect Rails.logger.info @contract.inspect
@contract.created_by = current_user.id
respond_to do |format| respond_to do |format|
if @contract.save if @contract.save
format.html { redirect_to @contract, :notice => 'Contract was successfully created.' } format.html { redirect_to @contract, :notice => 'Contract was successfully created.' }
@ -51,6 +52,6 @@ class ContractsController < ApplicationController
end end
def load_users def load_users
@users = @users = User.accessible_by(current_ability).sort_by(&:name) @users = User.accessible_by(current_ability).sort_by(&:name)
end end
end end

View File

@ -1,38 +1,53 @@
class HomeController < ApplicationController class HomeController < ApplicationController
layout 'resources'
def index def index
@num_certs = UserCertification.count # Alerts
@recent_certs = UserCertification.where("created_at > ?", DateTime.now - 7.days).count if user_signed_in? && current_user.orientation.blank? then
@num_users = User.count 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."
@recent_users = User.where("created_at > ?", DateTime.now - 7.days).count end
# Payments: member levels are multipled by 10 to indicate current payment; 25 x 10 = 250 if user_signed_in? && current_user.member_status.between?(2,100) then
@num_paid_users = User.all.select{|u| u.member_status >= 250 }.count flash[:alert] = "<!--
@num_plus_users = User.all.select{|u| u.member_status == 1000 }.count Member: <%= current_user.member.inspect
@num_basic_users = User.all.select{|u| u.member_status == 500 }.count Level: <%= current_user.member_level.inspect
@num_associate_users = User.all.select{|u| u.member_status == 250 }.count -->
@num_delinquent_users = User.all.select{|u| !u.payment_status }.count 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.<br/>Thanks for supporting us!"
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
end
def more_info # Fun Stats
respond_to do |format|
format.html # more_info.html.erb @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
end end

View File

@ -1,6 +1,9 @@
class Contract < ActiveRecord::Base class Contract < ActiveRecord::Base
belongs_to :user 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 validates_presence_of :first_name, :signed_at #, :last_name

View File

@ -3,55 +3,43 @@
<%= simple_format Setting.welcome_body %> <%= simple_format Setting.welcome_body %>
<% end %> <% end %>
<div class="col-sm-4">
<% if user_signed_in? && current_user.orientation.blank? then %> <% if ((can? :read, User) && (@recent_user_names.count > 1)) 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> <h2>New People: <em>(say hi!)</em></h2>
<% end %> <ul>
<% if user_signed_in? && current_user.member_status.between?(2,100) then %> <% @recent_user_names.each do |user| %>
<%= current_user.member.inspect %> <% if can? :read, user %>
<%= current_user.member_level.inspect %> <li><%= link_to user.name, user %> <%= raw(user.member_status_symbol) %> <em>(Signed up <%= user.created_at.strftime("%b %d") %>)</em></li>
<p class="alert">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.<br/>Thanks for supporting HeatSync!</p> <% end %>
<% end %> <% end %>
<table> </ul>
<tr>
<td>
<% if ((can? :read, User) && (@recent_user_names.count > 1)) then %>
<h2>New People: <em>(say hi!)</em></h2>
<ul>
<% @recent_user_names.each do |user| %>
<% if can? :read, user %>
<li><%= link_to user.name, user %> <%= raw(user.member_status_symbol) %> <em>(Signed up <%= user.created_at.strftime("%b %d") %>)</em></li>
<% end %> <% end %>
<% end %> </div>
</ul>
<% end %>
<h2>Cool Stats:</h2>
<dl>
<dt># of People in this DB:</dt>
<dd><%= @num_users %> (<%= @recent_users %> new in the last 7 days)</dd>
<dt># of People Certified:</dt>
<dd><%= @num_certs %> (<%= @recent_certs %> new in the last 7 days)</dd>
<dt># of Current Paying Members:</dt>
<dd><%= @num_paid_users %> (<%= @num_plus_users %> plus, <%= @num_basic_users %> basic, <%= @num_associate_users %> associate. <%= @num_delinquent_users %> not-current)</dd>
<dt># of Door Accesses Granted:</dt>
<dd><%= @num_door_opens %> (<%= @today_door_opens %> today, <%= @recent_door_opens %> in the last 7 days)</dd>
<dt># of Door Accesses Denied:</dt>
<dd><%= @num_door_denieds %> (<%= @recent_door_denieds %> in the last month)</dd>
<dt># of Members DB Logins:</dt>
<dd><%= @num_logins %> (<%= @recent_logins %> users last 7 days)</dd>
<dt># of Computers in this DB:</dt>
<dd><%= @num_macs %> (<%= @recent_macs %> seen today)</dd>
</dl>
</td> <div class="col-sm-4">
<td> <h2>Cool Stats:</h2>
<dl>
<dt># of People in this DB:</dt>
<dd><%= @num_users %> (<%= @recent_users %> new in the last 7 days)</dd>
<dt># of People Certified:</dt>
<dd><%= @num_certs %> (<%= @recent_certs %> new in the last 7 days)</dd>
<dt># of Current Paying Members:</dt>
<dd><%= @num_paid_users %> (<%= @num_plus_users %> plus, <%= @num_basic_users %> basic, <%= @num_associate_users %> associate. <%= @num_delinquent_users %> not-current)</dd>
<dt># of Door Accesses Granted:</dt>
<dd><%= @num_door_opens %> (<%= @today_door_opens %> today, <%= @recent_door_opens %> in the last 7 days)</dd>
<dt># of Door Accesses Denied:</dt>
<dd><%= @num_door_denieds %> (<%= @recent_door_denieds %> in the last month)</dd>
<dt># of Members DB Logins:</dt>
<dd><%= @num_logins %> (<%= @recent_logins %> users last 7 days)</dd>
<dt># of Computers in this DB:</dt>
<dd><%= @num_macs %> (<%= @recent_macs %> seen today)</dd>
</dl>
</div>
<h2>Member Resources</h2> <div class="col-sm-4">
<% if can? :access_doors_remotely, :door_access %> <h2>Member Resources</h2>
<ul><li><%= link_to "Remote Door Access", space_api_access_path %></li></ul> <% if can? :access_doors_remotely, :door_access %>
<% end %> <ul><li><%= link_to "Remote Door Access", space_api_access_path %></li></ul>
<%= simple_format Setting.member_resources_inset %> <% end %>
<%= simple_format Setting.member_resources_inset %>
</td> </div>
</tr>
</table>

View File

@ -2,6 +2,7 @@
<html> <html>
<head> <head>
<title>hsl_members(<%= controller.controller_name %>.<%= controller.action_name %><%= "["+params[:id]+"]" unless params[:id].blank? %>)</title> <title>hsl_members(<%= controller.controller_name %>.<%= controller.action_name %><%= "["+params[:id]+"]" unless params[:id].blank? %>)</title>
<link rel="icon" href="/favicon.ico">
<% if params[:controller] == "resources" %> <% if params[:controller] == "resources" %>
<link href="/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" /> <link href="/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" /> <link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" />

View File

@ -10,6 +10,7 @@
<link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" /> <link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" />
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script> <script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script>
<link rel="icon" href="/favicon.ico">
<style> <style>
.resource .thumbnail { height: 150px; position: relative; } .resource .thumbnail { height: 150px; position: relative; }

View File

@ -0,0 +1,5 @@
class AddCreatedByToContract < ActiveRecord::Migration
def change
add_column :contracts, :created_by, :integer
end
end

View File

@ -11,7 +11,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 => 20140303030220) do ActiveRecord::Schema.define(:version => 20140411022819) do
create_table "cards", :force => true do |t| create_table "cards", :force => true do |t|
t.string "card_number" t.string "card_number"
@ -42,6 +42,7 @@ ActiveRecord::Schema.define(:version => 20140303030220) do
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "cosigner" t.string "cosigner"
t.integer "created_by"
end end
create_table "door_logs", :force => true do |t| create_table "door_logs", :force => true do |t|