Merge branch 'master' of github.com:zyphlar/Open-Source-Access-Control-Web-Interface
This commit is contained in:
commit
83442c4bff
@ -20,7 +20,7 @@ class ContractsController < ApplicationController
|
|||||||
Rails.logger.info @contract.inspect
|
Rails.logger.info @contract.inspect
|
||||||
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.' }
|
||||||
format.json { render :json => @contract, :status => :created, :location => @contract }
|
format.json { render :json => @contract, :status => :created, :location => @contract }
|
||||||
else
|
else
|
||||||
format.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
@ -32,7 +32,7 @@ class ContractsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @contract.update_attributes(params[:contract])
|
if @contract.update_attributes(params[:contract])
|
||||||
format.html { redirect_to Contract, :notice => 'Contract was successfully updated.' }
|
format.html { redirect_to @contract, :notice => 'Contract was successfully updated.' }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
else
|
else
|
||||||
format.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
|
@ -292,18 +292,22 @@ Rails.logger.info "starting scan..."
|
|||||||
Rails.logger.info "Running [#{command}]"
|
Rails.logger.info "Running [#{command}]"
|
||||||
end
|
end
|
||||||
IO.popen(command) { |stdin|
|
IO.popen(command) { |stdin|
|
||||||
Rails.logger.info "Reading stdin: "+stdin.inspect
|
result = stdin.read()
|
||||||
stdin.each { |line|
|
result.lines.each { |line|
|
||||||
|
Rails.logger.info "Reading stdin: "+line.inspect
|
||||||
next if line !~ /^([\d\.]+)\s+([[:xdigit:]:]+)\s/;
|
next if line !~ /^([\d\.]+)\s+([[:xdigit:]:]+)\s/;
|
||||||
macs[($2).downcase] = ($1).downcase;
|
macs[($2).downcase] = ($1).downcase;
|
||||||
}
|
}
|
||||||
|
Rails.logger.info "STDIN:"+result.lines.count.inspect
|
||||||
|
@macs = macs.dup # make a copy for output in the view
|
||||||
|
Rails.logger.info "MACS:"+@macs.inspect
|
||||||
}
|
}
|
||||||
|
|
||||||
# Scan the existing macs and update each record as necessary
|
# Scan the existing macs and update each record as necessary
|
||||||
Mac.find(:all).each { |entry|
|
Mac.find(:all).each { |entry|
|
||||||
mac = entry.mac.downcase
|
mac = entry.mac.downcase
|
||||||
ip = entry.ip
|
ip = entry.ip
|
||||||
if macs.has_key?(mac)
|
if macs.has_key?(mac) # if our scan shows this mac
|
||||||
if ! entry.active || ! entry.since
|
if ! entry.active || ! entry.since
|
||||||
Rails.logger.info "Activating #{mac} at #{ip}" if options[:verbose]
|
Rails.logger.info "Activating #{mac} at #{ip}" if options[:verbose]
|
||||||
entry.since = Time.now
|
entry.since = Time.now
|
||||||
|
@ -35,7 +35,7 @@ class UsersController < ApplicationController
|
|||||||
when "orientation"
|
when "orientation"
|
||||||
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name] }
|
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name] }
|
||||||
when "waiver"
|
when "waiver"
|
||||||
@users = @users.sort_by{ |u| [-u.waiver.to_i,u.name] }
|
@users = @users.sort_by{ |u| [-u.contract_date.to_i,u.name] }
|
||||||
when "member"
|
when "member"
|
||||||
@users = @users.sort_by{ |u| [-u.member_status.to_i,u.name] }
|
@users = @users.sort_by{ |u| [-u.member_status.to_i,u.name] }
|
||||||
when "card"
|
when "card"
|
||||||
|
@ -12,7 +12,6 @@ class Ability
|
|||||||
# By default, users can only see their own stuff
|
# By default, users can only see their own stuff
|
||||||
can :read, Card, :user_id => user.id
|
can :read, Card, :user_id => user.id
|
||||||
can :read, Certification
|
can :read, Certification
|
||||||
can :read, Contract
|
|
||||||
can :read_details, Mac
|
can :read_details, Mac
|
||||||
can [:update], Mac, :user_id => nil
|
can [:update], Mac, :user_id => nil
|
||||||
can [:create,:update], Mac, :user_id => user.id
|
can [:create,:update], Mac, :user_id => user.id
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
class Contract < ActiveRecord::Base
|
class Contract < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
attr_accessible :user_id, :first_name, :last_name, :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
|
||||||
|
|
||||||
validates_presence_of :first_name, :signed_at #, :last_name
|
validates_presence_of :first_name, :signed_at #, :last_name
|
||||||
|
|
||||||
|
@ -145,7 +145,11 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def contract_date
|
||||||
|
self.contracts.first.signed_at unless self.contracts.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
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
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
<%= f.label :last_name %><br />
|
<%= f.label :last_name %><br />
|
||||||
<%= f.text_field :last_name, class: "form-control" %>
|
<%= f.text_field :last_name, class: "form-control" %>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :cosigner %><br />
|
||||||
|
<%= f.text_field :cosigner, class: "form-control" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :user_id, "User" %><br />
|
<%= f.label :user_id, "User" %><br />
|
||||||
@ -32,8 +36,14 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :document %><br />
|
<%= f.label :document %><br />
|
||||||
|
<%= link_to "View Existing Document", @contract.document.url, class: "btn btn-default" unless @contract.document.blank? %>
|
||||||
|
<p>
|
||||||
|
<%= link_to "Upload New Document", "#", class: "btn btn-default", onclick: "$('#document_upload').removeClass('hidden'); $(this).addClass('hidden')" unless @contract.document.blank? %>
|
||||||
|
<div id="document_upload" class="<%= "hidden" unless @contract.document.blank? %>">
|
||||||
<%= f.file_field :document %>
|
<%= f.file_field :document %>
|
||||||
</div>
|
</div>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.submit nil, class: "btn btn-primary" %>
|
<%= f.submit nil, class: "btn btn-primary" %>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Scan?</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
@ -14,9 +15,15 @@
|
|||||||
|
|
||||||
<% @contracts.sort_by{|r| (r.last_name) || "" }.each do |contract| %>
|
<% @contracts.sort_by{|r| (r.last_name) || "" }.each do |contract| %>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>
|
||||||
|
<% unless contract.document.blank? %>
|
||||||
|
<span class="glyphicon glyphicon-ok"></span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= contract.last_name %>,
|
<%= contract.last_name %>,
|
||||||
<%= contract.first_name %>
|
<%= contract.first_name %>
|
||||||
|
<%= "and #{contract.cosigner}" unless contract.cosigner.blank? %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to contract.user.name, contract.user if contract.user %>
|
<%= link_to contract.user.name, contract.user if contract.user %>
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
<h1 class="col-md-8">
|
<h1 class="col-md-8">
|
||||||
Contract
|
Contract
|
||||||
<%= link_to 'Back', contracts_path, :class => "btn btn-default" %>
|
<%= link_to 'Back', contracts_path, :class => "btn btn-default" %>
|
||||||
|
<%= link_to 'Edit', edit_contract_path(@contract), :class => "btn btn-primary" %>
|
||||||
<%= link_to 'Delete', contract_path(@contract), {:confirm => 'Are you sure you want to delete this forever?', :method => :delete, :class => "btn btn-danger"} if can? :destroy, @contract %>
|
<%= link_to 'Delete', contract_path(@contract), {:confirm => 'Are you sure you want to delete this forever?', :method => :delete, :class => "btn btn-danger"} if can? :destroy, @contract %>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
<%= @contract.full_name %>
|
<%= @contract.first_name %>
|
||||||
|
<%= @contract.last_name %>
|
||||||
|
<%= "and #{@contract.cosigner}" unless @contract.cosigner.blank? %>
|
||||||
<%= link_to "(#{@contract.user.name})", @contract.user if @contract.user %>
|
<%= link_to "(#{@contract.user.name})", @contract.user if @contract.user %>
|
||||||
<small>
|
<small>
|
||||||
signed
|
signed
|
||||||
@ -16,12 +19,15 @@
|
|||||||
</small>
|
</small>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
<% if @contract.document.blank? %>
|
||||||
|
No document uploaded
|
||||||
|
<% else %>
|
||||||
<p><%= link_to "Download Contract", @contract.document.url %>
|
<p><%= link_to "Download Contract", @contract.document.url %>
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<iframe src="<%= @contract.document.url %>" width="100%" height="600"></iframe>
|
<iframe src="<%= @contract.document.url %>" width="100%" height="600"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to 'Certifications', certifications_path if can? :read, Certification %>
|
<%= link_to 'Certifications', certifications_path if can? :read, Certification %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= link_to 'Waivers', contracts_path if can? :read, Contract %>
|
||||||
<%= link_to 'Payments', payments_path if can? :create, Payment %>
|
<%= link_to 'Payments', payments_path if can? :create, Payment %>
|
||||||
<%= link_to 'Computers', macs_path if user_signed_in? || (can? :read, Mac) %>
|
<%= link_to 'Computers', macs_path if user_signed_in? || (can? :read, Mac) %>
|
||||||
<%= link_to 'Settings', settings_path if can? :read, Setting %>
|
<%= link_to 'Settings', settings_path if can? :read, Setting %>
|
||||||
|
@ -89,6 +89,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<%= li_link_to 'Certifications', certifications_path if can? :read, Certification %>
|
<%= li_link_to 'Certifications', certifications_path if can? :read, Certification %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= li_link_to 'Waivers', contracts_path if can? :read, Contract %>
|
||||||
<%= li_link_to 'Computers', macs_path if user_signed_in? || (can? :read, Mac) %>
|
<%= li_link_to 'Computers', macs_path if user_signed_in? || (can? :read, Mac) %>
|
||||||
<%= li_link_to 'Payments', payments_path if can? :create, Payment %>
|
<%= li_link_to 'Payments', payments_path if can? :create, Payment %>
|
||||||
<%= li_link_to 'Settings', settings_path if can? :read, Setting %>
|
<%= li_link_to 'Settings', settings_path if can? :read, Setting %>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Scanning...
|
Scanning...
|
||||||
<% if can? :read_details, Mac
|
<% if can? :read_details, Mac
|
||||||
@log.each do |log| %>
|
@macs.each do |key, value| %>
|
||||||
<%= log.mac %> =
|
<%= key %> =
|
||||||
<%= log.ip %><br/>
|
<%= value %><br/>
|
||||||
<% end
|
<% end
|
||||||
end %>
|
end %>
|
||||||
|
@ -34,18 +34,18 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th><a href="?sort=name">Name</a></th>
|
<th><a href="?full=full&sort=name">Name</a></th>
|
||||||
<th><a href="?sort=member">Member?</a></th>
|
<th><a href="?full=full&sort=member">Member?</a></th>
|
||||||
<% if current_user.admin? then %><th><a href="?sort=email">Email</a></th><% end %>
|
<% if current_user.admin? then %><th><a href="?sort=email">Email</a></th><% end %>
|
||||||
<% if current_user.admin? then %>
|
<% if current_user.admin? then %>
|
||||||
<th><a href="?sort=orientation">Orientation?</a></th>
|
<th><a href="?full=full&sort=orientation">Orientation?</a></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<th><a href="?sort=waiver">Waiver?</a></th>
|
<th><a href="?full=full&sort=waiver">Waiver?</a></th>
|
||||||
<th><a href="?sort=card">Card?</a></th>
|
<th><a href="?full=full&sort=card">Card?</a></th>
|
||||||
<th><a href="?sort=instructor">Instructor?</a></th>
|
<th><a href="?full=full&sort=instructor">Instructor?</a></th>
|
||||||
<% if current_user.admin? then %><th><a href="?sort=admin">Admin?</a></th><% end %>
|
<% if current_user.admin? then %><th><a href="?sort=admin">Admin?</a></th><% end %>
|
||||||
<% @certifications.each do |c| %>
|
<% @certifications.each do |c| %>
|
||||||
<th><a href="?sort=cert&cert=<%= c.id %>"><%= c.name %></a></th>
|
<th><a href="?full=full&sort=cert&cert=<%= c.id %>"><%= c.name %></a></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<% if current_user.admin? then %><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 %>
|
<%= unless user.orientation.blank? then raw("<span class='hoverinfo' title='"+user.orientation.strftime("%B %d %Y")+"'>✓</span>") end %>
|
||||||
</td><% end %>
|
</td><% end %>
|
||||||
<td><%= unless user.waiver.blank? then raw("<span class='hoverinfo' title='"+user.waiver.strftime("%B %d %Y")+"'>✓</span>") end %></td>
|
<td><%= unless user.contracts.blank? then raw("<span class='hoverinfo' title='"+user.contracts.first.signed_at.strftime("%B %d %Y")+"'>✓</span>") end %></td>
|
||||||
<td><%= unless user.cards.blank? then raw("<span class='iconinfo'>✓</span>") end %></td>
|
<td><%= unless user.cards.blank? then raw("<span class='iconinfo'>✓</span>") end %></td>
|
||||||
<td><%= if user.instructor? then raw("<span class='iconinfo'>✓</a>") end %></td>
|
<td><%= if user.instructor? then raw("<span class='iconinfo'>✓</a>") end %></td>
|
||||||
<% if current_user.admin? then %><td><%= if user.admin? then raw("<span class='iconinfo'>✓</a>") end %></td><% end %>
|
<% if current_user.admin? then %><td><%= if user.admin? then raw("<span class='iconinfo'>✓</a>") end %></td><% end %>
|
||||||
|
@ -174,7 +174,13 @@ margin-right: auto;
|
|||||||
<b>Contracts:</b> <%= link_to "+ Add", new_contract_path, :class => 'btn' if can? :create, Contract %>
|
<b>Contracts:</b> <%= link_to "+ Add", new_contract_path, :class => 'btn' if can? :create, Contract %>
|
||||||
<ul>
|
<ul>
|
||||||
<% @user.contracts.each do |contract| %>
|
<% @user.contracts.each do |contract| %>
|
||||||
<li><%= link_to contract.signed_at.strftime("%B %d %Y"), contract %></li>
|
<li>
|
||||||
|
<% if can? :read, contract %>
|
||||||
|
<%= link_to contract.signed_at.strftime("%B %d %Y"), contract %>
|
||||||
|
<% else %>
|
||||||
|
<%= contract.signed_at.strftime("%B %d %Y") %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
5
db/migrate/20140303030220_add_cosigner_to_contracts.rb
Normal file
5
db/migrate/20140303030220_add_cosigner_to_contracts.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddCosignerToContracts < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :contracts, :cosigner, :string
|
||||||
|
end
|
||||||
|
end
|
@ -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 => 20140227095847) do
|
ActiveRecord::Schema.define(:version => 20140303030220) do
|
||||||
|
|
||||||
create_table "cards", :force => true do |t|
|
create_table "cards", :force => true do |t|
|
||||||
t.string "card_number"
|
t.string "card_number"
|
||||||
@ -41,6 +41,7 @@ ActiveRecord::Schema.define(:version => 20140227095847) do
|
|||||||
t.datetime "document_updated_at"
|
t.datetime "document_updated_at"
|
||||||
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"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "door_logs", :force => true do |t|
|
create_table "door_logs", :force => true do |t|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user