Improved asset data for user.

This commit is contained in:
Martin Edenhofer 2014-06-17 02:23:42 +02:00
parent b03bfe7327
commit cd34b66de1
3 changed files with 22 additions and 12 deletions

View file

@ -46,5 +46,8 @@ class App.User extends App.Model
# set image url # set image url
data.image = @apiPath + '/users/image/' + data.image data.image = @apiPath + '/users/image/' + data.image
if data.organization_id
data.organization = App.Organization.find(data.organization_id)
data data

View file

@ -33,17 +33,17 @@ returns
if !data[ User.to_app_model ] if !data[ User.to_app_model ]
data[ User.to_app_model ] = {} data[ User.to_app_model ] = {}
end end
if !data[ User.to_app_model ][ 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'] ) data[ User.to_app_model ][ self.owner_id ] = User.user_data_full( self.owner_id )
end end
if !data[ User.to_app_model ][ 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'] ) data[ User.to_app_model ][ self.customer_id ] = User.user_data_full( self.customer_id )
end end
if !data[ User.to_app_model ][ 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'] ) data[ User.to_app_model ][ self.created_by_id ] = User.user_data_full( self.created_by_id )
end end
if !data[ User.to_app_model ][ 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'] ) data[ User.to_app_model ][ self.updated_by_id ] = User.user_data_full( self.updated_by_id )
end end
data data
end end

View file

@ -28,11 +28,18 @@ returns
if !data[ User.to_app_model ][ self.id ] if !data[ User.to_app_model ][ self.id ]
data[ User.to_app_model ][ self.id ] = User.user_data_full( self.id ) data[ User.to_app_model ][ self.id ] = User.user_data_full( self.id )
end end
if !data[ User.to_app_model ][ self['created_by_id'] ] if self.organization_id
data[ User.to_app_model ][ self['created_by_id'] ] = User.user_data_full( self['created_by_id'] ) if !data[ Organization.to_app_model ]
data[ Organization.to_app_model ] = {}
end end
if !data[ User.to_app_model ][ self['updated_by_id'] ] if !data[ Organization.to_app_model ][ self.organization_id ]
data[ User.to_app_model ][ self['updated_by_id'] ] = User.user_data_full( self['updated_by_id'] ) data[ Organization.to_app_model ][ self.organization_id ] = Organization.find( self.organization_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 )
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 end
data data
end end