aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_public_body_categories_controller.rb (renamed from app/controllers/admin_public_body_category_controller.rb)28
-rw-r--r--app/controllers/admin_public_body_headings_controller.rb (renamed from app/controllers/admin_public_body_heading_controller.rb)30
2 files changed, 29 insertions, 29 deletions
diff --git a/app/controllers/admin_public_body_category_controller.rb b/app/controllers/admin_public_body_categories_controller.rb
index 99a4a7f3c..e9ca57434 100644
--- a/app/controllers/admin_public_body_category_controller.rb
+++ b/app/controllers/admin_public_body_categories_controller.rb
@@ -1,4 +1,4 @@
-class AdminPublicBodyCategoryController < AdminController
+class AdminPublicBodyCategoriesController < AdminController
def index
@locale = self.locale_from_params
@category_headings = PublicBodyHeading.all
@@ -55,28 +55,6 @@ class AdminPublicBodyCategoryController < AdminController
end
end
- def reorder
- error = nil
- ActiveRecord::Base.transaction do
- params[:categories].each_with_index do |category_id, index|
- conditions = { :public_body_category_id => category_id,
- :public_body_heading_id => params[:heading_id] }
- link = PublicBodyCategoryLink.where(conditions).first
- unless link
- error = "Couldn't find PublicBodyCategoryLink for category #{category_id}, heading #{params[:heading_id]}"
- raise ActiveRecord::Rollback
- end
- link.category_display_order = index
- unless link.save
- error = link.errors.full_messages.join(",")
- raise ActiveRecord::Rollback
- end
- end
- render :nothing => true, :status => :ok and return
- end
- render :text => error, :status => :unprocessable_entity
- end
-
def create
I18n.with_locale(I18n.default_locale) do
@category = PublicBodyCategory.new(params[:public_body_category])
@@ -87,7 +65,7 @@ class AdminPublicBodyCategoryController < AdminController
end
end
flash[:notice] = 'Category was successfully created.'
- redirect_to admin_category_index_url
+ redirect_to categories_path
else
render :action => 'new'
end
@@ -100,7 +78,7 @@ class AdminPublicBodyCategoryController < AdminController
category = PublicBodyCategory.find(params[:id])
category.destroy
flash[:notice] = "Category was successfully destroyed."
- redirect_to admin_category_index_url
+ redirect_to categories_path
end
end
end
diff --git a/app/controllers/admin_public_body_heading_controller.rb b/app/controllers/admin_public_body_headings_controller.rb
index 0fba350cc..6eec4b65e 100644
--- a/app/controllers/admin_public_body_heading_controller.rb
+++ b/app/controllers/admin_public_body_headings_controller.rb
@@ -1,4 +1,4 @@
-class AdminPublicBodyHeadingController < AdminController
+class AdminPublicBodyHeadingsController < AdminController
def edit
@heading = PublicBodyHeading.find(params[:id])
@@ -36,6 +36,28 @@ class AdminPublicBodyHeadingController < AdminController
render :text => error, :status => :unprocessable_entity
end
+ def reorder_categories
+ error = nil
+ ActiveRecord::Base.transaction do
+ params[:categories].each_with_index do |category_id, index|
+ conditions = { :public_body_category_id => category_id,
+ :public_body_heading_id => params[:id] }
+ link = PublicBodyCategoryLink.where(conditions).first
+ unless link
+ error = "Couldn't find PublicBodyCategoryLink for category #{category_id}, heading #{params[:id]}"
+ raise ActiveRecord::Rollback
+ end
+ link.category_display_order = index
+ unless link.save
+ error = link.errors.full_messages.join(",")
+ raise ActiveRecord::Rollback
+ end
+ end
+ render :nothing => true, :status => :ok and return
+ end
+ render :text => error, :status => :unprocessable_entity
+ end
+
def new
@heading = PublicBodyHeading.new
render :formats => [:html]
@@ -46,7 +68,7 @@ class AdminPublicBodyHeadingController < AdminController
@heading = PublicBodyHeading.new(params[:public_body_heading])
if @heading.save
flash[:notice] = 'Category heading was successfully created.'
- redirect_to admin_category_index_url
+ redirect_to categories_url
else
render :action => 'new'
end
@@ -60,13 +82,13 @@ class AdminPublicBodyHeadingController < AdminController
if heading.public_body_categories.count > 0
flash[:notice] = "There are categories associated with this heading, so can't destroy it"
- redirect_to admin_heading_edit_url(heading)
+ redirect_to edit_heading_url(heading)
return
end
heading.destroy
flash[:notice] = "Category heading was successfully destroyed."
- redirect_to admin_category_index_url
+ redirect_to categories_url
end
end
end