Couldn't get this patch to apply. Be sure it's against the latest from
master. Try pulling on master and then rebasing and resending the
patch.
One comment below.
On Thu, Nov 27, 2008 at 8:20 AM, LAN-SUN-LUK Benjamin
<Benjamin.LAN-SUN-LUK(a)supinfo.com> wrote:
Thanks for the suggestions.
Signed-off-by: Benjamin LAN-SUN-LUK <benjamin.lan-sun-luk(a)supinfo.com>
---
app/controllers/sprints_controller.rb | 22 ++++++++++++++--------
app/models/sprint.rb | 10 ++++++++++
app/views/sprints/show.html.erb | 2 +-
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/app/controllers/sprints_controller.rb
b/app/controllers/sprints_controller.rb
index 09ebe5b..f8f5881 100644
--- a/app/controllers/sprints_controller.rb
+++ b/app/controllers/sprints_controller.rb
@@ -87,15 +87,21 @@ class SprintsController < ApplicationController
def update
respond_to do |format|
if @sprint.can_edit?(@user)
- @sprint.update_attributes(params[:sprint])
-
- if @sprint.save
- flash[:message] = "Sprint updated successfully."
- format.html { redirect_to params[:url] ? params[:url] :
product_sprints_path(@product) }
+ unless @sprint.allowed_status?(params[:sprint][:status] ||
@sprint.status)
+ flash[:error] = "You cannot change the status because you got
tasks against the sprint"
+ format.html { redirect_to :action => :show }
else
- @title = "Sprint #{(a)sprint.id} (Edit)"
- @sprint.valid?
- format.html { render :action => :edit }
+
+ @sprint.update_attributes(params[:sprint])
+
+ if @sprint.save
+ flash[:message] = "Sprint updated successfully."
+ format.html { redirect_to params[:url] ? params[:url] :
product_sprints_path(@product) }
+ else
+ @title = "Sprint #{(a)sprint.id} (Edit)"
+ @sprint.valid?
+ format.html { render :action => :edit }
+ end
end
else
flash[:error] = "You are now allowed to edit sprints for
#{(a)product.name}."
diff --git a/app/models/sprint.rb b/app/models/sprint.rb
index 2638613..da092ee 100644
--- a/app/models/sprint.rb
+++ b/app/models/sprint.rb
@@ -171,4 +171,14 @@ class Sprint < ActiveRecord::Base
return false
end
+
+ # Check if the sprint is active and have tasks againsts him.
+ def has_activity?
+ status == STATUS_ACTIVE && !actual_hours.zero?
+ end
+
+ # Check if the sprint can move to this new status
+ def allowed_status?(new_status)
+ !(has_activity? && new_status.to_i == STATUS_PLANNED)
+ end
end
diff --git a/app/views/sprints/show.html.erb
b/app/views/sprints/show.html.erb
index 6fb47e3..6db7c0e 100644
--- a/app/views/sprints/show.html.erb
+++ b/app/views/sprints/show.html.erb
@@ -46,7 +46,7 @@
<% form_for(:sprint, @sprint, :url =>
product_sprint_path(@product, @sprint),
:html => {:method => :put}) do |form| %>
<%= hidden_field_tag :url, product_sprint_url(@product,
@sprint) %>
- <%= select :sprint, :status, Sprint::STATUS_TEXT %>
+ <%= select :sprint, :status, @sprint.has_activity? ?
Sprint::STATUS_TEXT[1..3] : Sprint::STATUS_TEXT %>
This would be more ruby-esque, and avoid a potential bug if we add new
statuses, if you instead use something like:
<%= select :sprint, :status, Sprint::STATUS_TEXT -
(@sprint.has_activity? ? [Sprint::STATUS_PLANNED] : [nil]) %>
<%= submit_tag "Apply" %>
<% end %>
<% else %>
--
1.6.0.2
_______________________________________________
projxp-devel mailing list
projxp-devel(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/projxp-devel
--
Darryl L. Pierce <mcpierce(a)gmail.com>
Visit the Infobahn Offramp: <
http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant