Conflicts:
	app/controllers/deliverables_controller.rb
This commit is contained in:
Richard Říman
2012-11-23 15:06:54 +01:00
20 changed files with 179 additions and 141 deletions
+13 -14
View File
@@ -38,7 +38,6 @@ class DeliverablesController < ApplicationController
# Action to preview the Deliverable description
def preview
@text = params[:deliverable][:description]
render :partial => 'common/preview'
end
# Saves a new Deliverable
@@ -57,9 +56,9 @@ class DeliverablesController < ApplicationController
if @deliverable.save
@flash = l(:notice_successful_create)
format.html { redirect_to :action => 'index' }
format.js { render :action => 'create.js.rjs'}
format.js
else
format.js { render :action => 'create_error.js.rjs'}
format.js
end
end
@@ -67,7 +66,7 @@ class DeliverablesController < ApplicationController
# Builds the edit form for the Deliverable
def edit
@deliverable = Deliverable.find_by_id_and_project_id(params[:deliverable_id], params[:id])
@deliverable = Deliverable.find_by_id_and_project_id(params[:deliverable_id], @project.id)
end
# Updates an existing Deliverable, optionally changing it's type
@@ -81,9 +80,9 @@ class DeliverablesController < ApplicationController
respond_to do |format|
if @deliverable.update_attributes(params[:deliverable])
@flash = l(:notice_successful_create)
format.html { redirect_to :action => 'index', :id => @project.id }
format.html { redirect_to :action => 'index', :id => @project.identifier }
else
format.html { render :action => 'edit', :id => @project.id}
format.html { render :action => 'edit', :id => @project.identifier }
end
end
@@ -98,7 +97,7 @@ class DeliverablesController < ApplicationController
render_403 and return unless @deliverable.editable_by?(User.current)
@deliverable.destroy
flash[:notice] = l(:notice_successful_delete)
redirect_to :action => 'index', :id => @project.id
redirect_to :action => 'index', :id => @project.identifier
end
# Create a query in the session and redirects to the issue list with that query
@@ -114,7 +113,7 @@ class DeliverablesController < ApplicationController
session[:query] = {:project_id => @query.project_id, :filters => @query.filters}
redirect_to :controller => 'issues', :action => 'index', :project_id => @project.id
redirect_to :controller => 'issues', :action => 'index', :project_id => @project.identifier
end
# Assigns issues to the Deliverable based on their Version
@@ -127,12 +126,12 @@ class DeliverablesController < ApplicationController
number_updated = @deliverable.assign_issues_by_version(params[:version][:id])
flash[:notice] = l(:message_updated_issues, number_updated)
redirect_to :action => 'index', :id => @project.id
redirect_to :action => 'index', :id => @project.identifier
end
private
def find_project
@project = Project.find(params[:id])
@project = Project.where(:identifier => params[:id]).first || Project.find(params[:id])
end
def get_settings
@@ -152,13 +151,13 @@ class DeliverablesController < ApplicationController
def sort_if_needed(deliverables)
if session[@sort_name] && %w(score spent progress labor_budget).include?(session[@sort_name][:key])
case session[@sort_name][:key]
when "score":
when "score" then
sorted = deliverables.sort {|a,b| a.score <=> b.score}
when "spent":
when "spent" then
sorted = deliverables.sort {|a,b| a.spent <=> b.spent}
when "progress":
when "progress" then
sorted = deliverables.sort {|a,b| a.progress <=> b.progress}
when "labor_budget":
when "labor_budget" then
sorted = deliverables.sort {|a,b| a.labor_budget <=> b.labor_budget}
end