##// END OF EJS Templates
Removed auto-generated comments....
Jean-Philippe Lang -
r9564:d58e5a0a1e9e
parent child
Show More
@@ -1,174 +1,161
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class GroupsController < ApplicationController
19 19 layout 'admin'
20 20
21 21 before_filter :require_admin
22 22
23 23 helper :custom_fields
24 24
25 # GET /groups
26 # GET /groups.xml
27 25 def index
28 26 @groups = Group.find(:all, :order => 'lastname')
29 27
30 28 respond_to do |format|
31 format.html # index.html.erb
29 format.html
32 30 format.xml { render :xml => @groups }
33 31 end
34 32 end
35 33
36 # GET /groups/1
37 # GET /groups/1.xml
38 34 def show
39 35 @group = Group.find(params[:id])
40 36
41 37 respond_to do |format|
42 format.html # show.html.erb
38 format.html
43 39 format.xml { render :xml => @group }
44 40 end
45 41 end
46 42
47 # GET /groups/new
48 # GET /groups/new.xml
49 43 def new
50 44 @group = Group.new
51 45
52 46 respond_to do |format|
53 format.html # new.html.erb
47 format.html
54 48 format.xml { render :xml => @group }
55 49 end
56 50 end
57 51
58 # GET /groups/1/edit
59 def edit
60 @group = Group.find(params[:id], :include => :projects)
61 end
62
63 # POST /groups
64 # POST /groups.xml
65 52 def create
66 53 @group = Group.new
67 54 @group.safe_attributes = params[:group]
68 55
69 56 respond_to do |format|
70 57 if @group.save
71 58 format.html {
72 59 flash[:notice] = l(:notice_successful_create)
73 60 redirect_to(params[:continue] ? new_group_path : groups_path)
74 61 }
75 62 format.xml { render :xml => @group, :status => :created, :location => @group }
76 63 else
77 64 format.html { render :action => "new" }
78 65 format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
79 66 end
80 67 end
81 68 end
82 69
83 # PUT /groups/1
84 # PUT /groups/1.xml
70 def edit
71 @group = Group.find(params[:id], :include => :projects)
72 end
73
85 74 def update
86 75 @group = Group.find(params[:id])
87 76 @group.safe_attributes = params[:group]
88 77
89 78 respond_to do |format|
90 79 if @group.save
91 80 flash[:notice] = l(:notice_successful_update)
92 81 format.html { redirect_to(groups_path) }
93 82 format.xml { head :ok }
94 83 else
95 84 format.html { render :action => "edit" }
96 85 format.xml { render :xml => @group.errors, :status => :unprocessable_entity }
97 86 end
98 87 end
99 88 end
100 89
101 # DELETE /groups/1
102 # DELETE /groups/1.xml
103 90 def destroy
104 91 @group = Group.find(params[:id])
105 92 @group.destroy
106 93
107 94 respond_to do |format|
108 95 format.html { redirect_to(groups_url) }
109 96 format.xml { head :ok }
110 97 end
111 98 end
112 99
113 100 def add_users
114 101 @group = Group.find(params[:id])
115 102 users = User.find_all_by_id(params[:user_ids])
116 103 @group.users << users if request.post?
117 104 respond_to do |format|
118 105 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
119 106 format.js {
120 107 render(:update) {|page|
121 108 page.replace_html "tab-content-users", :partial => 'groups/users'
122 109 users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") }
123 110 }
124 111 }
125 112 end
126 113 end
127 114
128 115 def remove_user
129 116 @group = Group.find(params[:id])
130 117 @group.users.delete(User.find(params[:user_id])) if request.delete?
131 118 respond_to do |format|
132 119 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
133 120 format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} }
134 121 end
135 122 end
136 123
137 124 def autocomplete_for_user
138 125 @group = Group.find(params[:id])
139 126 @users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
140 127 render :layout => false
141 128 end
142 129
143 130 def edit_membership
144 131 @group = Group.find(params[:id])
145 132 @membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
146 133 @membership.save if request.post?
147 134 respond_to do |format|
148 135 if @membership.valid?
149 136 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
150 137 format.js {
151 138 render(:update) {|page|
152 139 page.replace_html "tab-content-memberships", :partial => 'groups/memberships'
153 140 page.visual_effect(:highlight, "member-#{@membership.id}")
154 141 }
155 142 }
156 143 else
157 144 format.js {
158 145 render(:update) {|page|
159 146 page.alert(l(:notice_failed_to_save_members, :errors => @membership.errors.full_messages.join(', ')))
160 147 }
161 148 }
162 149 end
163 150 end
164 151 end
165 152
166 153 def destroy_membership
167 154 @group = Group.find(params[:id])
168 155 Member.find(params[:membership_id]).destroy if request.post?
169 156 respond_to do |format|
170 157 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' }
171 158 format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'groups/memberships'} }
172 159 end
173 160 end
174 161 end
General Comments 0
You need to be logged in to leave comments. Login now