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.

custom_fields_controller.rb 2.5 kB

13 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 CustomFieldsController < ApplicationController
  18. layout 'admin'
  19. before_filter :require_admin
  20. before_filter :build_new_custom_field, :only => [:new, :create]
  21. before_filter :find_custom_field, :only => [:edit, :update, :destroy]
  22. def index
  23. @custom_fields_by_type = CustomField.all.group_by {|f| f.class.name }
  24. @tab = params[:tab] || 'IssueCustomField'
  25. end
  26. def new
  27. end
  28. def create
  29. if @custom_field.save
  30. flash[:notice] = l(:notice_successful_create)
  31. call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
  32. redirect_to custom_fields_path(:tab => @custom_field.class.name)
  33. else
  34. render :action => 'new'
  35. end
  36. end
  37. def edit
  38. end
  39. def update
  40. if @custom_field.update_attributes(params[:custom_field])
  41. flash[:notice] = l(:notice_successful_update)
  42. call_hook(:controller_custom_fields_edit_after_save, :params => params, :custom_field => @custom_field)
  43. redirect_to custom_fields_path(:tab => @custom_field.class.name)
  44. else
  45. render :action => 'edit'
  46. end
  47. end
  48. def destroy
  49. begin
  50. @custom_field.destroy
  51. rescue
  52. flash[:error] = l(:error_can_not_delete_custom_field)
  53. end
  54. redirect_to custom_fields_path(:tab => @custom_field.class.name)
  55. end
  56. private
  57. def build_new_custom_field
  58. @custom_field = CustomField.new_subclass_instance(params[:type], params[:custom_field])
  59. if @custom_field.nil?
  60. render_404
  61. else
  62. @custom_field.default_value = nil
  63. end
  64. end
  65. def find_custom_field
  66. @custom_field = CustomField.find(params[:id])
  67. rescue ActiveRecord::RecordNotFound
  68. render_404
  69. end
  70. end

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