Adding resources (imported from old toolshare)
This commit is contained in:
parent
56450cf319
commit
1d0e8721e1
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -21,5 +21,6 @@ tmp/
|
|||
|
||||
# Ignore config and database files (passwords)
|
||||
/config/config.yml
|
||||
/config/s3.yml
|
||||
/config/database.yml
|
||||
/config/initializers/secret_token.rb
|
||||
|
|
3
Gemfile
3
Gemfile
|
@ -46,7 +46,8 @@ gem 'bcrypt-ruby', '~> 3.0.0'
|
|||
# To use debugger
|
||||
#gem 'debugger'
|
||||
|
||||
#gem "paperclip", "~> 3.0"
|
||||
gem "paperclip", "~> 3.0"
|
||||
gem "aws-sdk"
|
||||
gem 'gravtastic'
|
||||
|
||||
gem 'passenger'
|
||||
|
|
19
Gemfile.lock
19
Gemfile.lock
|
@ -29,9 +29,17 @@ GEM
|
|||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
arel (3.0.2)
|
||||
aws-sdk (1.33.0)
|
||||
json (~> 1.4)
|
||||
nokogiri (>= 1.4.4)
|
||||
uuidtools (~> 2.1)
|
||||
bcrypt-ruby (3.0.1)
|
||||
builder (3.0.4)
|
||||
cancan (1.6.10)
|
||||
climate_control (0.0.3)
|
||||
activesupport (>= 3.0)
|
||||
cocaine (0.5.3)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
coffee-rails (3.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (~> 3.2.0)
|
||||
|
@ -61,8 +69,16 @@ GEM
|
|||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.25)
|
||||
mini_portile (0.5.2)
|
||||
multi_json (1.8.2)
|
||||
nokogiri (1.6.1)
|
||||
mini_portile (~> 0.5.0)
|
||||
orm_adapter (0.4.0)
|
||||
paperclip (3.5.4)
|
||||
activemodel (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
cocaine (~> 0.5.3)
|
||||
mime-types
|
||||
passenger (4.0.19)
|
||||
daemon_controller (>= 1.1.0)
|
||||
rack
|
||||
|
@ -129,6 +145,7 @@ GEM
|
|||
uglifier (2.2.1)
|
||||
execjs (>= 0.3.0)
|
||||
multi_json (~> 1.0, >= 1.0.2)
|
||||
uuidtools (2.1.4)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
|
||||
|
@ -136,6 +153,7 @@ PLATFORMS
|
|||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
aws-sdk
|
||||
bcrypt-ruby (~> 3.0.0)
|
||||
cancan
|
||||
coffee-rails (~> 3.2.1)
|
||||
|
@ -143,6 +161,7 @@ DEPENDENCIES
|
|||
gravtastic
|
||||
jquery-rails
|
||||
json
|
||||
paperclip (~> 3.0)
|
||||
passenger
|
||||
pg
|
||||
rails (= 3.2.8)
|
||||
|
|
4
app/controllers/resources_controller.rb
Normal file
4
app/controllers/resources_controller.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class ResourcesController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
before_filter :authenticate_user!
|
||||
end
|
|
@ -1,4 +1,10 @@
|
|||
module ApplicationHelper
|
||||
@payment_methods = [[nil],["PayPal"],["Dwolla"],["Bill Pay"],["Check"],["Cash"],["Other"]]
|
||||
@payment_instructions = {nil => nil, :paypal => "Set up a monthly recurring payment to hslfinances@gmail.com", :dwolla => "Set up a monthly recurring payment to hslfinances@gmail.com", :billpay => "Have your bank send a monthly check to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201", :check => "Mail to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201 OR put in the drop safe at the Lab with a deposit slip firmly attached each month.", :cash => "Put in the drop safe at the Lab with a deposit slip firmly attached each month.", :other => "Hmm... talk to a Treasurer!"}
|
||||
|
||||
def sort_link(title, column, options = {})
|
||||
condition = options[:unless] if options.has_key?(:unless)
|
||||
sort_dir = params[:dir] == 'up' ? 'down' : 'up'
|
||||
link_to_unless condition, title, request.parameters.merge( {:sort => column, :dir => sort_dir} )
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,7 @@ class Ability
|
|||
can [:update], Mac, :user_id => nil
|
||||
can [:create,:update], Mac, :user_id => user.id
|
||||
can :read, Payment, :user_id => user.id
|
||||
can :read, Resource
|
||||
can :read, UserCertification, :user_id => user.id
|
||||
can :read, User, :id => user.id #TODO: why can users update themselves? Maybe because Devise doesn't check users/edit?
|
||||
can :compose_email, User
|
||||
|
|
12
app/models/resource.rb
Normal file
12
app/models/resource.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class Resource < ActiveRecord::Base
|
||||
belongs_to :owner, :class_name => "ToolshareUser"
|
||||
belongs_to :category, :class_name => "ResourceCategory"
|
||||
has_attached_file :picture,
|
||||
:styles => { :medium => "300x300>",
|
||||
:thumb => "100x100>",
|
||||
:tiny => "50x50>"},
|
||||
:storage => :s3,
|
||||
:s3_credentials => Rails.root.join('config', 's3.yml'),
|
||||
:path => ":attachment/:id/:style.:extension",
|
||||
:bucket => 'Toolshare'
|
||||
end
|
3
app/models/resource_category.rb
Normal file
3
app/models/resource_category.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class ResourceCategory < ActiveRecord::Base
|
||||
has_many :resources
|
||||
end
|
4
app/models/toolshare_user.rb
Normal file
4
app/models/toolshare_user.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class ToolshareUser < ActiveRecord::Base
|
||||
has_many :resources, :foreign_key => "owner_id"
|
||||
attr_accessible :name, :email
|
||||
end
|
38
app/views/resources/index.html.erb
Normal file
38
app/views/resources/index.html.erb
Normal file
|
@ -0,0 +1,38 @@
|
|||
<h1>Resources</h1>
|
||||
|
||||
<%= link_to 'New Resource', new_resource_path, :class => "btn" if can? :create, Resource %>
|
||||
|
||||
<table class="lined-table">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th> <%= sort_link 'Owner', :owner_id %></th>
|
||||
<th> <%= sort_link 'Category', :category_id %></th>
|
||||
<th> <%= sort_link 'Name', :name %></th>
|
||||
<th> <%= sort_link 'Serial', :serial %></th>
|
||||
<th> <%= sort_link 'Status/Location', :status %></th>
|
||||
</tr>
|
||||
|
||||
<% unless @resources.blank? %>
|
||||
<% @resources.group_by(&:supercategory).each do |supercategory,resources| %>
|
||||
<tr><th><%= supercategory %></th></tr>
|
||||
<% resources.each do |resource| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= link_to image_tag(resource.picture.url(:tiny)), resource.picture.url, :popup => ['index_image_preview', 'height=300,width=400'] if resource.picture? %>
|
||||
</td>
|
||||
<td>
|
||||
<%=h resource.owner.name if resource.owner %>
|
||||
<td><%=h resource.category.name unless resource.category.nil? %></td>
|
||||
<td><%=h resource.name %></td>
|
||||
<td><%=h resource.serial %></td>
|
||||
<td><%=h resource.status %></td>
|
||||
<td><%= link_to 'Edit', edit_resource_path(resource) if can? :update, resource %></td>
|
||||
<td><%= link_to 'Destroy', resource, :confirm => 'Are you sure you want to delete this?', :method => :delete if can? :destroy, resource %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
|
@ -8,6 +8,7 @@ Dooraccess::Application.routes.draw do
|
|||
match 'paypal_csvs/:id/link' => 'paypal_csvs#link', :as => :link_paypal_csv
|
||||
|
||||
resources :payments
|
||||
resources :resources
|
||||
|
||||
match 'statistics' => 'statistics#index', :as => :statistics
|
||||
match 'statistics/mac_log' => 'statistics#mac_log', :as => :mac_statistics
|
||||
|
|
2
config/s3.yml.example
Normal file
2
config/s3.yml.example
Normal file
|
@ -0,0 +1,2 @@
|
|||
access_key_id: YOUR_PUBLIC_ACCESS_KEY
|
||||
secret_access_key: YOUR_SECRET_ACCESS_KEY
|
26
db/migrate/20140209065240_create_resources.rb
Normal file
26
db/migrate/20140209065240_create_resources.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
class CreateResources < ActiveRecord::Migration
|
||||
def up
|
||||
create_table "resources", :force => true do |t|
|
||||
t.string "type"
|
||||
t.integer "owner_id"
|
||||
t.integer "category_id"
|
||||
t.string "name"
|
||||
t.string "serial"
|
||||
t.string "specs"
|
||||
t.string "status"
|
||||
t.boolean "donatable"
|
||||
t.string "picture_file_name"
|
||||
t.string "picture_content_type"
|
||||
t.integer "picture_file_size"
|
||||
t.datetime "picture_updated_at"
|
||||
t.text "notes"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "estimated_value"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :resources
|
||||
end
|
||||
end
|
14
db/migrate/20140209070141_create_categories.rb
Normal file
14
db/migrate/20140209070141_create_categories.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class CreateCategories < ActiveRecord::Migration
|
||||
def up
|
||||
create_table "resource_categories", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "parent"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :resource_categories
|
||||
end
|
||||
end
|
27
db/migrate/20140209070300_create_toolshare_users.rb
Normal file
27
db/migrate/20140209070300_create_toolshare_users.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
class CreateToolshareUsers < ActiveRecord::Migration
|
||||
def up
|
||||
create_table "toolshare_users", :force => true do |t|
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "reset_password_token"
|
||||
t.string "remember_token"
|
||||
t.datetime "remember_created_at"
|
||||
t.integer "sign_in_count", :default => 0
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "name"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :toolshare_users
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class ChangeResourceTypeToSuperCategory < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :resources, :type, :supercategory
|
||||
end
|
||||
end
|
48
db/schema.rb
48
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140209025344) do
|
||||
ActiveRecord::Schema.define(:version => 20140209072532) do
|
||||
|
||||
create_table "cards", :force => true do |t|
|
||||
t.string "card_number"
|
||||
|
@ -116,6 +116,32 @@ ActiveRecord::Schema.define(:version => 20140209025344) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "resource_categories", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "parent"
|
||||
end
|
||||
|
||||
create_table "resources", :force => true do |t|
|
||||
t.string "supercategory"
|
||||
t.integer "owner_id"
|
||||
t.integer "category_id"
|
||||
t.string "name"
|
||||
t.string "serial"
|
||||
t.string "specs"
|
||||
t.string "status"
|
||||
t.boolean "donatable"
|
||||
t.string "picture_file_name"
|
||||
t.string "picture_content_type"
|
||||
t.integer "picture_file_size"
|
||||
t.datetime "picture_updated_at"
|
||||
t.text "notes"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "estimated_value"
|
||||
end
|
||||
|
||||
create_table "settings", :force => true do |t|
|
||||
t.string "var", :null => false
|
||||
t.text "value"
|
||||
|
@ -127,6 +153,26 @@ ActiveRecord::Schema.define(:version => 20140209025344) do
|
|||
|
||||
add_index "settings", ["thing_type", "thing_id", "var"], :name => "index_settings_on_thing_type_and_thing_id_and_var", :unique => true
|
||||
|
||||
create_table "toolshare_users", :force => true do |t|
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "reset_password_token"
|
||||
t.string "remember_token"
|
||||
t.datetime "remember_created_at"
|
||||
t.integer "sign_in_count", :default => 0
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "name"
|
||||
end
|
||||
|
||||
create_table "user_certifications", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "certification_id"
|
||||
|
|
Loading…
Reference in New Issue
Block a user