1 # Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
3 # This file is part of ECS.
5 # ECS is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Affero General Public License as
7 # published by the Free Software Foundation, either version 3 of
8 # the License, or (at your option) any later version.
10 # ECS is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public
16 # License along with ECS. If not, see <http://www.gnu.org/licenses/>.
19 class Admin::OrganizationsController < ApplicationController
23 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
24 verify :method => [ :post, :put, :delete ], :only => [ :destroy, :create, :update ],
25 :add_flash => { :notice => "Failed to execute last action" },
26 :redirect_to => :admin_organization_path
30 render :action => 'list'
34 @organizations=Organization.find(:all).uniq
38 @organization = Organization.find(params[:id])
42 @organization = Organization.new
46 @organization = Organization.new(params[:organization])
48 flash[:notice] = 'Organization was successfully created.'
49 redirect_to :action => 'index'
51 render :action => 'new'
56 @organization = Organization.find(params[:id])
60 @organization = Organization.find(params[:id])
61 if @organization.update_attributes(params[:organization])
62 flash[:notice] = 'Organization was successfully updated.'
63 redirect_to :action => 'index'
65 render :action => 'edit'
70 Organization.find(params[:id]).destroy
71 redirect_to :action => 'index'