blob: 39a406e4d79c62e39e4dab9ac2ea0bf7612e66ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# app/controllers/admin_public_body_controller.rb:
# Controller for editing public bodies from the admin interface.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
# $Id: admin_public_body_controller.rb,v 1.9 2008-03-14 10:09:55 francis Exp $
class AdminPublicBodyController < ApplicationController
layout "admin"
def index
list
render :action => 'list'
end
def list
@query = params[:query]
@public_bodies = PublicBody.paginate :order => "name", :page => params[:page], :per_page => 100,
:conditions => @query.nil? ? nil : ["name ilike '%'||?||'%' or
short_name ilike '%'||?||'%' or
request_email ilike '%'||?||'%'", @query, @query, @query]
end
def show
@public_body = PublicBody.find(params[:id])
end
def new
@public_body = PublicBody.new
end
def create
params[:public_body][:last_edit_editor] = admin_http_auth_user()
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
flash[:notice] = 'PublicBody was successfully created.'
redirect_to admin_url('body/list')
else
render :action => 'new'
end
end
def edit
@public_body = PublicBody.find(params[:id])
@public_body.last_edit_comment = ""
end
def update
params[:public_body][:last_edit_editor] = admin_http_auth_user()
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
flash[:notice] = 'PublicBody was successfully updated.'
redirect_to admin_url('body/show/' + @public_body.id.to_s)
else
render :action => 'edit'
end
end
def destroy
public_body = PublicBody.find(params[:id])
public_body.tag_string = ""
public_body.destroy
flash[:notice] = "PublicBody was successfully destroyed."
redirect_to admin_url('body/list')
end
private
end
|