Browse Source

Closes #1

denney-disable-on-select
John N. Milner 12 years ago
parent
commit
55fbd06305
  1. 1
      app/components/bikes.rb
  2. 4
      app/components/transactions.rb
  3. 2
      app/components/user_logs.rb
  4. 2
      app/components/user_stats.rb
  5. 2
      app/components/user_transactions.rb
  6. 2
      app/components/users.rb
  7. 3
      app/models/bike.rb
  8. 5
      db/schema.rb
  9. 3
      spec/factories/bikes.rb

1
app/components/bikes.rb

@ -4,6 +4,7 @@ class Bikes < Netzke::Basepack::Grid
c.model = "Bike"
c.columns = [
{ :name => :shop_id, :text => 'Shop ID'},
:serial_number,
{ :name => :bike_brand__brand, :text => 'Brand' },
{ :name => :bike_model__model, :text => 'Model',

4
app/components/transactions.rb

@ -10,7 +10,7 @@ class Transactions < Netzke::Basepack::Grid
c.columns = [
:amount,
:item,
{ :name => :bike__serial_number},
{ :name => :bike__shop_id},
{ :name => :vendor, :getter => lambda { |rec|
user = rec.vendor
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
@ -27,7 +27,7 @@ class Transactions < Netzke::Basepack::Grid
end
def default_fields_for_forms
bike_store = Bike.all.map { |b| [b.id, b.serial_number] }
bike_store = Bike.all.map { |b| [b.id, b.shop_id] }
user_store = User.all.map { |u| [u.id, u.to_s] }
customer = nil
if session[:selected_customer_type] == "User"

2
app/components/user_logs.rb

@ -50,7 +50,7 @@ class UserLogs < Netzke::Basepack::Grid
def default_fields_for_forms
#figure out a better way to do this
bike_store = Bike.all.map { |b| [b.id, b.serial_number] }
bike_store = Bike.all.map { |b| [b.id, b.shop_id] }
current_user ||= User.find_by_id(session[:selected_user_id]) || controller.current_user
bike_id = current_user.bike.nil? ? nil : current_user.bike.id
action_id = current_user.user_role.id

2
app/components/user_stats.rb

@ -6,7 +6,7 @@ class UserStats < Netzke::Base
<div id="user_stats_page">
<p>Total Hours Worked: #{user.total_hours}</p>
<p>Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}</p>
<p>Current bike ID: #{bike.id if bike}</p>
<p>Current bike Shop ID: #{bike.shop_id if bike}</p>
<p>Current bike S/N: #{bike.serial_number if bike}</p>
</div>
)

2
app/components/user_transactions.rb

@ -10,7 +10,7 @@ class UserTransactions < Netzke::Basepack::Grid
c.columns = [
:amount,
:item,
{ :name => :bike__serial_number},
{ :name => :bike__shop_id},
{ :name => :vendor, :getter => lambda { |rec|
user = rec.vendor
user.nil? ? "" : "#{user.first_name} #{user.last_name}"

2
app/components/users.rb

@ -10,7 +10,7 @@ class Users < Netzke::Basepack::Grid
:nickname,
:email,
:user_role__role,
:bike__serial_number
:bike__shop_id
]
end

3
app/models/bike.rb

@ -1,6 +1,6 @@
class Bike < ActiveRecord::Base
acts_as_loggable
attr_accessible :serial_number, :bike_brand_id, :bike_model_id, :color, :bike_style_id, :seat_tube_height,
attr_accessible :shop_id, :serial_number, :bike_brand_id, :bike_model_id, :color, :bike_style_id, :seat_tube_height,
:top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_status_id
has_many :transactions
@ -13,6 +13,7 @@ class Bike < ActiveRecord::Base
belongs_to :bike_condition
belongs_to :bike_status
validates :shop_id, :presence => true, :uniqueness => true, :length => { :minimum => 3 }
validates :serial_number, :uniqueness => true, :length => { :minimum => 3 }
validates :bike_brand_id, :presence => true
validates :bike_model_id, :presence => true

5
db/schema.rb

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130209023110) do
ActiveRecord::Schema.define(:version => 20130405012238) do
create_table "bike_actions", :force => true do |t|
t.string "action", :limit => 128, :null => false
@ -60,9 +60,10 @@ ActiveRecord::Schema.define(:version => 20130209023110) do
t.integer "bike_status_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "shop_id"
end
add_index "bikes", ["serial_number"], :name => "index_bikes_on_serial_number", :unique => true
add_index "bikes", ["shop_id"], :name => "index_bikes_on_shop_id", :unique => true
create_table "customers", :force => true do |t|
t.string "first_name", :null => false

3
spec/factories/bikes.rb

@ -2,6 +2,9 @@
FactoryGirl.define do
factory :bike do
sequence :shop_id do |n|
"Shop ID #{n}"
end
sequence :serial_number do |n|
"S/N# #{n}"
end

Loading…
Cancel
Save