Mercurial > hg > soundsoftware-site
comparison app/controllers/versions_controller.rb @ 929:5f33065ddc4b redmine-1.3
Update to Redmine SVN rev 9414 on 1.3-stable branch
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 14:54:18 +0100 |
parents | cbb26bc654de |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
909:cbb26bc654de | 929:5f33065ddc4b |
---|---|
21 before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] | 21 before_filter :find_model_object, :except => [:index, :new, :create, :close_completed] |
22 before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] | 22 before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed] |
23 before_filter :find_project, :only => [:index, :new, :create, :close_completed] | 23 before_filter :find_project, :only => [:index, :new, :create, :close_completed] |
24 before_filter :authorize | 24 before_filter :authorize |
25 | 25 |
26 accept_api_auth :index, :create, :update, :destroy | 26 accept_api_auth :index, :show, :create, :update, :destroy |
27 | 27 |
28 helper :custom_fields | 28 helper :custom_fields |
29 helper :projects | 29 helper :projects |
30 | 30 |
31 def index | 31 def index |
73 def new | 73 def new |
74 @version = @project.versions.build | 74 @version = @project.versions.build |
75 if params[:version] | 75 if params[:version] |
76 attributes = params[:version].dup | 76 attributes = params[:version].dup |
77 attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) | 77 attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
78 @version.attributes = attributes | 78 @version.safe_attributes = attributes |
79 end | 79 end |
80 end | 80 end |
81 | 81 |
82 def create | 82 def create |
83 # TODO: refactor with code above in #new | 83 # TODO: refactor with code above in #new |
84 @version = @project.versions.build | 84 @version = @project.versions.build |
85 if params[:version] | 85 if params[:version] |
86 attributes = params[:version].dup | 86 attributes = params[:version].dup |
87 attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) | 87 attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
88 @version.attributes = attributes | 88 @version.safe_attributes = attributes |
89 end | 89 end |
90 | 90 |
91 if request.post? | 91 if request.post? |
92 if @version.save | 92 if @version.save |
93 respond_to do |format| | 93 respond_to do |format| |
122 | 122 |
123 def update | 123 def update |
124 if request.put? && params[:version] | 124 if request.put? && params[:version] |
125 attributes = params[:version].dup | 125 attributes = params[:version].dup |
126 attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) | 126 attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) |
127 if @version.update_attributes(attributes) | 127 @version.safe_attributes = attributes |
128 if @version.save | |
128 respond_to do |format| | 129 respond_to do |format| |
129 format.html { | 130 format.html { |
130 flash[:notice] = l(:notice_successful_update) | 131 flash[:notice] = l(:notice_successful_update) |
131 redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project | 132 redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
132 } | 133 } |