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