Class: GroupsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- GroupsController
- Defined in:
- app/controllers/groups_controller.rb
Overview
Redmine - project management software Copyright (C) 2006-2009 Jean-Philippe Lang
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Instance Method Summary
- - (Object) add_users
- - (Object) autocomplete_for_user
-
- (Object) create
POST /groups POST /groups.xml.
-
- (Object) destroy
DELETE /groups/1 DELETE /groups/1.xml.
- - (Object) destroy_membership
-
- (Object) edit
GET /groups/1/edit.
- - (Object) edit_membership
-
- (Object) index
GET /groups GET /groups.xml.
-
- (Object) new
GET /groups/new GET /groups/new.xml.
- - (Object) remove_user
-
- (Object) show
GET /groups/1 GET /groups/1.xml.
-
- (Object) update
PUT /groups/1 PUT /groups/1.xml.
Methods inherited from ApplicationController
accept_key_auth, #accept_key_auth_actions, #api_request?, #authorize, #authorize_global, #check_if_login_required, #check_project_privacy, #delete_broken_cookies, #deny_access, #filename_for_content_disposition, #find_current_user, #find_model_object, #find_project, #find_project_from_association, #invalid_authenticity_token, #logged_user=, model_object, #parse_qvalues, #per_page_option, #redirect_back_or_default, #render_403, #render_404, #render_attachment_warning_if_needed, #render_error, #render_feed, #require_admin, #require_login, #set_localization, #user_setup
Methods included from Redmine::I18n
#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages
Methods included from Redmine::Search::Controller
#default_search_scope, #default_search_scopes, included
Methods included from Redmine::MenuManager::MenuController
#current_menu_item, included, #menu_items, #redirect_to_project_menu_item
Instance Method Details
- (Object) add_users
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'app/controllers/groups_controller.rb', line 109 def add_users @group = Group.find(params[:id]) users = User.find_all_by_id(params[:user_ids]) @group.users << users if request.post? respond_to do |format| format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users' users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") } } } end end |
- (Object) autocomplete_for_user
133 134 135 136 137 |
# File 'app/controllers/groups_controller.rb', line 133 def autocomplete_for_user @group = Group.find(params[:id]) @users = User.active.like(params[:q]).find(:all, :limit => 100) - @group.users render :layout => false end |
- (Object) create
POST /groups POST /groups.xml
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/groups_controller.rb', line 65 def create @group = Group.new(params[:group]) respond_to do |format| if @group.save flash[:notice] = l(:notice_successful_create) format.html { redirect_to(groups_path) } format.xml { render :xml => @group, :status => :created, :location => @group } else format.html { render :action => "new" } format.xml { render :xml => @group.errors, :status => :unprocessable_entity } end end end |
- (Object) destroy
DELETE /groups/1 DELETE /groups/1.xml
99 100 101 102 103 104 105 106 107 |
# File 'app/controllers/groups_controller.rb', line 99 def destroy @group = Group.find(params[:id]) @group.destroy respond_to do |format| format.html { redirect_to(groups_url) } format.xml { head :ok } end end |
- (Object) destroy_membership
154 155 156 157 158 159 160 161 |
# File 'app/controllers/groups_controller.rb', line 154 def destroy_membership @group = Group.find(params[:id]) Member.find(params[:membership_id]).destroy if request.post? respond_to do |format| format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' } format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'groups/memberships'} } end end |
- (Object) edit
GET /groups/1/edit
59 60 61 |
# File 'app/controllers/groups_controller.rb', line 59 def edit @group = Group.find(params[:id]) end |
- (Object) edit_membership
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'app/controllers/groups_controller.rb', line 139 def edit_membership @group = Group.find(params[:id]) @membership = Member.edit_membership(params[:membership_id], params[:membership], @group) @membership.save if request.post? respond_to do |format| format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'memberships' } format.js { render(:update) {|page| page.replace_html "tab-content-memberships", :partial => 'groups/memberships' page.visual_effect(:highlight, "member-#{@membership.id}") } } end end |
- (Object) index
GET /groups GET /groups.xml
27 28 29 30 31 32 33 34 |
# File 'app/controllers/groups_controller.rb', line 27 def index @groups = Group.find(:all, :order => 'lastname') respond_to do |format| format.html # index.html.erb format.xml { render :xml => @groups } end end |
- (Object) new
GET /groups/new GET /groups/new.xml
49 50 51 52 53 54 55 56 |
# File 'app/controllers/groups_controller.rb', line 49 def new @group = Group.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @group } end end |
- (Object) remove_user
124 125 126 127 128 129 130 131 |
# File 'app/controllers/groups_controller.rb', line 124 def remove_user @group = Group.find(params[:id]) @group.users.delete(User.find(params[:user_id])) if request.post? respond_to do |format| format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} } end end |
- (Object) show
GET /groups/1 GET /groups/1.xml
38 39 40 41 42 43 44 45 |
# File 'app/controllers/groups_controller.rb', line 38 def show @group = Group.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @group } end end |
- (Object) update
PUT /groups/1 PUT /groups/1.xml
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/controllers/groups_controller.rb', line 82 def update @group = Group.find(params[:id]) respond_to do |format| if @group.update_attributes(params[:group]) flash[:notice] = l(:notice_successful_update) format.html { redirect_to(groups_path) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @group.errors, :status => :unprocessable_entity } end end end |