I hope that it work now :-).
Signed-off-by: Benjamin LAN-SUN-LUK <benjamin.lan-sun-luk(a)supinfo.com>
---
app/controllers/sprints_controller.rb | 18 ++++++++----------
app/models/backlog_item.rb | 4 ++++
app/views/sprints/plan.html.erb | 6 +++---
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/app/controllers/sprints_controller.rb
b/app/controllers/sprints_controller.rb
index df336ad..713d330 100644
--- a/app/controllers/sprints_controller.rb
+++ b/app/controllers/sprints_controller.rb
@@ -130,14 +130,6 @@ class SprintsController < ApplicationController
@title = "Sprint #{(a)sprint.id} (Planning)"
@user_stories = UserStory.find_all_by_product_id((a)product.id)
- @estimates = Hash.new
- @selected = Array.new
-
- BacklogItem.find_all_by_sprint_id((a)sprint.id).each do |item|
- @estimates["#{item.user_story_id}"] = item.estimated_hours
- @selected << item.user_story_id
- end
-
format.html
else
flash[:error] = "You are not allowed to plan this sprint."
@@ -167,7 +159,7 @@ class SprintsController < ApplicationController
@sprint.backlog_items << BacklogItem.new(
:sprint_id => @sprint.id,
:user_story_id => selected,
- :estimated_hours => estimate.to_f)
+ :estimated_hours => estimate)
end
end
@@ -177,8 +169,14 @@ class SprintsController < ApplicationController
else
@title = "Sprint #{(a)sprint.id} (Planning)"
flash[:error] = "There was an error updating the sprint
backlog."
+ @sprint.backlog_items.each do |backlog_item|
+ if backlog_item.errors['estimated_hours']
+ flash[:error] += ' ' +
backlog_item.errors['estimated_hours']
+ break
+ end
+ end
@user_stories = UserStory.find_all_by_product_id((a)product.id)
- format.html { render :action => :plan }
+ format.html { render :action => :plan, :selected =>
params[:selected] }
end
else
flash[:error] = "You are not allowed to plan this sprint."
diff --git a/app/models/backlog_item.rb b/app/models/backlog_item.rb
index d149172..5a88800 100644
--- a/app/models/backlog_item.rb
+++ b/app/models/backlog_item.rb
@@ -24,6 +24,10 @@ class BacklogItem < ActiveRecord::Base
validates_presence_of :user_story_id,
:message => 'You need to specify a user story.'
+ validates_numericality_of :estimated_hours,
+ :greater_than => 0,
+ :message => 'Estimated hours must be numeric and greater than 0.'
+
belongs_to :sprint
belongs_to :user_story
belongs_to :owner, :class_name => 'User', :foreign_key =>
'owner_id'
diff --git a/app/views/sprints/plan.html.erb
b/app/views/sprints/plan.html.erb
index ba6bb95..de55d5e 100644
--- a/app/views/sprints/plan.html.erb
+++ b/app/views/sprints/plan.html.erb
@@ -22,13 +22,13 @@
<tbody>
<% @user_stories.each_with_index do |story, index| %>
<% row_class = index%2 == 0 ? 'even' : 'odd' %>
-
+ <% backlog_item =
@sprint.backlog_items.find_by_user_story_id(story.id) %>
<tr class="<%= row_class %>">
<td><%= story.id %></td>
<td><%= story.priority %></td>
<td>
- <%= check_box_tag "selected[]", story.id,
@selected.include?(story.id) %>
- <%= text_field_tag "estimates['#{story.id}']",
@estimates["#{story.id}"],
+ <%= check_box_tag "selected[]", story.id, (backlog_item ||
(params[:selected].include?(story.id.to_s) if params[:selected])) %>
+ <%= text_field_tag "estimates['#{story.id}']",
(backlog_item.estimated_hours if backlog_item),
:size => 4, :maxlength => 4%>
</td>
<td><%= get_first_sentence story.description %></td>
--
1.6.0.2
Show replies by date
On Sun, Nov 16, 2008 at 7:55 PM, LAN-SUN-LUK Benjamin
<Benjamin.LAN-SUN-LUK(a)supinfo.com> wrote:
I hope that it work now :-).
ACK. Though if you can fix it to not lose the bad estimates, that
would be optimal. But, you can push this as is.
--
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
I will try to do this tomorow ;-).
---
Benjamin LAN-SUN-LUK
Le 17 nov. 08 à 02:39, "Darryl Pierce" <mcpierce(a)gmail.com> a écrit :
On Sun, Nov 16, 2008 at 7:55 PM, LAN-SUN-LUK Benjamin
<Benjamin.LAN-SUN-LUK(a)supinfo.com> wrote:
> I hope that it work now :-).
ACK. Though if you can fix it to not lose the bad estimates, that
would be optimal. But, you can push this as is.
--
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
_______________________________________________
projxp-devel mailing list
projxp-devel(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/projxp-devel