From cd34b66de1d6583c8b6d7fe1481aea94609bbf66 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 17 Jun 2014 02:23:42 +0200 Subject: [PATCH] Improved asset data for user. --- app/assets/javascripts/app/models/user.js.coffee | 3 +++ app/models/ticket/assets.rb | 16 ++++++++-------- app/models/user/assets.rb | 15 +++++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/app/models/user.js.coffee b/app/assets/javascripts/app/models/user.js.coffee index 29f43331d..99b392957 100644 --- a/app/assets/javascripts/app/models/user.js.coffee +++ b/app/assets/javascripts/app/models/user.js.coffee @@ -46,5 +46,8 @@ class App.User extends App.Model # set image url data.image = @apiPath + '/users/image/' + data.image + if data.organization_id + data.organization = App.Organization.find(data.organization_id) + data diff --git a/app/models/ticket/assets.rb b/app/models/ticket/assets.rb index 53aa439f6..ff4472861 100644 --- a/app/models/ticket/assets.rb +++ b/app/models/ticket/assets.rb @@ -33,17 +33,17 @@ returns if !data[ User.to_app_model ] data[ User.to_app_model ] = {} end - if !data[ User.to_app_model ][ self['owner_id'] ] - data[ User.to_app_model ][ self['owner_id'] ] = User.user_data_full( self['owner_id'] ) + if !data[ User.to_app_model ][ self.owner_id ] + data[ User.to_app_model ][ self.owner_id ] = User.user_data_full( self.owner_id ) end - if !data[ User.to_app_model ][ self['customer_id'] ] - data[ User.to_app_model ][ self['customer_id'] ] = User.user_data_full( self['customer_id'] ) + if !data[ User.to_app_model ][ self.customer_id ] + data[ User.to_app_model ][ self.customer_id ] = User.user_data_full( self.customer_id ) end - if !data[ User.to_app_model ][ self['created_by_id'] ] - data[ User.to_app_model ][ self['created_by_id'] ] = User.user_data_full( self['created_by_id'] ) + if !data[ User.to_app_model ][ self.created_by_id ] + data[ User.to_app_model ][ self.created_by_id ] = User.user_data_full( self.created_by_id ) end - if !data[ User.to_app_model ][ self['updated_by_id'] ] - data[ User.to_app_model ][ self['updated_by_id'] ] = User.user_data_full( self['updated_by_id'] ) + if !data[ User.to_app_model ][ self.updated_by_id ] + data[ User.to_app_model ][ self.updated_by_id ] = User.user_data_full( self.updated_by_id ) end data end diff --git a/app/models/user/assets.rb b/app/models/user/assets.rb index 49d0e2779..b601fcbfe 100644 --- a/app/models/user/assets.rb +++ b/app/models/user/assets.rb @@ -28,11 +28,18 @@ returns if !data[ User.to_app_model ][ self.id ] data[ User.to_app_model ][ self.id ] = User.user_data_full( self.id ) end - if !data[ User.to_app_model ][ self['created_by_id'] ] - data[ User.to_app_model ][ self['created_by_id'] ] = User.user_data_full( self['created_by_id'] ) + if self.organization_id + if !data[ Organization.to_app_model ] + data[ Organization.to_app_model ] = {} + end + if !data[ Organization.to_app_model ][ self.organization_id ] + data[ Organization.to_app_model ][ self.organization_id ] = Organization.find( self.organization_id ) end - if !data[ User.to_app_model ][ self['updated_by_id'] ] - data[ User.to_app_model ][ self['updated_by_id'] ] = User.user_data_full( self['updated_by_id'] ) + if !data[ User.to_app_model ][ self.created_by_id ] + data[ User.to_app_model ][ self.created_by_id ] = User.user_data_full( self.created_by_id ) + end + if !data[ User.to_app_model ][ self.updated_by_id ] + data[ User.to_app_model ][ self.updated_by_id ] = User.user_data_full( self.updated_by_id ) end data end