More contract tweaks
This commit is contained in:
parent
d8311fa7cc
commit
3cd6c59df0
|
@ -20,7 +20,7 @@ class ContractsController < ApplicationController
|
|||
Rails.logger.info @contract.inspect
|
||||
respond_to do |format|
|
||||
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 }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
|
@ -32,7 +32,7 @@ class ContractsController < ApplicationController
|
|||
def update
|
||||
respond_to do |format|
|
||||
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 }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
|
|
|
@ -35,7 +35,7 @@ class UsersController < ApplicationController
|
|||
when "orientation"
|
||||
@users = @users.sort_by{ |u| [-u.orientation.to_i,u.name] }
|
||||
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"
|
||||
@users = @users.sort_by{ |u| [-u.member_status.to_i,u.name] }
|
||||
when "card"
|
||||
|
|
|
@ -12,7 +12,6 @@ class Ability
|
|||
# By default, users can only see their own stuff
|
||||
can :read, Card, :user_id => user.id
|
||||
can :read, Certification
|
||||
can :read, Contract
|
||||
can :read_details, Mac
|
||||
can [:update], Mac, :user_id => nil
|
||||
can [:create,:update], Mac, :user_id => user.id
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Contract < ActiveRecord::Base
|
||||
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
|
||||
|
||||
|
|
|
@ -145,7 +145,11 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
def contract_date
|
||||
self.contracts.first.signed_at unless self.contracts.blank?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def send_new_user_email
|
||||
Rails.logger.info UserMailer.new_user_email(self).deliver
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
<%= f.label :last_name %><br />
|
||||
<%= f.text_field :last_name, class: "form-control" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.label :cosigner %><br />
|
||||
<%= f.text_field :cosigner, class: "form-control" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :user_id, "User" %><br />
|
||||
|
@ -32,7 +36,13 @@
|
|||
|
||||
<div class="form-group">
|
||||
<%= f.label :document %><br />
|
||||
<%= f.file_field :document %>
|
||||
<%= 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 %>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<td>
|
||||
<%= contract.last_name %>,
|
||||
<%= contract.first_name %>
|
||||
<%= "and #{contract.cosigner}" unless contract.cosigner.blank? %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to contract.user.name, contract.user if contract.user %>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<h1 class="col-md-8">
|
||||
Contract
|
||||
<%= 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 %>
|
||||
</h1>
|
||||
</div>
|
||||
|
@ -10,6 +11,7 @@
|
|||
<h2>
|
||||
<%= @contract.first_name %>
|
||||
<%= @contract.last_name %>
|
||||
<%= "and #{@contract.cosigner}" unless @contract.cosigner.blank? %>
|
||||
<%= link_to "(#{@contract.user.name})", @contract.user if @contract.user %>
|
||||
<small>
|
||||
signed
|
||||
|
@ -17,12 +19,15 @@
|
|||
</small>
|
||||
</h2>
|
||||
|
||||
|
||||
<% if @contract.document.blank? %>
|
||||
No document uploaded
|
||||
<% else %>
|
||||
<p><%= link_to "Download Contract", @contract.document.url %>
|
||||
<div class="col-xs-12">
|
||||
<iframe src="<%= @contract.document.url %>" width="100%" height="600"></iframe>
|
||||
</div>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
||||
<br />
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
<% else %>
|
||||
<%= link_to 'Certifications', certifications_path if can? :read, Certification %>
|
||||
<% end %>
|
||||
<%= link_to 'Waivers', contracts_path if can? :read, Contract %>
|
||||
<%= link_to 'Payments', payments_path if can? :create, Payment %>
|
||||
<%= link_to 'Computers', macs_path if user_signed_in? || (can? :read, Mac) %>
|
||||
<%= link_to 'Settings', settings_path if can? :read, Setting %>
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
<% else %>
|
||||
<%= li_link_to 'Certifications', certifications_path if can? :read, Certification %>
|
||||
<% 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 'Payments', payments_path if can? :create, Payment %>
|
||||
<%= li_link_to 'Settings', settings_path if can? :read, Setting %>
|
||||
|
|
|
@ -34,18 +34,18 @@
|
|||
<% end %>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><a href="?sort=name">Name</a></th>
|
||||
<th><a href="?sort=member">Member?</a></th>
|
||||
<th><a href="?full=full&sort=name">Name</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=orientation">Orientation?</a></th>
|
||||
<th><a href="?full=full&sort=orientation">Orientation?</a></th>
|
||||
<% end %>
|
||||
<th><a href="?sort=waiver">Waiver?</a></th>
|
||||
<th><a href="?sort=card">Card?</a></th>
|
||||
<th><a href="?sort=instructor">Instructor?</a></th>
|
||||
<th><a href="?full=full&sort=waiver">Waiver?</a></th>
|
||||
<th><a href="?full=full&sort=card">Card?</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 %>
|
||||
<% @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 %>
|
||||
<th></th>
|
||||
<th></th>
|
||||
|
@ -61,7 +61,7 @@
|
|||
<% if current_user.admin? then %><td>
|
||||
<%= unless user.orientation.blank? then raw("<span class='hoverinfo' title='"+user.orientation.strftime("%B %d %Y")+"'>✓</span>") 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><%= 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 %>
|
||||
|
|
|
@ -173,9 +173,15 @@ margin-right: auto;
|
|||
<%= @user.waiver.strftime("%B %d %Y") unless @user.waiver.blank? %><br/>
|
||||
<b>Contracts:</b> <%= link_to "+ Add", new_contract_path, :class => 'btn' if can? :create, Contract %>
|
||||
<ul>
|
||||
<% @user.contracts.each do |contract| %>
|
||||
<li><%= link_to contract.signed_at.strftime("%B %d %Y"), contract %></li>
|
||||
<% end %>
|
||||
<% @user.contracts.each do |contract| %>
|
||||
<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 %>
|
||||
</ul>
|
||||
</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.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140227095847) do
|
||||
ActiveRecord::Schema.define(:version => 20140303030220) do
|
||||
|
||||
create_table "cards", :force => true do |t|
|
||||
t.string "card_number"
|
||||
|
@ -41,6 +41,7 @@ ActiveRecord::Schema.define(:version => 20140227095847) do
|
|||
t.datetime "document_updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "cosigner"
|
||||
end
|
||||
|
||||
create_table "door_logs", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue
Block a user