annotate .svn/pristine/58/58b49876d90ca4f57b376fabd8862c7bd7f14741.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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