annotate .svn/pristine/15/15507fe94b5bb5521b6c8407d27c46737c998477.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents dffacf8a6908
children
rev   line source
Chris@1517 1 # Redmine - project management software
Chris@1517 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1517 3 #
Chris@1517 4 # This program is free software; you can redistribute it and/or
Chris@1517 5 # modify it under the terms of the GNU General Public License
Chris@1517 6 # as published by the Free Software Foundation; either version 2
Chris@1517 7 # of the License, or (at your option) any later version.
Chris@1517 8 #
Chris@1517 9 # This program is distributed in the hope that it will be useful,
Chris@1517 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1517 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1517 12 # GNU General Public License for more details.
Chris@1517 13 #
Chris@1517 14 # You should have received a copy of the GNU General Public License
Chris@1517 15 # along with this program; if not, write to the Free Software
Chris@1517 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1517 17
Chris@1517 18 class GroupsController < ApplicationController
Chris@1517 19 layout 'admin'
Chris@1517 20
Chris@1517 21 before_filter :require_admin
Chris@1517 22 before_filter :find_group, :except => [:index, :new, :create]
Chris@1517 23 accept_api_auth :index, :show, :create, :update, :destroy, :add_users, :remove_user
Chris@1517 24
Chris@1517 25 helper :custom_fields
Chris@1517 26
Chris@1517 27 def index
Chris@1517 28 @groups = Group.sorted.all
Chris@1517 29
Chris@1517 30 respond_to do |format|
Chris@1517 31 format.html
Chris@1517 32 format.api
Chris@1517 33 end
Chris@1517 34 end
Chris@1517 35
Chris@1517 36 def show
Chris@1517 37 respond_to do |format|
Chris@1517 38 format.html
Chris@1517 39 format.api
Chris@1517 40 end
Chris@1517 41 end
Chris@1517 42
Chris@1517 43 def new
Chris@1517 44 @group = Group.new
Chris@1517 45 end
Chris@1517 46
Chris@1517 47 def create
Chris@1517 48 @group = Group.new
Chris@1517 49 @group.safe_attributes = params[:group]
Chris@1517 50
Chris@1517 51 respond_to do |format|
Chris@1517 52 if @group.save
Chris@1517 53 format.html {
Chris@1517 54 flash[:notice] = l(:notice_successful_create)
Chris@1517 55 redirect_to(params[:continue] ? new_group_path : groups_path)
Chris@1517 56 }
Chris@1517 57 format.api { render :action => 'show', :status => :created, :location => group_url(@group) }
Chris@1517 58 else
Chris@1517 59 format.html { render :action => "new" }
Chris@1517 60 format.api { render_validation_errors(@group) }
Chris@1517 61 end
Chris@1517 62 end
Chris@1517 63 end
Chris@1517 64
Chris@1517 65 def edit
Chris@1517 66 end
Chris@1517 67
Chris@1517 68 def update
Chris@1517 69 @group.safe_attributes = params[:group]
Chris@1517 70
Chris@1517 71 respond_to do |format|
Chris@1517 72 if @group.save
Chris@1517 73 flash[:notice] = l(:notice_successful_update)
Chris@1517 74 format.html { redirect_to(groups_path) }
Chris@1517 75 format.api { render_api_ok }
Chris@1517 76 else
Chris@1517 77 format.html { render :action => "edit" }
Chris@1517 78 format.api { render_validation_errors(@group) }
Chris@1517 79 end
Chris@1517 80 end
Chris@1517 81 end
Chris@1517 82
Chris@1517 83 def destroy
Chris@1517 84 @group.destroy
Chris@1517 85
Chris@1517 86 respond_to do |format|
Chris@1517 87 format.html { redirect_to(groups_path) }
Chris@1517 88 format.api { render_api_ok }
Chris@1517 89 end
Chris@1517 90 end
Chris@1517 91
Chris@1517 92 def add_users
Chris@1517 93 @users = User.where(:id => (params[:user_id] || params[:user_ids])).all
Chris@1517 94 @group.users << @users if request.post?
Chris@1517 95 respond_to do |format|
Chris@1517 96 format.html { redirect_to edit_group_path(@group, :tab => 'users') }
Chris@1517 97 format.js
Chris@1517 98 format.api { render_api_ok }
Chris@1517 99 end
Chris@1517 100 end
Chris@1517 101
Chris@1517 102 def remove_user
Chris@1517 103 @group.users.delete(User.find(params[:user_id])) if request.delete?
Chris@1517 104 respond_to do |format|
Chris@1517 105 format.html { redirect_to edit_group_path(@group, :tab => 'users') }
Chris@1517 106 format.js
Chris@1517 107 format.api { render_api_ok }
Chris@1517 108 end
Chris@1517 109 end
Chris@1517 110
Chris@1517 111 def autocomplete_for_user
Chris@1517 112 respond_to do |format|
Chris@1517 113 format.js
Chris@1517 114 end
Chris@1517 115 end
Chris@1517 116
Chris@1517 117 def edit_membership
Chris@1517 118 @membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
Chris@1517 119 @membership.save if request.post?
Chris@1517 120 respond_to do |format|
Chris@1517 121 format.html { redirect_to edit_group_path(@group, :tab => 'memberships') }
Chris@1517 122 format.js
Chris@1517 123 end
Chris@1517 124 end
Chris@1517 125
Chris@1517 126 def destroy_membership
Chris@1517 127 Member.find(params[:membership_id]).destroy if request.post?
Chris@1517 128 respond_to do |format|
Chris@1517 129 format.html { redirect_to edit_group_path(@group, :tab => 'memberships') }
Chris@1517 130 format.js
Chris@1517 131 end
Chris@1517 132 end
Chris@1517 133
Chris@1517 134 private
Chris@1517 135
Chris@1517 136 def find_group
Chris@1517 137 @group = Group.find(params[:id])
Chris@1517 138 rescue ActiveRecord::RecordNotFound
Chris@1517 139 render_404
Chris@1517 140 end
Chris@1517 141 end