From 3c38b2fd7c38e5da64d0445d41edb5f7a8f9eb09 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 18 May 2012 15:53:20 +0200 Subject: [PATCH] Added module layer to load default collections. --- .../sessions/collection_network.rb | 11 +++++++++ app/controllers/sessions/collection_ticket.rb | 12 ++++++++++ app/controllers/sessions_controller.rb | 24 +++++++++---------- 3 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 app/controllers/sessions/collection_network.rb create mode 100644 app/controllers/sessions/collection_ticket.rb diff --git a/app/controllers/sessions/collection_network.rb b/app/controllers/sessions/collection_network.rb new file mode 100644 index 000000000..319000f70 --- /dev/null +++ b/app/controllers/sessions/collection_network.rb @@ -0,0 +1,11 @@ +module ExtraCollection + def add(collections) + + collections['Network'] = Network.all + collections['NetworkCategory'] = Network::Category.all + collections['NetworkCategoryType'] = Network::Category::Type.all + collections['NetworkPrivacy'] = Network::Privacy.all + + end + module_function :add +end \ No newline at end of file diff --git a/app/controllers/sessions/collection_ticket.rb b/app/controllers/sessions/collection_ticket.rb new file mode 100644 index 000000000..97414be62 --- /dev/null +++ b/app/controllers/sessions/collection_ticket.rb @@ -0,0 +1,12 @@ +module ExtraCollection + def add(collections) + + collections['TicketStateType'] = Ticket::StateType.all + collections['TicketState'] = Ticket::State.all + collections['TicketPriority'] = Ticket::Priority.all + collections['TicketArticleType'] = Ticket::Article::Type.all + collections['TicketArticleSender'] = Ticket::Article::Sender.all + + end + module_function :add +end \ No newline at end of file diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 3168d9d68..19d921641 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -130,18 +130,18 @@ class SessionsController < ApplicationController # auto population of default collections default_collection = {} - default_collection['Role'] = Role.all - default_collection['Group'] = Group.all - default_collection['Organization'] = Organization.all - default_collection['TicketStateType'] = Ticket::StateType.all - default_collection['TicketState'] = Ticket::State.all - default_collection['TicketPriority'] = Ticket::Priority.all - default_collection['TicketArticleType'] = Ticket::Article::Type.all - default_collection['TicketArticleSender'] = Ticket::Article::Sender.all - default_collection['Network'] = Network.all - default_collection['NetworkCategory'] = Network::Category.all - default_collection['NetworkCategoryType'] = Network::Category::Type.all - default_collection['NetworkPrivacy'] = Network::Privacy.all + default_collection['Role'] = Role.all + default_collection['Group'] = Group.all + default_collection['Organization'] = Organization.all + + # load routes from external files + dir = File.expand_path('../', __FILE__) + files = Dir.glob( "#{dir}/sessions/collection_*.rb" ) + for file in files + require file + ExtraCollection.add(default_collection) + end + return default_collection end end \ No newline at end of file