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

enumerations_controller.rb 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # redMine - project management software
  2. # Copyright (C) 2006 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 EnumerationsController < ApplicationController
  18. layout 'base'
  19. before_filter :require_admin
  20. def index
  21. list
  22. render :action => 'list'
  23. end
  24. # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  25. verify :method => :post, :only => [ :destroy, :create, :update ],
  26. :redirect_to => { :action => :list }
  27. def list
  28. end
  29. def new
  30. @enumeration = Enumeration.new(:opt => params[:opt])
  31. end
  32. def create
  33. @enumeration = Enumeration.new(params[:enumeration])
  34. if @enumeration.save
  35. flash[:notice] = l(:notice_successful_create)
  36. redirect_to :action => 'list', :opt => @enumeration.opt
  37. else
  38. render :action => 'new'
  39. end
  40. end
  41. def edit
  42. @enumeration = Enumeration.find(params[:id])
  43. end
  44. def update
  45. @enumeration = Enumeration.find(params[:id])
  46. if @enumeration.update_attributes(params[:enumeration])
  47. flash[:notice] = l(:notice_successful_update)
  48. redirect_to :action => 'list', :opt => @enumeration.opt
  49. else
  50. render :action => 'edit'
  51. end
  52. end
  53. def destroy
  54. Enumeration.find(params[:id]).destroy
  55. flash[:notice] = l(:notice_successful_delete)
  56. redirect_to :action => 'list'
  57. rescue
  58. flash[:notice] = "Unable to delete enumeration"
  59. redirect_to :action => 'list'
  60. end
  61. end