This commit is contained in:
Palo Delincak
2011-12-21 11:41:04 +01:00
parent fba5042ba3
commit bc33dd1127
3 changed files with 164 additions and 26 deletions
+20 -20
View File
@@ -13,8 +13,8 @@ class DeliverablesController < ApplicationController
@deliverable_count = Deliverable.count(:conditions => { :project_id => @project.id})
@deliverable_pages = Paginator.new self, @deliverable_count, per_page_option, params['page']
@deliverables = Deliverable.find(:all,
{
@deliverables = Deliverable.find(:all,
{
:conditions => { :project_id => @project.id},
:limit => per_page_option,
:offset => @deliverable_pages.current.offset
@@ -22,7 +22,7 @@ class DeliverablesController < ApplicationController
)
@deliverables = sort_if_needed @deliverables
@deliverable = Deliverable.new
@budget = Budget.new(@project.id)
@@ -32,14 +32,15 @@ class DeliverablesController < ApplicationController
respond_to do |format|
format.html { render :action => 'index', :layout => !request.xhr? }
end
end
# Action to preview the Deliverable description
def preview
@text = params[:deliverable][:description]
render :partial => 'common/preview'
end
# Saves a new Deliverable
def create
if params[:deliverable][:type] == FixedDeliverable.name
@@ -49,7 +50,7 @@ class DeliverablesController < ApplicationController
else
@deliverable = Deliverable.new(params[:deliverable])
end
@deliverable.project = @project
@budget = Budget.new(@project.id)
respond_to do |format|
@@ -72,11 +73,11 @@ class DeliverablesController < ApplicationController
# Updates an existing Deliverable, optionally changing it's type
def update
@deliverable = Deliverable.find(params[:deliverable_id])
if params[:deliverable][:type] != @deliverable.class
@deliverable = @deliverable.change_type(params[:deliverable][:type])
end
respond_to do |format|
if @deliverable.update_attributes(params[:deliverable])
@flash = l(:notice_successful_create)
@@ -86,20 +87,20 @@ class DeliverablesController < ApplicationController
end
end
end
# Removes the Deliverable
def destroy
@deliverable = Deliverable.find_by_id_and_project_id(params[:deliverable_id], @project.id)
render_404 and return unless @deliverable
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
end
# Create a query in the session and redirects to the issue list with that query
def issues
@query = Query.new(:name => "_")
@@ -115,25 +116,25 @@ class DeliverablesController < ApplicationController
redirect_to :controller => 'issues', :action => 'index', :project_id => @project.id
end
# Assigns issues to the Deliverable based on their Version
def bulk_assign_issues
@deliverable = Deliverable.find_by_id_and_project_id(params[:deliverable_id], @project.id)
render_404 and return unless @deliverable
render_403 and return unless @deliverable.editable_by?(User.current)
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
end
private
def find_project
@project = Project.find(params[:id])
end
def get_settings
@settings = Setting.plugin_budget_plugin
end
@@ -146,7 +147,7 @@ class DeliverablesController < ApplicationController
return { :order => sort_clause }
end
end
# Sort +deliverables+ manually using the virtual fields
def sort_if_needed(deliverables)
if session[@sort_name] && %w(score spent progress labor_budget).include?(session[@sort_name][:key])
@@ -167,5 +168,4 @@ class DeliverablesController < ApplicationController
return deliverables
end
end
end