Finishing contracts, changing from s3.yml to .env
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class ContractsController < ApplicationController
|
||||
load_and_authorize_resource :contract
|
||||
before_filter :authenticate_user!
|
||||
before_filter :authenticate_user!, :load_users
|
||||
layout 'resources'
|
||||
|
||||
def index
|
||||
@@ -16,6 +16,8 @@ class ContractsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
Rails.logger.info "CONTRACT"
|
||||
Rails.logger.info @contract.inspect
|
||||
respond_to do |format|
|
||||
if @contract.save
|
||||
format.html { redirect_to Contract, :notice => 'Contract was successfully created.' }
|
||||
@@ -47,4 +49,8 @@ class ContractsController < ApplicationController
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
def load_users
|
||||
@users = @users = User.accessible_by(current_ability).sort_by(&:name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,6 +12,7 @@ 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
|
||||
@@ -54,7 +55,7 @@ class Ability
|
||||
can :manage, :all
|
||||
end
|
||||
|
||||
# Prevent all destruction for now
|
||||
# Prevent most destruction for now
|
||||
#cannot :destroy, User
|
||||
#cannot :destroy, Card
|
||||
cannot :destroy, Certification
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
class Contract < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
attr_accessible :user_id, :first_name, :last_name, :signed_at, :document_file_name, :document_content_type, :document_file_size, :document_updated_at
|
||||
attr_accessible :user_id, :first_name, :last_name, :signed_at, :document, :document_file_name, :document_content_type, :document_file_size, :document_updated_at
|
||||
|
||||
validates_presence_of :first_name, :last_name, :signed_at
|
||||
|
||||
has_attached_file :document, { :styles => { :medium => "300x300>"},
|
||||
:storage => :s3,
|
||||
:s3_credentials => Rails.root.join('config', 's3.yml'),
|
||||
:s3_credentials => { :access_key_id => ENV['S3_KEY'],
|
||||
:secret_access_key => ENV['S3_SECRET'] },
|
||||
:path => ":attachment/:id/:style.:extension",
|
||||
:bucket => 'Toolshare' } #TODO: move to local storage
|
||||
:bucket => ENV['S3_BUCKET'] }
|
||||
end
|
||||
|
||||
@@ -14,11 +14,12 @@ class Resource < ActiveRecord::Base
|
||||
:thumb => "100x100>",
|
||||
:tiny => "50x50>"},
|
||||
:storage => :s3,
|
||||
:s3_credentials => Rails.root.join('config', 's3.yml'),
|
||||
:s3_credentials => { :access_key_id => ENV['S3_KEY'],
|
||||
:secret_access_key => ENV['S3_SECRET'] },
|
||||
:path => ":attachment/:id/:style.:extension",
|
||||
:bucket => 'Toolshare' }
|
||||
:bucket => ENV['S3_BUCKET'] }
|
||||
|
||||
has_attached_file :picture, PICTURE_OPTIONS #TODO: move to local storage
|
||||
has_attached_file :picture, PICTURE_OPTIONS
|
||||
has_attached_file :picture2, PICTURE_OPTIONS
|
||||
has_attached_file :picture3, PICTURE_OPTIONS
|
||||
has_attached_file :picture4, PICTURE_OPTIONS
|
||||
|
||||
@@ -14,6 +14,7 @@ class User < ActiveRecord::Base
|
||||
has_many :cards
|
||||
has_many :user_certifications
|
||||
has_many :certifications, :through => :user_certifications
|
||||
has_many :contracts
|
||||
has_many :payments
|
||||
has_many :macs
|
||||
has_many :resources
|
||||
|
||||
@@ -11,26 +11,31 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<div class="form-group">
|
||||
<%= f.label :first_name %><br />
|
||||
<%= f.text_field :first_name, class: "form-control" %>
|
||||
</p>
|
||||
<p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.label :last_name %><br />
|
||||
<%= f.text_field :last_name, class: "form-control" %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<div class="form-group">
|
||||
<%= f.label :user_id, "User" %><br />
|
||||
<%= collection_select(:contract, :user_id, @users, :id, :name, :include_blank => true) %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :signed_at %><br />
|
||||
<%= f.date_select :signed_at, class: "form-control" %>
|
||||
</p>
|
||||
<%= f.date_select :signed_at %>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<div class="form-group">
|
||||
<%= f.label :document %><br />
|
||||
<%= f.file_field :document %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<div class="form-group">
|
||||
<%= f.submit nil, class: "btn btn-primary" %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
4
app/views/contracts/edit.html.erb
Normal file
4
app/views/contracts/edit.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<h1>Edit Contract
|
||||
<%= link_to 'Back', contracts_path, class: "btn btn-default" %>
|
||||
</h1>
|
||||
<%= render 'form' %>
|
||||
@@ -4,18 +4,32 @@
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<% @contracts.sort_by{|r| [r.last_name] }.each do |contract| %>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<%= contract.last_name %>
|
||||
<%= contract.first_name %>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>User</th>
|
||||
<th>Date</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @contracts.sort_by{|r| [r.last_name] }.each do |contract| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= contract.last_name %>,
|
||||
<%= contract.first_name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to contract.user.name, contract.user if contract.user %>
|
||||
</td>
|
||||
<td>
|
||||
<%= contract.signed_at.to_date.to_s(:long) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "View", contract, class: "btn btn-primary" %>
|
||||
<%= link_to "Edit", edit_contract_path(contract), class: "btn btn-default" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<br />
|
||||
|
||||
|
||||
28
app/views/contracts/show.html.erb
Normal file
28
app/views/contracts/show.html.erb
Normal file
@@ -0,0 +1,28 @@
|
||||
<div class="row">
|
||||
<h1 class="col-md-8">
|
||||
Contract
|
||||
<%= link_to 'Back', contracts_path, :class => "btn btn-default" %>
|
||||
<%= 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>
|
||||
|
||||
|
||||
<h2>
|
||||
<%= @contract.full_name %>
|
||||
<%= link_to "(#{@contract.user.name})", @contract.user if @contract.user %>
|
||||
<small>
|
||||
signed
|
||||
<%= @contract.signed_at.to_date.to_s(:long) %>
|
||||
</small>
|
||||
</h2>
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<span class="col-md-2 col-xs-6">
|
||||
<h3>Featured item:</h3>
|
||||
<%= render @featured_resource %>
|
||||
<%= render @featured_resource unless @featured_resource.blank? %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -170,7 +170,13 @@ margin-right: auto;
|
||||
|
||||
<p>
|
||||
<b>Waiver?</b>
|
||||
<%= @user.waiver.strftime("%B %d %Y") unless @user.waiver.blank? %>
|
||||
<%= @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 %>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user