Permalink
Browse files

a whole mess of changes

  • Loading branch information...
1 parent 48997c7 commit 1a0d447c305df26fa0808180c25746049c90b748 Alex Berry committed Apr 17, 2012
Showing with 545 additions and 30 deletions.
  1. +14 −0 :w
  2. +1 −0 Gemfile
  3. +4 −0 Gemfile.lock
  4. BIN app/controllers/.admins_equipments_controller.rb.swp
  5. +4 −0 app/controllers/admins_controller.rb
  6. +20 −0 app/controllers/admins_equipments_controller.rb
  7. +13 −0 app/controllers/admins_users_controller.rb
  8. +10 −0 app/helpers/application_helper.rb
  9. BIN app/models/.inventory.rb.swp
  10. +3 −0 app/models/chassis.rb
  11. +6 −0 app/models/equipment.rb
  12. +3 −0 app/models/inventory.rb
  13. +5 −1 app/models/robot.rb
  14. +3 −0 app/models/statistic.rb
  15. +6 −0 app/models/user.rb
  16. +1 −0 app/views/admins/show.html.erb
  17. +17 −0 app/views/admins_equipments/index.html.erb
  18. +5 −0 app/views/admins_equipments/new.html.erb
  19. +18 −0 app/views/admins_users/index.html.erb
  20. +31 −0 app/views/layouts/admin.html.erb
  21. +7 −6 app/views/layouts/application.html.erb
  22. +3 −3 app/views/robots/new.html.erb
  23. +5 −0 config/routes.rb
  24. BIN db/migrate/.20120417184256_create_inventory.rb.swp
  25. BIN db/migrate/.20120417213502_add_user_equipment_robot_to_inventory.rb.swp
  26. +6 −0 db/migrate/20120409223733_add_chassis_to_robot.rb
  27. +8 −0 db/migrate/20120409225431_create_chasses.rb
  28. +19 −0 db/migrate/20120413003523_create_diesel_clearance_users.rb
  29. +8 −0 db/migrate/20120413015049_change_chasses_name_to_string.rb
  30. +5 −0 db/migrate/20120416211846_add_admin_to_users.rb
  31. +7 −0 db/migrate/20120417175407_create_equipment_model.rb
  32. +13 −0 db/migrate/20120417184256_create_inventory.rb
  33. +5 −0 db/migrate/20120417191545_change_equipment_table.rb
  34. +5 −0 db/migrate/20120417211050_add_balance_to_users.rb
  35. +8 −0 db/migrate/20120417213502_add_user_equipment_robot_to_inventory.rb
  36. +26 −1 db/schema.rb
  37. +4 −6 db/seeds.rb
  38. +87 −0 doc/robot-schematics.txt
  39. +11 −0 features/admin.feature
  40. +7 −0 features/admin_robots.feature
  41. +10 −0 features/equipment_new.feature
  42. +5 −0 features/stat.feature
  43. +14 −0 features/step_definitions/equipment_steps.rb
  44. +14 −0 features/step_definitions/navigation_steps.rb
  45. +10 −1 features/step_definitions/robot_steps.rb
  46. +33 −0 features/step_definitions/user_steps.rb
  47. +3 −2 features/support/env.rb
  48. +9 −9 spec/factories/clearance.rb
  49. +5 −0 spec/factories/robot.rb
  50. +5 −0 spec/factories/user.rb
  51. BIN spec/models/.inventory_spec.rb.swp
  52. +6 −0 spec/models/chassis_spec.rb
  53. +9 −0 spec/models/equipment_spec.rb
  54. +6 −0 spec/models/inventory_spec.rb
  55. +6 −1 spec/models/robot_spec.rb
  56. +5 −0 spec/models/statistic_spec.rb
  57. +7 −0 spec/models/user_spec.rb
View
14 :w
@@ -0,0 +1,14 @@
+<div data-role="equipment_actios">
+ <%= link_to "New Equipment", new_admin_equipment_path %>
+</div>
+<table data-role="equipment">
+ <tr>
+ <th>Name</th>
+ <th>Price</th>
+ <th>&nbsp;</th>
+ </tr>
+ <% @equipment.each do |equipment| %>
+ <tr data-equipment="<%= equipment.id %>">
+ <td><%= equipment.name %></td>
+ <td><%= equipment.price %></td>
+ <td></td>
View
@@ -10,6 +10,7 @@ group :test do
gem "cucumber-rails", require: false
gem "database_cleaner"
gem "spork"
+ gem "launchy"
gem "guard-rspec"
gem "guard-cucumber"
gem "guard-spork"
View
@@ -28,6 +28,7 @@ GEM
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.2.7)
arel (3.0.2)
bourbon (1.4.0)
sass (>= 3.1)
@@ -91,6 +92,8 @@ GEM
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.6.6)
+ launchy (2.1.0)
+ addressable (~> 2.2.6)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -184,6 +187,7 @@ DEPENDENCIES
guard-spork
high_voltage
jquery-rails
+ launchy
pg
rails (= 3.2.2)
rspec-rails
Binary file not shown.
@@ -0,0 +1,4 @@
+class AdminsController < ApplicationController
+ layout 'admin'
+
+end
@@ -0,0 +1,20 @@
+class AdminsEquipmentsController < ApplicationController
+ layout 'admin'
+
+ def index
+ @equipment = Equipment.all
+ end
+
+ def new
+ @equipment = Equipment.new
+ end
+
+ def create
+ @equipment = Equipment.new(params[:equipment])
+ if(@equipment.save)
+ redirect_to admin_equipments_path
+ else
+ render :new
+ end
+ end
+end
@@ -0,0 +1,13 @@
+class AdminsUsersController < ApplicationController
+ layout 'admin'
+
+ def index
+ @users = User.all
+ end
+
+ def update
+ @user = User.find(params[:id])
+ @user.update_attributes(params[:user])
+ redirect_to admin_users_path
+ end
+end
@@ -1,2 +1,12 @@
module ApplicationHelper
+ def current_user_is_admin?
+ current_user && current_user.admin
+ end
+
+def admin_link
+ if current_user_is_admin?
+ link_to "Admin", admin_path
+ end
+end
+
end
Binary file not shown.
View
@@ -0,0 +1,3 @@
+class Chassis < ActiveRecord::Base
+ has_many :robots
+end
View
@@ -0,0 +1,6 @@
+class Equipment < ActiveRecord::Base
+ has_many :inventories
+ has_many :users, :through => :inventories
+
+ validates_presence_of :name, :price
+end
View
@@ -0,0 +1,3 @@
+class Inventory < ActiveRecord:: Base
+ validates_presence_of :user, :equipment
+end
View
@@ -1,4 +1,8 @@
class Robot < ActiveRecord::Base
belongs_to :user
- validates_presence_of :user
+ belongs_to :chassis
+
+ %w{user chassis name}.map{|field|
+ validates_presence_of field
+ }
end
View
@@ -0,0 +1,3 @@
+class Statistic
+
+end
View
@@ -1,4 +1,10 @@
class User < ActiveRecord::Base
include Clearance::User
+ attr_accessible :admin, :balance
+
+ validates :balance, :numericality => { :only_integer => true,
+ :greater_than_or_equal_to => 0 }
has_many :robots
+ has_many :inventories
+ has_many :equipment, :through => :inventories
end
@@ -0,0 +1 @@
+
@@ -0,0 +1,17 @@
+<div data-role="equipment_actios">
+ <%= link_to "New Equipment", new_admin_equipment_path %>
+</div>
+<table data-role="equipment">
+ <tr>
+ <th>Name</th>
+ <th>Price</th>
+ <th>&nbsp;</th>
+ </tr>
+ <% @equipment.each do |equipment| %>
+ <tr data-equipment="<%= equipment.id %>">
+ <td><%= equipment.name %></td>
+ <td><%= equipment.price %></td>
+ <td></td>
+ </tr>
+ <% end %>
+</table>
@@ -0,0 +1,5 @@
+<%= semantic_form_for @equipment, :url => admin_equipments_path do |form| %>
+ <%= form.input :name %>
+ <%= form.input :price %>
+ <%= form.action :submit, :as => :button, :label => 'Save' %>
+<% end %>
@@ -0,0 +1,18 @@
+<table data-role="users">
+ <tr>
+ <th>Email</th>
+ <th>Administrator?</th>
+ </tr>
+ <% @users.each do |user| %>
+ <% disabled = (user == current_user) %>
+ <tr data-user="<%= user.id %>">
+ <td><%= user.email %></td>
+ <td>
+ <%= form_for user, :url => admin_user_path(user), :method => :put do |form| %>
+ <%= form.check_box :admin, :id => "user_#{user.id}_admin", :disabled => disabled %>
+ <%= form.submit "save", :disabled => disabled %>
+ <% end %>
+ </td>
+ </tr>
+ <% end %>
+</table>
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Roboterror</title>
+ <%= stylesheet_link_tag "application", :media => "all" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+ </head>
+ <body class="<%= body_class %>" >
+ <div class="page-wrapper">
+ <% if signed_in? %>
+ <div data-role="user-identification">
+ <%= current_user.email %>
+ <%= link_to "Sign out", "/sign_out", method: :delete %>
+ <%= admin_link %>
+ </div>
+ <% end %>
+ <nav data-role="admin-navigation">
+ <%= link_to "Users", admin_users_path %>
+ <%= link_to "Equipment", admin_equipments_path %>
+ </nav>
+ <div data-role="flash">
+ <% flash.each do |key, value| -%>
+ <div class="flash <%= key %>"><%= value %></div>
+ <% end -%>
+ </div>
+ <%= yield %>
+ </div>
+ </body>
+ <%= yield :footer_script %>
+</html>
@@ -8,12 +8,13 @@
</head>
<body class="<%= body_class %>" >
<div class="page-wrapper">
- <% if signed_in? %>
- <div data-role="user-identification">
- <%= current_user.email %>
- <%= link_to "Sign out", "/sign_out", method: :delete %>
- </div>
- <% else %>
+ <% if signed_in? %>
+ <div data-role="user-identification">
+ <%= current_user.email %>
+ <%= link_to "Sign out", "/sign_out", method: :delete %>
+ <%= admin_link %>
+ </div>
+ <% else %>
<div data-role="user-sign-in">
<%= link_to "Sign in", "/sign_in" %>
</div>
@@ -1,6 +1,6 @@
<h2>Create a new Robot</h2>
-<%= form_for @robot do |form| %>
- <%= form.label :name, "Robot name" %>
- <%= form.text_field :name %>
+<%= semantic_form_for @robot do |form| %>
+ <%= form.input :name, label: "Robot name" %>
+ <%= form.input :chassis, as: "select" %>
<%= form.submit "Deployz!!" %>
<% end %>
View
@@ -2,5 +2,10 @@
root to: "homepages#index"
+ resource :admin, :only => ['show'] do
+ resources :users, :only => ['index', 'update'], :controller => 'admins_users'
+ resources :equipments, :only => ['index', 'new', 'create'], :controller => 'admins_equipments'
+ end
+
resources :robots, :only => ['index', 'show', 'new', 'create', 'edit', 'update', 'destroy']
end
Binary file not shown.
@@ -0,0 +1,6 @@
+class AddChassisToRobot < ActiveRecord::Migration
+ def change
+ add_column :robots, :chassis_id, :integer
+ add_index :robots, :chassis_id
+ end
+end
@@ -0,0 +1,8 @@
+class CreateChasses < ActiveRecord::Migration
+ def change
+ create_table :chasses do |t|
+t.column :name, :integer
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,19 @@
+class CreateDieselClearanceUsers < ActiveRecord::Migration
+ def self.up
+ create_table(:users) do |t|
+ t.string :email
+ t.string :encrypted_password, :limit => 128
+ t.string :salt, :limit => 128
+ t.string :confirmation_token, :limit => 128
+ t.string :remember_token, :limit => 128
+ t.timestamps
+ end
+
+ add_index :users, :email
+ add_index :users, :remember_token
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
@@ -0,0 +1,8 @@
+class ChangeChassesNameToString < ActiveRecord::Migration
+ def up
+ change_column :chasses, :name, :string
+ end
+
+ def down
+ end
+end
@@ -0,0 +1,5 @@
+class AddAdminToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :admin, :boolean
+ end
+end
@@ -0,0 +1,7 @@
+class CreateEquipmentModel < ActiveRecord::Migration
+ def change
+ create_table :equipment do |table|
+ table.string :name
+ end
+ end
+end
@@ -0,0 +1,13 @@
+class CreateInventory < ActiveRecord::Migration
+ def up
+ create_table :inventories do |table|
+ table.integer :equipment_id
+ table.integer :user_id
+ table.integer :robot_id
+ end
+ end
+
+ def down
+ drop_table :inventories
+ end
+end
@@ -0,0 +1,5 @@
+class ChangeEquipmentTable < ActiveRecord::Migration
+ def change
+ add_column :equipment, :price, :integer
+ end
+end
@@ -0,0 +1,5 @@
+class AddBalanceToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :balance, :integer
+ end
+end
@@ -0,0 +1,8 @@
+class AddUserEquipmentRobotToInventory < ActiveRecord::Migration
+ def change
+ add_column :inventories, :user, :integer
+ add_column :inventories, :equipment, :integer
+ add_column :inventories, :robot, :integer
+ add_column :inventories, :price, :integer
+ end
+end
Oops, something went wrong.

0 comments on commit 1a0d447

Please sign in to comment.