do_not_allow_setting_is_default_if_project_id_is_set.patch

fix to backend so users can't submit an invalid enumeration - Albert Rosenfield, 2010-10-25 17:06

Download (900 Bytes)

View differences:

app/controllers/enumerations_controller.rb 2010-10-19 15:25:34.182267531 +0200
44 44
  end
45 45

  
46 46
  def create
47
    if params[:enumeration][:project_id].length != 0
48
      # disallow is_default if project-specific
49
      params[:enumeration][:is_default] = 0
50
    end
47 51
    @enumeration = Enumeration.new(params[:enumeration])
48 52
    @enumeration.type = params[:enumeration][:type]
49 53
    if @enumeration.save
......
59 63
  end
60 64

  
61 65
  def update
66
    if params[:enumeration][:project_id].length != 0
67
      # disallow is_default if project-specific
68
      params[:enumeration][:is_default] = 0
69
    end
62 70
    @enumeration = Enumeration.find(params[:id])
63 71
    @enumeration.type = params[:enumeration][:type] if params[:enumeration][:type]
64 72
    if @enumeration.update_attributes(params[:enumeration])