annotate app/controllers/members_controller.rb @ 45:65d9e2cabaa3 luisf

Added tipoftheday to the config/settings in order to correct previous issues. Tip of the day is now working correctly. Added the heading strings to the locales files.
author luisf
date Tue, 23 Nov 2010 11:50:01 +0000
parents 513646585e45
children 32b5adec7422 cbb26bc654de
rev   line source
Chris@0 1 # redMine - project management software
Chris@0 2 # Copyright (C) 2006 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@0 18 class MembersController < ApplicationController
Chris@0 19 model_object Member
Chris@0 20 before_filter :find_model_object, :except => [:new, :autocomplete_for_member]
Chris@0 21 before_filter :find_project_from_association, :except => [:new, :autocomplete_for_member]
Chris@0 22 before_filter :find_project, :only => [:new, :autocomplete_for_member]
Chris@0 23 before_filter :authorize
Chris@0 24
Chris@0 25 def new
Chris@0 26 members = []
Chris@0 27 if params[:member] && request.post?
Chris@0 28 attrs = params[:member].dup
Chris@0 29 if (user_ids = attrs.delete(:user_ids))
Chris@0 30 user_ids.each do |user_id|
Chris@0 31 members << Member.new(attrs.merge(:user_id => user_id))
Chris@0 32 end
Chris@0 33 else
Chris@0 34 members << Member.new(attrs)
Chris@0 35 end
Chris@0 36 @project.members << members
Chris@0 37 end
Chris@0 38 respond_to do |format|
Chris@0 39 if members.present? && members.all? {|m| m.valid? }
Chris@0 40
Chris@0 41 format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
Chris@0 42
Chris@0 43 format.js {
Chris@0 44 render(:update) {|page|
Chris@0 45 page.replace_html "tab-content-members", :partial => 'projects/settings/members'
Chris@0 46 page << 'hideOnLoad()'
Chris@0 47 members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") }
Chris@0 48 }
Chris@0 49 }
Chris@0 50 else
Chris@0 51
Chris@0 52 format.js {
Chris@0 53 render(:update) {|page|
Chris@0 54 errors = members.collect {|m|
Chris@0 55 m.errors.full_messages
Chris@0 56 }.flatten.uniq
Chris@0 57
Chris@0 58 page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', ')))
Chris@0 59 }
Chris@0 60 }
Chris@0 61
Chris@0 62 end
Chris@0 63 end
Chris@0 64 end
Chris@0 65
Chris@0 66 def edit
Chris@0 67 if request.post? and @member.update_attributes(params[:member])
Chris@0 68 respond_to do |format|
Chris@0 69 format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
Chris@0 70 format.js {
Chris@0 71 render(:update) {|page|
Chris@0 72 page.replace_html "tab-content-members", :partial => 'projects/settings/members'
Chris@0 73 page << 'hideOnLoad()'
Chris@0 74 page.visual_effect(:highlight, "member-#{@member.id}")
Chris@0 75 }
Chris@0 76 }
Chris@0 77 end
Chris@0 78 end
Chris@0 79 end
Chris@0 80
Chris@0 81 def destroy
Chris@0 82 if request.post? && @member.deletable?
Chris@0 83 @member.destroy
Chris@0 84 end
Chris@0 85 respond_to do |format|
Chris@0 86 format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
Chris@0 87 format.js { render(:update) {|page|
Chris@0 88 page.replace_html "tab-content-members", :partial => 'projects/settings/members'
Chris@0 89 page << 'hideOnLoad()'
Chris@0 90 }
Chris@0 91 }
Chris@0 92 end
Chris@0 93 end
Chris@0 94
Chris@0 95 def autocomplete_for_member
Chris@0 96 @principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals
Chris@0 97 render :layout => false
Chris@0 98 end
Chris@0 99
Chris@0 100 end