aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/admin_public_body_headings_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/admin_public_body_headings_controller.rb')
-rw-r--r--app/controllers/admin_public_body_headings_controller.rb63
1 files changed, 33 insertions, 30 deletions
diff --git a/app/controllers/admin_public_body_headings_controller.rb b/app/controllers/admin_public_body_headings_controller.rb
index e893e760d..a7fe27390 100644
--- a/app/controllers/admin_public_body_headings_controller.rb
+++ b/app/controllers/admin_public_body_headings_controller.rb
@@ -1,22 +1,52 @@
class AdminPublicBodyHeadingsController < AdminController
+ def new
+ @heading = PublicBodyHeading.new
+ @heading.build_all_translations
+ end
+
+ def create
+ I18n.with_locale(I18n.default_locale) do
+ @heading = PublicBodyHeading.new(params[:public_body_heading])
+ if @heading.save
+ flash[:notice] = 'Heading was successfully created.'
+ redirect_to admin_categories_url
+ else
+ @heading.build_all_translations
+ render :action => 'new'
+ end
+ end
+ end
+
def edit
@heading = PublicBodyHeading.find(params[:id])
- render :formats => [:html]
+ @heading.build_all_translations
end
def update
+ @heading = PublicBodyHeading.find(params[:id])
+
I18n.with_locale(I18n.default_locale) do
- @heading = PublicBodyHeading.find(params[:id])
if @heading.update_attributes(params[:public_body_heading])
- flash[:notice] = 'Category heading was successfully updated.'
+ flash[:notice] = 'Heading was successfully updated.'
redirect_to edit_admin_heading_path(@heading)
else
+ @heading.build_all_translations
render :action => 'edit'
end
end
end
+ def destroy
+ @locale = self.locale_from_params
+ I18n.with_locale(@locale) do
+ heading = PublicBodyHeading.find(params[:id])
+ heading.destroy
+ flash[:notice] = "Heading was successfully destroyed."
+ redirect_to admin_categories_url
+ end
+ end
+
def reorder
transaction = reorder_headings(params[:headings])
if transaction[:success]
@@ -35,33 +65,6 @@ class AdminPublicBodyHeadingsController < AdminController
end
end
- def new
- @heading = PublicBodyHeading.new
- render :formats => [:html]
- end
-
- def create
- I18n.with_locale(I18n.default_locale) do
- @heading = PublicBodyHeading.new(params[:public_body_heading])
- if @heading.save
- flash[:notice] = 'Category heading was successfully created.'
- redirect_to admin_categories_url
- else
- render :action => 'new'
- end
- end
- end
-
- def destroy
- @locale = self.locale_from_params()
- I18n.with_locale(@locale) do
- heading = PublicBodyHeading.find(params[:id])
- heading.destroy
- flash[:notice] = "Category heading was successfully destroyed."
- redirect_to admin_categories_url
- end
- end
-
protected
def reorder_headings(headings)