Mercurial > hg > soundsoftware-site
comparison app/controllers/groups_controller.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | cbce1fd3b1b7 |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2009 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 class GroupsController < ApplicationController | 18 class GroupsController < ApplicationController |
19 layout 'admin' | 19 layout 'admin' |
20 | 20 |
21 before_filter :require_admin | 21 before_filter :require_admin |
22 | 22 |
23 helper :custom_fields | 23 helper :custom_fields |
24 | 24 |
25 # GET /groups | 25 # GET /groups |
26 # GET /groups.xml | 26 # GET /groups.xml |
27 def index | 27 def index |
28 @groups = Group.find(:all, :order => 'lastname') | 28 @groups = Group.find(:all, :order => 'lastname') |
29 | 29 |
46 | 46 |
47 # GET /groups/new | 47 # GET /groups/new |
48 # GET /groups/new.xml | 48 # GET /groups/new.xml |
49 def new | 49 def new |
50 @group = Group.new | 50 @group = Group.new |
51 | 51 |
52 respond_to do |format| | 52 respond_to do |format| |
53 format.html # new.html.erb | 53 format.html # new.html.erb |
54 format.xml { render :xml => @group } | 54 format.xml { render :xml => @group } |
55 end | 55 end |
56 end | 56 end |
65 def create | 65 def create |
66 @group = Group.new(params[:group]) | 66 @group = Group.new(params[:group]) |
67 | 67 |
68 respond_to do |format| | 68 respond_to do |format| |
69 if @group.save | 69 if @group.save |
70 flash[:notice] = l(:notice_successful_create) | 70 format.html { |
71 format.html { redirect_to(groups_path) } | 71 flash[:notice] = l(:notice_successful_create) |
72 redirect_to(params[:continue] ? new_group_path : groups_path) | |
73 } | |
72 format.xml { render :xml => @group, :status => :created, :location => @group } | 74 format.xml { render :xml => @group, :status => :created, :location => @group } |
73 else | 75 else |
74 format.html { render :action => "new" } | 76 format.html { render :action => "new" } |
75 format.xml { render :xml => @group.errors, :status => :unprocessable_entity } | 77 format.xml { render :xml => @group.errors, :status => :unprocessable_entity } |
76 end | 78 end |
103 respond_to do |format| | 105 respond_to do |format| |
104 format.html { redirect_to(groups_url) } | 106 format.html { redirect_to(groups_url) } |
105 format.xml { head :ok } | 107 format.xml { head :ok } |
106 end | 108 end |
107 end | 109 end |
108 | 110 |
109 def add_users | 111 def add_users |
110 @group = Group.find(params[:id]) | 112 @group = Group.find(params[:id]) |
111 users = User.find_all_by_id(params[:user_ids]) | 113 users = User.find_all_by_id(params[:user_ids]) |
112 @group.users << users if request.post? | 114 @group.users << users if request.post? |
113 respond_to do |format| | 115 respond_to do |format| |
114 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } | 116 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } |
115 format.js { | 117 format.js { |
116 render(:update) {|page| | 118 render(:update) {|page| |
117 page.replace_html "tab-content-users", :partial => 'groups/users' | 119 page.replace_html "tab-content-users", :partial => 'groups/users' |
118 users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") } | 120 users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") } |
119 } | 121 } |
120 } | 122 } |
121 end | 123 end |
122 end | 124 end |
123 | 125 |
124 def remove_user | 126 def remove_user |
125 @group = Group.find(params[:id]) | 127 @group = Group.find(params[:id]) |
126 @group.users.delete(User.find(params[:user_id])) if request.post? | 128 @group.users.delete(User.find(params[:user_id])) if request.delete? |
127 respond_to do |format| | 129 respond_to do |format| |
128 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } | 130 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } |
129 format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} } | 131 format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} } |
130 end | 132 end |
131 end | 133 end |
132 | 134 |
133 def autocomplete_for_user | 135 def autocomplete_for_user |
134 @group = Group.find(params[:id]) | 136 @group = Group.find(params[:id]) |
135 @users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100) | 137 @users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100) |
136 render :layout => false | 138 render :layout => false |
137 end | 139 end |
138 | 140 |
139 def edit_membership | 141 def edit_membership |
140 @group = Group.find(params[:id]) | 142 @group = Group.find(params[:id]) |
141 @membership = Member.edit_membership(params[:membership_id], params[:membership], @group) | 143 @membership = Member.edit_membership(params[:membership_id], params[:membership], @group) |
142 @membership.save if request.post? | 144 @membership.save if request.post? |
143 respond_to do |format| | 145 respond_to do |format| |
156 } | 158 } |
157 } | 159 } |
158 end | 160 end |
159 end | 161 end |
160 end | 162 end |
161 | 163 |
162 def destroy_membership | 164 def destroy_membership |
163 @group = Group.find(params[:id]) | 165 @group = Group.find(params[:id]) |
164 Member.find(params[:membership_id]).destroy if request.post? | 166 Member.find(params[:membership_id]).destroy if request.post? |
165 respond_to do |format| | 167 respond_to do |format| |
166 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' } | 168 format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' } |