You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

groups_controller.rb 3.8 kB

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

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...