From 438baa1231f8e2a5b3fe87bb04d071a97468fcdc Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 22 Sep 2013 00:50:23 +0200 Subject: [PATCH] Renamed class name to get app model name. --- app/controllers/application_controller.rb | 4 +-- app/controllers/sessions/collection_base.rb | 18 ++++++------ .../sessions/collection_network.rb | 16 +++++------ app/controllers/sessions/collection_ticket.rb | 28 +++++++++---------- app/controllers/sessions_controller.rb | 2 +- .../ticket_overviews_controller.rb | 6 ++-- app/controllers/tickets_controller.rb | 24 ++++++++-------- app/models/history/assets.rb | 20 ++++++------- app/models/organization/assets.rb | 18 ++++++------ app/models/ticket/article/assets.rb | 22 +++++++-------- app/models/ticket/assets.rb | 28 +++++++++---------- app/models/user/assets.rb | 8 +++--- lib/core_ext/class.rb | 6 ++-- lib/sessions/backend/ticket_overview_list.rb | 4 +-- lib/sessions/client.rb | 6 ++-- 15 files changed, 105 insertions(+), 105 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cf2233f11..8c96d274f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -257,7 +257,7 @@ class ApplicationController < ActionController::Base begin # create object - generic_object = object.new( object.param_cleanup( params[object.to_app_model] ) ) + generic_object = object.new( object.param_cleanup( params[object.to_app_model_url] ) ) # save object generic_object.save! @@ -281,7 +281,7 @@ class ApplicationController < ActionController::Base generic_object = object.find( params[:id] ) # save object - generic_object.update_attributes!( object.param_cleanup( params[object.to_app_model] ) ) + generic_object.update_attributes!( object.param_cleanup( params[object.to_app_model_url] ) ) model_update_render_item(generic_object) rescue Exception => e logger.error e.message diff --git a/app/controllers/sessions/collection_base.rb b/app/controllers/sessions/collection_base.rb index 3ad1aecad..3aea3e3e2 100644 --- a/app/controllers/sessions/collection_base.rb +++ b/app/controllers/sessions/collection_base.rb @@ -4,29 +4,29 @@ module ExtraCollection def session( collections, user ) # all base stuff - collections[ Taskbar.to_online_model ] = Taskbar.where( :user_id => user.id ) - collections[ Role.to_online_model ] = Role.all - collections[ Group.to_online_model ] = Group.all + collections[ Taskbar.to_app_model ] = Taskbar.where( :user_id => user.id ) + collections[ Role.to_app_model ] = Role.all + collections[ Group.to_app_model ] = Group.all if !user.is_role('Customer') - collections[ Organization.to_online_model ] = Organization.all + collections[ Organization.to_app_model ] = Organization.all else if user.organization_id - collections[ Organization.to_online_model ] = Organization.where( :id => user.organization_id ) + collections[ Organization.to_app_model ] = Organization.where( :id => user.organization_id ) end end end def push( collections, user ) # all base stuff - collections[ Role.to_online_model ] = Role.all - collections[ Group.to_online_model ] = Group.all + collections[ Role.to_app_model ] = Role.all + collections[ Group.to_app_model ] = Group.all if !user.is_role('Customer') - collections[ Organization.to_online_model ] = Organization.all + collections[ Organization.to_app_model ] = Organization.all else if user.organization_id - collections[ Organization.to_online_model ] = Organization.where( :id => user.organization_id ) + collections[ Organization.to_app_model ] = Organization.where( :id => user.organization_id ) end end end diff --git a/app/controllers/sessions/collection_network.rb b/app/controllers/sessions/collection_network.rb index 2952b2879..5029fd172 100644 --- a/app/controllers/sessions/collection_network.rb +++ b/app/controllers/sessions/collection_network.rb @@ -3,18 +3,18 @@ module ExtraCollection def session( collections, user ) - collections[ Network.to_online_model ] = Network.all - collections[ Network::Category.to_online_model ] = Network::Category.all - collections[ Network::Category::Type.to_online_model ] = Network::Category::Type.all - collections[ Network::Privacy.to_online_model ] = Network::Privacy.all + collections[ Network.to_app_model ] = Network.all + collections[ Network::Category.to_app_model ] = Network::Category.all + collections[ Network::Category::Type.to_app_model ] = Network::Category::Type.all + collections[ Network::Privacy.to_app_model ] = Network::Privacy.all end def push( collections, user ) - collections[ Network.to_online_model ] = Network.all - collections[ Network::Category.to_online_model ] = Network::Category.all - collections[ Network::Category::Type.to_online_model ] = Network::Category::Type.all - collections[ Network::Privacy.to_online_model ] = Network::Privacy.all + collections[ Network.to_app_model ] = Network.all + collections[ Network::Category.to_app_model ] = Network::Category.all + collections[ Network::Category::Type.to_app_model ] = Network::Category::Type.all + collections[ Network::Privacy.to_app_model ] = Network::Privacy.all end module_function :session, :push diff --git a/app/controllers/sessions/collection_ticket.rb b/app/controllers/sessions/collection_ticket.rb index 026ccbfcc..5f62e03d4 100644 --- a/app/controllers/sessions/collection_ticket.rb +++ b/app/controllers/sessions/collection_ticket.rb @@ -4,37 +4,37 @@ module ExtraCollection def session( collections, user ) # all ticket stuff - collections[ Ticket::StateType.to_online_model ] = Ticket::StateType.all - collections[ Ticket::State.to_online_model ] = Ticket::State.all - collections[ Ticket::Priority.to_online_model ] = Ticket::Priority.all - collections[ Ticket::Article::Type.to_online_model ] = Ticket::Article::Type.all - collections[ Ticket::Article::Sender.to_online_model ] = Ticket::Article::Sender.all + collections[ Ticket::StateType.to_app_model ] = Ticket::StateType.all + collections[ Ticket::State.to_app_model ] = Ticket::State.all + collections[ Ticket::Priority.to_app_model ] = Ticket::Priority.all + collections[ Ticket::Article::Type.to_app_model ] = Ticket::Article::Type.all + collections[ Ticket::Article::Sender.to_app_model ] = Ticket::Article::Sender.all if !user.is_role('Customer') # all signatures - collections[ Signature.to_online_model ] = Signature.all + collections[ Signature.to_app_model ] = Signature.all # all email addresses - collections[ EmailAddress.to_online_model ] = EmailAddress.all + collections[ EmailAddress.to_app_model ] = EmailAddress.all end end def push( collections, user ) # all ticket stuff - collections[ Ticket::StateType.to_online_model ] = Ticket::StateType.all - collections[ Ticket::State.to_online_model ] = Ticket::State.all - collections[ Ticket::Priority.to_online_model ] = Ticket::Priority.all - collections[ Ticket::Article::Type.to_online_model ] = Ticket::Article::Type.all - collections[ Ticket::Article::Sender.to_online_model ] = Ticket::Article::Sender.all + collections[ Ticket::StateType.to_app_model ] = Ticket::StateType.all + collections[ Ticket::State.to_app_model ] = Ticket::State.all + collections[ Ticket::Priority.to_app_model ] = Ticket::Priority.all + collections[ Ticket::Article::Type.to_app_model ] = Ticket::Article::Type.all + collections[ Ticket::Article::Sender.to_app_model ] = Ticket::Article::Sender.all if !user.is_role('Customer') # all signatures - collections[ Signature.to_online_model ] = Signature.all + collections[ Signature.to_app_model ] = Signature.all # all email addresses - collections[ EmailAddress.to_online_model ] = EmailAddress.all + collections[ EmailAddress.to_app_model ] = EmailAddress.all end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 28cfbd186..d76b6857a 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -161,7 +161,7 @@ class SessionsController < ApplicationController } render :json => { :sessions => sessions_clean, - User.to_online_model.to_sym => users, + User.to_app_model => users, } end diff --git a/app/controllers/ticket_overviews_controller.rb b/app/controllers/ticket_overviews_controller.rb index da931a1a3..7a3bc802a 100644 --- a/app/controllers/ticket_overviews_controller.rb +++ b/app/controllers/ticket_overviews_controller.rb @@ -49,7 +49,7 @@ class TicketOverviewsController < ApplicationController end # get related users - assets = { User.to_online_model.to_sym => {} } + assets = { User.to_app_model => {} } overview[:ticket_ids].each {|ticket_id| ticket = Ticket.lookup( :id => ticket_id ) assets = ticket.assets(assets) @@ -70,8 +70,8 @@ class TicketOverviewsController < ApplicationController Group.find(group_id).users.each {|user| next if !agents[ user.id ] groups_users[ group_id ].push user.id - if !assets[ User.to_online_model.to_sym ][user.id] - assets[ User.to_online_model.to_sym ][user.id] = User.user_data_full(user.id) + if !assets[ User.to_app_model ][user.id] + assets[ User.to_app_model ][user.id] = User.user_data_full(user.id) end } } diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 9e3b5c023..5bd83b48e 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -304,22 +304,22 @@ class TicketsController < ApplicationController # get related users assets = {} - assets[ User.to_online_model.to_sym ] = {} + assets[ User.to_app_model ] = {} assets = ticket.assets(assets) # get attributes to update attributes_to_change = Ticket::ScreenOptions.attributes_to_change( :user => current_user, :ticket => ticket ) attributes_to_change[:owner_id].each { |user_id| - if !assets[ User.to_online_model.to_sym ][user_id] - assets[ User.to_online_model.to_sym ][user_id] = User.user_data_full( user_id ) + if !assets[ User.to_app_model ][user_id] + assets[ User.to_app_model ][user_id] = User.user_data_full( user_id ) end } attributes_to_change[:group_id__owner_id].each {|group_id, user_ids| user_ids.each {|user_id| - if !assets[ User.to_online_model.to_sym ][user_id] - assets[ User.to_online_model.to_sym ][user_id] = User.user_data_full( user_id ) + if !assets[ User.to_app_model ][user_id] + assets[ User.to_app_model ][user_id] = User.user_data_full( user_id ) end } } @@ -362,17 +362,17 @@ class TicketsController < ApplicationController ) assets = {} - assets[ User.to_online_model.to_sym ] = {} + assets[ User.to_app_model ] = {} attributes_to_change[:owner_id].each { |user_id| - if !assets[ User.to_online_model.to_sym ][user_id] - assets[ User.to_online_model.to_sym ][user_id] = User.user_data_full( user_id ) + if !assets[ User.to_app_model ][user_id] + assets[ User.to_app_model ][user_id] = User.user_data_full( user_id ) end } attributes_to_change[:group_id__owner_id].each {|group_id, user_ids| user_ids.each {|user_id| - if !assets[ User.to_online_model.to_sym ][user_id] - assets[ User.to_online_model.to_sym ][user_id] = User.user_data_full( user_id ) + if !assets[ User.to_app_model ][user_id] + assets[ User.to_app_model ][user_id] = User.user_data_full( user_id ) end } } @@ -387,8 +387,8 @@ class TicketsController < ApplicationController owner_ids = [] ticket.agent_of_group.each { |user| owner_ids.push user.id - if !assets[ User.to_online_model.to_sym ][user.id] - assets[ User.to_online_model.to_sym ][user.id] = User.user_data_full( user.id ) + if !assets[ User.to_app_model ][user.id] + assets[ User.to_app_model ][user.id] = User.user_data_full( user.id ) end } diff --git a/app/models/history/assets.rb b/app/models/history/assets.rb index d42283307..fbabe11bf 100644 --- a/app/models/history/assets.rb +++ b/app/models/history/assets.rb @@ -22,22 +22,22 @@ returns def assets (data) - if !data[ User.to_online_model.to_sym ] - data[ User.to_online_model.to_sym ] = {} + if !data[ User.to_app_model ] + data[ User.to_app_model ] = {} end - if !data[ User.to_online_model.to_sym ][ self['created_by_id'] ] - data[ User.to_online_model.to_sym ][ 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 # fetch meta relations - if !data[ History::Object.to_online_model.to_sym ] - data[ History::Object.to_online_model.to_sym ] = History::Object.all() + if !data[ History::Object.to_app_model ] + data[ History::Object.to_app_model ] = History::Object.all() end - if !data[ History::Type.to_online_model.to_sym ] - data[ History::Type.to_online_model.to_sym ] = History::Type.all() + if !data[ History::Type.to_app_model ] + data[ History::Type.to_app_model ] = History::Type.all() end - if !data[ History::Attribute.to_online_model.to_sym ] - data[ History::Attribute.to_online_model.to_sym ] = History::Attribute.all() + if !data[ History::Attribute.to_app_model ] + data[ History::Attribute.to_app_model ] = History::Attribute.all() end data diff --git a/app/models/organization/assets.rb b/app/models/organization/assets.rb index 11cb0e55b..9bb88d15f 100644 --- a/app/models/organization/assets.rb +++ b/app/models/organization/assets.rb @@ -22,19 +22,19 @@ returns def assets (data) - if !data[ Organization.to_online_model.to_sym ] - data[ Organization.to_online_model.to_sym ] = {} + if !data[ Organization.to_app_model ] + data[ Organization.to_app_model ] = {} end - if !data[ User.to_online_model.to_sym ] - data[ User.to_online_model.to_sym ] = {} + if !data[ User.to_app_model ] + data[ User.to_app_model ] = {} end - if !data[ Organization.to_online_model.to_sym ][ self.id ] - data[ Organization.to_online_model.to_sym ][ self.id ] = self.attributes - data[ Organization.to_online_model.to_sym ][ self.id ][:user_ids] = [] + if !data[ Organization.to_app_model ][ self.id ] + data[ Organization.to_app_model ][ self.id ] = self.attributes + data[ Organization.to_app_model ][ self.id ][:user_ids] = [] users = User.where( :organization_id => self.id ).limit(10) users.each {|user| - data[ User.to_online_model.to_sym ][ user.id ] = User.user_data_full( user.id ) - data[ Organization.to_online_model.to_sym ][ self.id ][:user_ids].push user.id + data[ User.to_app_model ][ user.id ] = User.user_data_full( user.id ) + data[ Organization.to_app_model ][ self.id ][:user_ids].push user.id } end data diff --git a/app/models/ticket/article/assets.rb b/app/models/ticket/article/assets.rb index 8515e475c..5c0cee906 100644 --- a/app/models/ticket/article/assets.rb +++ b/app/models/ticket/article/assets.rb @@ -23,24 +23,24 @@ returns def assets (data) - if !data[ Ticket::Article.to_online_model.to_sym ] - data[ Ticket::Article.to_online_model.to_sym ] = {} + if !data[ Ticket::Article.to_app_model ] + data[ Ticket::Article.to_app_model ] = {} end - if !data[ Ticket::Article.to_online_model.to_sym ][ self.id ] - data[ Ticket::Article.to_online_model.to_sym ][ self.id ] = self.attributes + if !data[ Ticket::Article.to_app_model ][ self.id ] + data[ Ticket::Article.to_app_model ][ self.id ] = self.attributes # add attachment list to article - data[ Ticket::Article.to_online_model.to_sym ][ self.id ]['attachments'] = Store.list( :object => 'Ticket::Article', :o_id => self.id ) + data[ Ticket::Article.to_app_model ][ self.id ]['attachments'] = Store.list( :object => 'Ticket::Article', :o_id => self.id ) end - if !data[ User.to_online_model.to_sym ] - data[ User.to_online_model.to_sym ] = {} + if !data[ User.to_app_model ] + data[ User.to_app_model ] = {} end - if !data[ User.to_online_model.to_sym ][ self['created_by_id'] ] - data[ User.to_online_model.to_sym ][ 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_online_model.to_sym ][ self['updated_by_id'] ] - data[ User.to_online_model.to_sym ][ 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/ticket/assets.rb b/app/models/ticket/assets.rb index 87584b48b..e70ebf73b 100644 --- a/app/models/ticket/assets.rb +++ b/app/models/ticket/assets.rb @@ -23,27 +23,27 @@ returns def assets (data) - if !data[ Ticket.to_online_model.to_sym ] - data[ Ticket.to_online_model.to_sym ] = {} + if !data[ Ticket.to_app_model ] + data[ Ticket.to_app_model ] = {} end - if !data[ Ticket.to_online_model.to_sym ][ self.id ] - data[ Ticket.to_online_model.to_sym ][ self.id ] = self.attributes + if !data[ Ticket.to_app_model ][ self.id ] + data[ Ticket.to_app_model ][ self.id ] = self.attributes end - if !data[ User.to_online_model.to_sym ] - data[ User.to_online_model.to_sym ] = {} + if !data[ User.to_app_model ] + data[ User.to_app_model ] = {} end - if !data[ User.to_online_model.to_sym ][ self['owner_id'] ] - data[ User.to_online_model.to_sym ][ 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_online_model.to_sym ][ self['customer_id'] ] - data[ User.to_online_model.to_sym ][ 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_online_model.to_sym ][ self['created_by_id'] ] - data[ User.to_online_model.to_sym ][ 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_online_model.to_sym ][ self['updated_by_id'] ] - data[ User.to_online_model.to_sym ][ 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 3425b7f0a..307d46b62 100644 --- a/app/models/user/assets.rb +++ b/app/models/user/assets.rb @@ -22,11 +22,11 @@ returns def assets (data) - if !data[ User.to_online_model.to_sym ] - data[ User.to_online_model.to_sym ] = {} + if !data[ User.to_app_model ] + data[ User.to_app_model ] = {} end - if !data[ User.to_online_model.to_sym ][ self.id ] - data[ User.to_online_model.to_sym ][ self.id ] = User.user_data_full( self.id ) + if !data[ User.to_app_model ][ self.id ] + data[ User.to_app_model ][ self.id ] = User.user_data_full( self.id ) end data end diff --git a/lib/core_ext/class.rb b/lib/core_ext/class.rb index 962d2182e..ebd89f90c 100644 --- a/lib/core_ext/class.rb +++ b/lib/core_ext/class.rb @@ -1,5 +1,5 @@ class Class - def to_app_model + def to_app_model_url camel_cased_word = self.to_s camel_cased_word.gsub(/::/, '_'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). @@ -7,8 +7,8 @@ class Class tr("-", "_"). downcase end - def to_online_model + def to_app_model camel_cased_word = self.to_s - camel_cased_word.gsub(/::/, '') + camel_cased_word.gsub(/::/, '').to_sym end end \ No newline at end of file diff --git a/lib/sessions/backend/ticket_overview_list.rb b/lib/sessions/backend/ticket_overview_list.rb index 824af2081..acf412a2c 100644 --- a/lib/sessions/backend/ticket_overview_list.rb +++ b/lib/sessions/backend/ticket_overview_list.rb @@ -70,8 +70,8 @@ module Sessions::Backend::TicketOverviewList # send update to browser client.send({ :data => { - User.to_online_model.to_sym => users, - Ticket.to_online_model.to_sym => tickets, + User.to_app_model => users, + Ticket.to_app_model => tickets, }, :event => [ 'loadAssets' ] }) diff --git a/lib/sessions/client.rb b/lib/sessions/client.rb index f5b53b00c..a2dfbc969 100644 --- a/lib/sessions/client.rb +++ b/lib/sessions/client.rb @@ -47,7 +47,7 @@ class Sessions::Client self.send({ :data => { :collections => { - User.to_online_model.to_sym => users, + User.to_app_model => users, }, }, :event => [ 'loadCollection', 'ticket_overview_rebuild' ], @@ -73,8 +73,8 @@ class Sessions::Client self.send({ :data => { :collections => { - Ticket.to_online_model.to_sym => tickets, - User.to_online_model.to_sym => users, + Ticket.to_app_model => tickets, + User.to_app_model => users, }, }, :event => [ 'loadCollection', 'ticket_overview_rebuild' ],