diff --git a/app/controllers/contracts_controller.rb b/app/controllers/contracts_controller.rb
index fbb4905..0b66c9c 100644
--- a/app/controllers/contracts_controller.rb
+++ b/app/controllers/contracts_controller.rb
@@ -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" }
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9adaefe..278cea9 100755
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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"
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 55cfe63..5ac0d4c 100755
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -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
diff --git a/app/models/contract.rb b/app/models/contract.rb
index 52a4c21..a588fe3 100644
--- a/app/models/contract.rb
+++ b/app/models/contract.rb
@@ -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
diff --git a/app/models/user.rb b/app/models/user.rb
index ecfa34d..1829249 100755
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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
diff --git a/app/views/contracts/_form.html.erb b/app/views/contracts/_form.html.erb
index 067737b..ee863e1 100644
--- a/app/views/contracts/_form.html.erb
+++ b/app/views/contracts/_form.html.erb
@@ -19,6 +19,10 @@
<%= f.label :last_name %>
<%= f.text_field :last_name, class: "form-control" %>
+
+ <%= link_to "Upload New Document", "#", class: "btn btn-default", onclick: "$('#document_upload').removeClass('hidden'); $(this).addClass('hidden')" unless @contract.document.blank? %> +
<%= link_to "Download Contract", @contract.document.url %>