From c00c8fa3dfb8c87f65da526e9fd87d54959d9303 Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Sat, 5 Jan 2013 14:01:26 -0500 Subject: [PATCH] Fixed user profiles and added NOTE action to bike_logs --- app/components/user_logs.rb | 2 +- app/components/user_profiles.rb | 8 ++++++++ app/components/users_and_profiles_border.rb | 5 ++++- app/models/user.rb | 2 +- app/models/user_profile.rb | 2 +- db/seed/fixtures/acts_as_loggable/bike_actions.yml | 13 +++++++++---- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/components/user_logs.rb b/app/components/user_logs.rb index a580967..c5dfbbf 100644 --- a/app/components/user_logs.rb +++ b/app/components/user_logs.rb @@ -11,7 +11,7 @@ class UserLogs < Netzke::Basepack::Grid :logger_id => controller.current_user.id, :copy_type => 'Bike', :copy_action_type => 'ActsAsLoggable::BikeAction', - :copy_action_id => 3 + :copy_action_id => 4 } #just users diff --git a/app/components/user_profiles.rb b/app/components/user_profiles.rb index eea0545..1048f66 100644 --- a/app/components/user_profiles.rb +++ b/app/components/user_profiles.rb @@ -1,19 +1,27 @@ class UserProfiles < Netzke::Basepack::Grid + def configure(c) super if controller.current_user.user? user_profiles_scope = lambda { |rel| rel.where(:user_id => controller.current_user.id);} user_profiles_data_store = { auto_load: true } + user_profile_strong_default_attrs = { + :user_id => controller.current_user.id + } else user_profiles_scope = lambda { |rel| rel.where(:user_id => session[:selected_user_id]);} user_profiles_data_store = { auto_load: false} + user_profile_strong_default_attrs = { + :user_id => session[:selected_user_id] + } end c.model = "UserProfile" c.title = "Profile" c.data_store = user_profiles_data_store c.scope = user_profiles_scope + c.strong_default_attrs = user_profile_strong_default_attrs c.columns = [ :addrStreet1, :addrStreet2, diff --git a/app/components/users_and_profiles_border.rb b/app/components/users_and_profiles_border.rb index 71e9b51..d0e8a84 100644 --- a/app/components/users_and_profiles_border.rb +++ b/app/components/users_and_profiles_border.rb @@ -24,7 +24,10 @@ class UsersAndProfilesBorder < Netzke::Base function(){ // calling superclass's initComponent this.callParent(); - this.getComponent('user_stats').updateStats(); + var stats = this.getComponent('user_stats'); + if (stats != undefined){ + stats.updateStats(); + } // setting the 'rowclick' event var view = this.getComponent('users').getView(); diff --git a/app/models/user.rb b/app/models/user.rb index e352105..9caeccc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,7 +7,7 @@ class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, - :first_name, :last_name, :nickname, :user_role_id + :first_name, :last_name, :nickname, :user_role_id, :bike_id has_many :user_profiles belongs_to :user_role diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb index e3e1d4d..4ef323f 100644 --- a/app/models/user_profile.rb +++ b/app/models/user_profile.rb @@ -1,6 +1,6 @@ class UserProfile < ActiveRecord::Base # Setup accessible (or protected) attributes for your model - attr_accessible :bike_id, :addrStreet1, :addrStreet2, :addrCity, + attr_accessible :user_id, :addrStreet1, :addrStreet2, :addrCity, :addrState, :addrZip, :phone belongs_to :user diff --git a/db/seed/fixtures/acts_as_loggable/bike_actions.yml b/db/seed/fixtures/acts_as_loggable/bike_actions.yml index c64121b..8dcd8a5 100644 --- a/db/seed/fixtures/acts_as_loggable/bike_actions.yml +++ b/db/seed/fixtures/acts_as_loggable/bike_actions.yml @@ -1,15 +1,20 @@ -acquired: +note: id: 1 + action: NOTE + created_at: <%= Time.now %> + updated_at: <%= Time.now %> +acquired: + id: 2 action: ACQUIRED created_at: <%= Time.now %> updated_at: <%= Time.now %> scrapped: - id: 2 + id: 3 action: SCRAPPED created_at: <%= Time.now %> updated_at: <%= Time.now %> worked: - id: 3 + id: 4 action: WORKED created_at: <%= Time.now %> updated_at: <%= Time.now %> @@ -19,7 +24,7 @@ completed: created_at: <%= Time.now %> updated_at: <%= Time.now %> sold: - id: 5 + id: 6 action: SOLD created_at: <%= Time.now %> updated_at: <%= Time.now %>