diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb deleted file mode 100644 index a20ea3a..0000000 --- a/app/controllers/account_controller.rb +++ /dev/null @@ -1,82 +0,0 @@ -class AccountController < ApplicationController - - # say something nice, you goof! something sweet. - def index - unless logged_in? - render :action => 'index_anonymous' - end - end - - # action to perform login to the application - def login - return unless request.post? - self.current_user = User.authenticate(params[:login], params[:password]) - if logged_in? - if params[:remember_me] == "1" - self.current_user.remember_me - cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } - end - redirect_back_or_default(:controller => '/account', :action => 'index') - flash[:notice] = _("Logged in successfully") - else - flash[:notice] = _('Incorrect username or password') - end - end - - # action to register an user to the application - def signup - begin - @user = User.new(params[:user]) - @user.terms_of_use = virtual_community.terms_of_use - @terms_of_use = virtual_community.terms_of_use - - if request.post? - @user.save! - @user.person.virtual_community = virtual_community - @user.person.save! - self.current_user = @user - redirect_back_or_default(:controller => 'account', :action => 'index') - flash[:notice] = _("Thanks for signing up!") - end - rescue ActiveRecord::RecordInvalid - render :action => 'signup' - end - end - - # action to perform logout from the application - def logout - self.current_user.forget_me if logged_in? - cookies.delete :auth_token - reset_session - flash[:notice] = _("You have been logged out.") - redirect_back_or_default(:controller => '/account', :action => 'index') - end - - def change_password - if request.post? - @user = current_user - begin - @user.change_password!(params[:current_password], - params[:new_password], - params[:new_password_confirmation]) - flash[:notice] = _('Your password has been changed successfully!') - redirect_to :action => 'index' - rescue User::IncorrectPassword => e - flash[:notice] = _('The supplied current password is incorrect.') - render :action => 'change_password' - end - else - render :action => 'change_password' - end - end - - protected - - before_filter :load_profile_for_user - def load_profile_for_user - return unless logged_in? - @profile = current_user.person - end - - -end diff --git a/app/controllers/admin_panel_controller.rb b/app/controllers/admin_panel_controller.rb deleted file mode 100644 index 54473ac..0000000 --- a/app/controllers/admin_panel_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class AdminPanelController < ApplicationController -end diff --git a/app/controllers/cms_controller.rb b/app/controllers/cms_controller.rb deleted file mode 100644 index 94f436f..0000000 --- a/app/controllers/cms_controller.rb +++ /dev/null @@ -1,3 +0,0 @@ -class CmsController < ComatoseAdminController - define_option :page_class, Article -end diff --git a/app/controllers/content_viewer_controller.rb b/app/controllers/content_viewer_controller.rb deleted file mode 100644 index 9788aca..0000000 --- a/app/controllers/content_viewer_controller.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ContentViewerController < ApplicationController - - def view_page - path = params[:page].clone - path.unshift(params[:profile]) - @path = path.join('/') - @page = Article.find_by_path(@path) - if @page.nil? - render :action => 'not_found', :status => 404 - end - end - -end diff --git a/app/controllers/edit_template_controller.rb b/app/controllers/edit_template_controller.rb deleted file mode 100644 index f863eea..0000000 --- a/app/controllers/edit_template_controller.rb +++ /dev/null @@ -1,18 +0,0 @@ -class EditTemplateController < ApplicationController - - design_editor :holder => 'virtual_community', :autosave => true, :block_types => :block_types - - def block_types - { - #'ListBlock' => _("List Block"), - #'LinkBlock' => _("Link Block"), - #'RecentDocumentsBlock' => _('Recent documents'), - 'Design::MainBlock' => _('Main content block'), - } - end - - def index - redirect_to :action => 'design_editor' - end - -end diff --git a/app/controllers/enterprise_controller.rb b/app/controllers/enterprise_controller.rb deleted file mode 100644 index 7da4fe8..0000000 --- a/app/controllers/enterprise_controller.rb +++ /dev/null @@ -1,143 +0,0 @@ -# Manage enterprises by providing an interface to register, activate and manage them -class EnterpriseController < ApplicationController - - before_filter :logon, :my_enterprises - - # Redirects to show if there is only one action and to list otherwise - def index - if @my_enterprises.size == 1 - redirect_to :action => 'show', :id => @my_enterprises[0] - else - redirect_to :action => 'list' - end - end - - # Lists all enterprises - def list - @enterprises = Enterprise.find(:all) - @my_enterprises - end - - # Show details about an enterprise - def show - @enterprise = @my_enterprises.find(params[:id]) - end - - # Make a form to the creation of an eterprise - def register_form - @enterprise = Enterprise.new() - @vitual_communities = VirtualCommunity.find(:all) - @validation_entities = Organization.find(:all) - end - - # Saves the new created enterprise - def register - @enterprise = Enterprise.new(params[:enterprise]) - @enterprise.organization_info = OrganizationInfo.new(params[:organization]) - if @enterprise.save - @enterprise.people << @person - flash[:notice] = _('The enterprise was succesfully created, the validation entity will cotact you as soon as your enterprise is approved') - redirect_to :action => 'index' - else - flash[:notice] = _('Enterprise was not created') - @vitual_communities = VirtualCommunity.find(:all) - @validation_entities = Organization.find(:all) - render :action => 'register_form' - end - end - - # Provides an interface to editing the enterprise details - def edit - @enterprise = @my_enterprises.find(params[:id]) - @validation_entities = Organization.find(:all) - [@enterprise] - end - - # Saves the changes made in an enterprise - def update - @enterprise = @my_enterprises.find(params[:id]) - if @enterprise.update_attributes(params[:enterprise]) && @enterprise.organization_info.update_attributes(params[:organization_info]) - redirect_to :action => 'index' - else - flash[:notice] = _('Could not update the enterprise') - @validation_entities = Organization.find(:all) - [@enterprise] - render :action => 'edit' - end - end - - # Make the current user a new member of the enterprise - def affiliate - @enterprise = Enterprise.find(params[:id]) - @enterprise.people << @person - redirect_to :action => 'index' - end - - # Elimitates the enterprise of the system - def destroy - @enterprise = @my_enterprises.find(params[:id]) - if @enterprise - @enterprise.destroy - else - flash[:notice] = 'Can destroy only your enterprises' - end - redirect_to :action => 'index' - end - - # Search enterprises by name or tags - def search - @tagged_enterprises = Enterprise.search(params[:query]) - end - - # Activate a validated enterprise - def activate - @enterprise = Enterprise.find(params[:id]) - if @enterprise.activate - flash[:notice] = _('Enterprise successfuly activacted') - else - flash[:notice] = _('Failed to activate the enterprise') - end - redirect_to :action => 'index' - end - - # Validates an eterprise - def approve - @enterprise = Enterprise.find(params[:id]) - if @enterprise.approve - flash[:notice] = _('Enterprise successfuly approved') - else - flash[:notice] = _('Failed to approve the enterprise') - end - redirect_to :action => 'index' - end - - # Rejects an enterprise - def reject - @enterprise = Enterprise.find(params[:id]) - if @enterprise.reject - flash[:notice] = _('Enterprise successfuly rejected') - else - flash[:notice] = _('Failed to reject the enterprise') - end - redirect_to :action => 'index' - end - - - protected - - # Make sure that the user is logged before access this controller - def logon - if logged_in? - @user = current_user - @person = @user.person - else - redirect_to :controller => 'account' unless logged_in? - end - end - - # Initializes some variables to contain the enterprises of the current user - def my_enterprises - if logged_in? - @my_active_enterprises = @person.active_enterprises - @my_pending_enterprises = @person.pending_enterprises - @my_enterprises = @person.enterprises - end - end -end diff --git a/app/controllers/environment_admin/admin_panel_controller.rb b/app/controllers/environment_admin/admin_panel_controller.rb new file mode 100644 index 0000000..54473ac --- /dev/null +++ b/app/controllers/environment_admin/admin_panel_controller.rb @@ -0,0 +1,2 @@ +class AdminPanelController < ApplicationController +end diff --git a/app/controllers/environment_admin/edit_template_controller.rb b/app/controllers/environment_admin/edit_template_controller.rb new file mode 100644 index 0000000..f863eea --- /dev/null +++ b/app/controllers/environment_admin/edit_template_controller.rb @@ -0,0 +1,18 @@ +class EditTemplateController < ApplicationController + + design_editor :holder => 'virtual_community', :autosave => true, :block_types => :block_types + + def block_types + { + #'ListBlock' => _("List Block"), + #'LinkBlock' => _("Link Block"), + #'RecentDocumentsBlock' => _('Recent documents'), + 'Design::MainBlock' => _('Main content block'), + } + end + + def index + redirect_to :action => 'design_editor' + end + +end diff --git a/app/controllers/environment_admin/features_controller.rb b/app/controllers/environment_admin/features_controller.rb new file mode 100644 index 0000000..a306824 --- /dev/null +++ b/app/controllers/environment_admin/features_controller.rb @@ -0,0 +1,22 @@ +class FeaturesController < ApplicationController + + acts_as_virtual_community_admin_controller + + def index + @features = VirtualCommunity.available_features + end + + post_only :update + def update + features = if params[:features].nil? + [] + else + params[:features].keys + end + @virtual_community.enabled_features = features + @virtual_community.save! + flash[:notice] = _('Features updated successfully.') + redirect_to :action => 'index' + end + +end diff --git a/app/controllers/environment_admin/manage_tags_controller.rb b/app/controllers/environment_admin/manage_tags_controller.rb new file mode 100644 index 0000000..c5794a4 --- /dev/null +++ b/app/controllers/environment_admin/manage_tags_controller.rb @@ -0,0 +1,74 @@ +# Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them +class ManageTagsController < ApplicationController + + # Index redirects to list action without modifing the url + def index + redirect_to :action => 'list' + end + + # Lists the tags starting with the top tags or with the chidren of @parent if its provided + def list + @parent = Tag.find(params[:parent]) if params[:parent] + @tags = @parent ? @parent.children : Tag.roots + @pending_tags = Tag.find_all_by_pending(true) + end + + # Prompt for data to a new tag + def new + @parent_tags = Tag.find_all_by_pending(false) + @tag = Tag.new + end + + # Collects the data and creates a new tag with it + def create + @tag = Tag.new(params[:tag]) + if @tag.save + flash[:notice] = _('Tag was successfully created.') + redirect_to :action => 'list' + else + @parent_tags = Tag.find_all_by_pending(false) + render :action => 'new' + end + end + + # Prompt for modifications on the attributes of a tag + def edit + @tag = Tag.find(params[:id]) + @parent_tags = @tag.parent_candidates + end + + # Do the modifications collected by edit + def update + @tag = Tag.find(params[:id]) + if @tag.update_attributes(params[:tag]) + flash[:notice] = _('Tag was successfully updated.') + redirect_to :action => 'list' + else + @parent_tags = @tag.parent_candidates + render :action => 'edit' + end + end + + # Destroy a tag and all its children + def destroy + @tag = Tag.find(params[:id]) + if @tag.destroy + flash[:notice] = _('Tag was successfuly destroyed') + end + redirect_to :action => 'list' + end + + # Approve a pending tag so now ita can be used to tag things + def approve + @tag = Tag.find(params[:id]) + if @tag.update_attribute(:pending, false) + flash[:notice] = _('Tag was successfuly approved') + redirect_to :action => 'list' + end + end + + # Full-text search for tags that have the query terms + def search + @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) + end +end diff --git a/app/controllers/environment_admin/role_controller.rb b/app/controllers/environment_admin/role_controller.rb new file mode 100644 index 0000000..7063e8f --- /dev/null +++ b/app/controllers/environment_admin/role_controller.rb @@ -0,0 +1,47 @@ +class RoleController < ApplicationController + def index + @roles = Role.find(:all) + end + + def show + @role = Role.find(params[:id]) + end + + def new + @role = Role.new(:name => '', :permissions => []) + end + + def create + role = Role.new(params[:role]) + if role.save + redirect_to :action => 'show', :id => role + else + flash[:notice] = _('Failed to create role') + redirect_to :action => 'index' + end + end + + def edit + @role = Role.find(params[:id]) + end + + def update + role = Role.find(params[:id]) + if role.update_attributes(params[:role]) + redirect_to :action => 'show', :id => role + else + flash[:notice] = _('Failed to edit role') + render :action => 'edit' + end + end + + def destroy + role = Role.find(params[:id]) + if role.destroy + redirect_to :action => 'index' + else + flash[:notice] = _('Failed to edit role') + redirect_to :action => 'index' + end + end +end diff --git a/app/controllers/features_controller.rb b/app/controllers/features_controller.rb deleted file mode 100644 index a306824..0000000 --- a/app/controllers/features_controller.rb +++ /dev/null @@ -1,22 +0,0 @@ -class FeaturesController < ApplicationController - - acts_as_virtual_community_admin_controller - - def index - @features = VirtualCommunity.available_features - end - - post_only :update - def update - features = if params[:features].nil? - [] - else - params[:features].keys - end - @virtual_community.enabled_features = features - @virtual_community.save! - flash[:notice] = _('Features updated successfully.') - redirect_to :action => 'index' - end - -end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb deleted file mode 100644 index 9800738..0000000 --- a/app/controllers/home_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class HomeController < ApplicationController - - design :holder => 'virtual_community' - -end diff --git a/app/controllers/manage_tags_controller.rb b/app/controllers/manage_tags_controller.rb deleted file mode 100644 index c5794a4..0000000 --- a/app/controllers/manage_tags_controller.rb +++ /dev/null @@ -1,74 +0,0 @@ -# Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them -class ManageTagsController < ApplicationController - - # Index redirects to list action without modifing the url - def index - redirect_to :action => 'list' - end - - # Lists the tags starting with the top tags or with the chidren of @parent if its provided - def list - @parent = Tag.find(params[:parent]) if params[:parent] - @tags = @parent ? @parent.children : Tag.roots - @pending_tags = Tag.find_all_by_pending(true) - end - - # Prompt for data to a new tag - def new - @parent_tags = Tag.find_all_by_pending(false) - @tag = Tag.new - end - - # Collects the data and creates a new tag with it - def create - @tag = Tag.new(params[:tag]) - if @tag.save - flash[:notice] = _('Tag was successfully created.') - redirect_to :action => 'list' - else - @parent_tags = Tag.find_all_by_pending(false) - render :action => 'new' - end - end - - # Prompt for modifications on the attributes of a tag - def edit - @tag = Tag.find(params[:id]) - @parent_tags = @tag.parent_candidates - end - - # Do the modifications collected by edit - def update - @tag = Tag.find(params[:id]) - if @tag.update_attributes(params[:tag]) - flash[:notice] = _('Tag was successfully updated.') - redirect_to :action => 'list' - else - @parent_tags = @tag.parent_candidates - render :action => 'edit' - end - end - - # Destroy a tag and all its children - def destroy - @tag = Tag.find(params[:id]) - if @tag.destroy - flash[:notice] = _('Tag was successfuly destroyed') - end - redirect_to :action => 'list' - end - - # Approve a pending tag so now ita can be used to tag things - def approve - @tag = Tag.find(params[:id]) - if @tag.update_attribute(:pending, false) - flash[:notice] = _('Tag was successfuly approved') - redirect_to :action => 'list' - end - end - - # Full-text search for tags that have the query terms - def search - @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) - end -end diff --git a/app/controllers/profile_admin/cms_controller.rb b/app/controllers/profile_admin/cms_controller.rb new file mode 100644 index 0000000..94f436f --- /dev/null +++ b/app/controllers/profile_admin/cms_controller.rb @@ -0,0 +1,3 @@ +class CmsController < ComatoseAdminController + define_option :page_class, Article +end diff --git a/app/controllers/profile_admin/enterprise_controller.rb b/app/controllers/profile_admin/enterprise_controller.rb new file mode 100644 index 0000000..7da4fe8 --- /dev/null +++ b/app/controllers/profile_admin/enterprise_controller.rb @@ -0,0 +1,143 @@ +# Manage enterprises by providing an interface to register, activate and manage them +class EnterpriseController < ApplicationController + + before_filter :logon, :my_enterprises + + # Redirects to show if there is only one action and to list otherwise + def index + if @my_enterprises.size == 1 + redirect_to :action => 'show', :id => @my_enterprises[0] + else + redirect_to :action => 'list' + end + end + + # Lists all enterprises + def list + @enterprises = Enterprise.find(:all) - @my_enterprises + end + + # Show details about an enterprise + def show + @enterprise = @my_enterprises.find(params[:id]) + end + + # Make a form to the creation of an eterprise + def register_form + @enterprise = Enterprise.new() + @vitual_communities = VirtualCommunity.find(:all) + @validation_entities = Organization.find(:all) + end + + # Saves the new created enterprise + def register + @enterprise = Enterprise.new(params[:enterprise]) + @enterprise.organization_info = OrganizationInfo.new(params[:organization]) + if @enterprise.save + @enterprise.people << @person + flash[:notice] = _('The enterprise was succesfully created, the validation entity will cotact you as soon as your enterprise is approved') + redirect_to :action => 'index' + else + flash[:notice] = _('Enterprise was not created') + @vitual_communities = VirtualCommunity.find(:all) + @validation_entities = Organization.find(:all) + render :action => 'register_form' + end + end + + # Provides an interface to editing the enterprise details + def edit + @enterprise = @my_enterprises.find(params[:id]) + @validation_entities = Organization.find(:all) - [@enterprise] + end + + # Saves the changes made in an enterprise + def update + @enterprise = @my_enterprises.find(params[:id]) + if @enterprise.update_attributes(params[:enterprise]) && @enterprise.organization_info.update_attributes(params[:organization_info]) + redirect_to :action => 'index' + else + flash[:notice] = _('Could not update the enterprise') + @validation_entities = Organization.find(:all) - [@enterprise] + render :action => 'edit' + end + end + + # Make the current user a new member of the enterprise + def affiliate + @enterprise = Enterprise.find(params[:id]) + @enterprise.people << @person + redirect_to :action => 'index' + end + + # Elimitates the enterprise of the system + def destroy + @enterprise = @my_enterprises.find(params[:id]) + if @enterprise + @enterprise.destroy + else + flash[:notice] = 'Can destroy only your enterprises' + end + redirect_to :action => 'index' + end + + # Search enterprises by name or tags + def search + @tagged_enterprises = Enterprise.search(params[:query]) + end + + # Activate a validated enterprise + def activate + @enterprise = Enterprise.find(params[:id]) + if @enterprise.activate + flash[:notice] = _('Enterprise successfuly activacted') + else + flash[:notice] = _('Failed to activate the enterprise') + end + redirect_to :action => 'index' + end + + # Validates an eterprise + def approve + @enterprise = Enterprise.find(params[:id]) + if @enterprise.approve + flash[:notice] = _('Enterprise successfuly approved') + else + flash[:notice] = _('Failed to approve the enterprise') + end + redirect_to :action => 'index' + end + + # Rejects an enterprise + def reject + @enterprise = Enterprise.find(params[:id]) + if @enterprise.reject + flash[:notice] = _('Enterprise successfuly rejected') + else + flash[:notice] = _('Failed to reject the enterprise') + end + redirect_to :action => 'index' + end + + + protected + + # Make sure that the user is logged before access this controller + def logon + if logged_in? + @user = current_user + @person = @user.person + else + redirect_to :controller => 'account' unless logged_in? + end + end + + # Initializes some variables to contain the enterprises of the current user + def my_enterprises + if logged_in? + @my_active_enterprises = @person.active_enterprises + @my_pending_enterprises = @person.pending_enterprises + @my_enterprises = @person.enterprises + end + end +end diff --git a/app/controllers/profile_admin/profile_editor_controller.rb b/app/controllers/profile_admin/profile_editor_controller.rb new file mode 100644 index 0000000..729a312 --- /dev/null +++ b/app/controllers/profile_admin/profile_editor_controller.rb @@ -0,0 +1,15 @@ +class ProfileEditorController < ApplicationController + helper :profile + + # edits the profile info (posts back) + def edit + if request.post? + profile.info.update_attributes(params[:info]) + redirect_to :action => 'index' + else + @info = profile.info + render :action => @info.class.name.underscore + end + end +end + diff --git a/app/controllers/profile_editor_controller.rb b/app/controllers/profile_editor_controller.rb deleted file mode 100644 index 729a312..0000000 --- a/app/controllers/profile_editor_controller.rb +++ /dev/null @@ -1,15 +0,0 @@ -class ProfileEditorController < ApplicationController - helper :profile - - # edits the profile info (posts back) - def edit - if request.post? - profile.info.update_attributes(params[:info]) - redirect_to :action => 'index' - else - @info = profile.info - render :action => @info.class.name.underscore - end - end -end - diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb new file mode 100644 index 0000000..a20ea3a --- /dev/null +++ b/app/controllers/public/account_controller.rb @@ -0,0 +1,82 @@ +class AccountController < ApplicationController + + # say something nice, you goof! something sweet. + def index + unless logged_in? + render :action => 'index_anonymous' + end + end + + # action to perform login to the application + def login + return unless request.post? + self.current_user = User.authenticate(params[:login], params[:password]) + if logged_in? + if params[:remember_me] == "1" + self.current_user.remember_me + cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } + end + redirect_back_or_default(:controller => '/account', :action => 'index') + flash[:notice] = _("Logged in successfully") + else + flash[:notice] = _('Incorrect username or password') + end + end + + # action to register an user to the application + def signup + begin + @user = User.new(params[:user]) + @user.terms_of_use = virtual_community.terms_of_use + @terms_of_use = virtual_community.terms_of_use + + if request.post? + @user.save! + @user.person.virtual_community = virtual_community + @user.person.save! + self.current_user = @user + redirect_back_or_default(:controller => 'account', :action => 'index') + flash[:notice] = _("Thanks for signing up!") + end + rescue ActiveRecord::RecordInvalid + render :action => 'signup' + end + end + + # action to perform logout from the application + def logout + self.current_user.forget_me if logged_in? + cookies.delete :auth_token + reset_session + flash[:notice] = _("You have been logged out.") + redirect_back_or_default(:controller => '/account', :action => 'index') + end + + def change_password + if request.post? + @user = current_user + begin + @user.change_password!(params[:current_password], + params[:new_password], + params[:new_password_confirmation]) + flash[:notice] = _('Your password has been changed successfully!') + redirect_to :action => 'index' + rescue User::IncorrectPassword => e + flash[:notice] = _('The supplied current password is incorrect.') + render :action => 'change_password' + end + else + render :action => 'change_password' + end + end + + protected + + before_filter :load_profile_for_user + def load_profile_for_user + return unless logged_in? + @profile = current_user.person + end + + +end diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb new file mode 100644 index 0000000..9788aca --- /dev/null +++ b/app/controllers/public/content_viewer_controller.rb @@ -0,0 +1,13 @@ +class ContentViewerController < ApplicationController + + def view_page + path = params[:page].clone + path.unshift(params[:profile]) + @path = path.join('/') + @page = Article.find_by_path(@path) + if @page.nil? + render :action => 'not_found', :status => 404 + end + end + +end diff --git a/app/controllers/public/home_controller.rb b/app/controllers/public/home_controller.rb new file mode 100644 index 0000000..9800738 --- /dev/null +++ b/app/controllers/public/home_controller.rb @@ -0,0 +1,5 @@ +class HomeController < ApplicationController + + design :holder => 'virtual_community' + +end diff --git a/app/controllers/role_controller.rb b/app/controllers/role_controller.rb deleted file mode 100644 index 7063e8f..0000000 --- a/app/controllers/role_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -class RoleController < ApplicationController - def index - @roles = Role.find(:all) - end - - def show - @role = Role.find(params[:id]) - end - - def new - @role = Role.new(:name => '', :permissions => []) - end - - def create - role = Role.new(params[:role]) - if role.save - redirect_to :action => 'show', :id => role - else - flash[:notice] = _('Failed to create role') - redirect_to :action => 'index' - end - end - - def edit - @role = Role.find(params[:id]) - end - - def update - role = Role.find(params[:id]) - if role.update_attributes(params[:role]) - redirect_to :action => 'show', :id => role - else - flash[:notice] = _('Failed to edit role') - render :action => 'edit' - end - end - - def destroy - role = Role.find(params[:id]) - if role.destroy - redirect_to :action => 'index' - else - flash[:notice] = _('Failed to edit role') - redirect_to :action => 'index' - end - end -end diff --git a/config/environment.rb b/config/environment.rb index 79b3a2f..2cca8b6 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -10,6 +10,14 @@ RAILS_GEM_VERSION = '1.1.6' # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') +# extra directories for controllers organization +extra_controller_dirs = %w[ + app/controllers/profile_admin + app/controllers/environment_admin + app/controllers/system_admin + app/controllers/public +].map {|item| File.join(RAILS_ROOT, item) } + Rails::Initializer.run do |config| # Settings in config/environments/* take precedence those specified here @@ -34,11 +42,18 @@ Rails::Initializer.run do |config| # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector - # Make Active Record use UTC-base instead of local time # config.active_record.default_timezone = :utc # See Rails::Configuration for more options + + extra_controller_dirs.each do |item| + $LOAD_PATH << item + config.controller_paths << item + end +end +extra_controller_dirs.each do |item| + Dependencies.load_paths << item end # Add new inflection rules using the following format -- libgit2 0.21.2