From 058195d6709affbf5948d653d3da1c1467b27a8b Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 18 Nov 2014 10:16:18 +0100 Subject: [PATCH] User story points are undefined if the task points are undefined --- taiga/projects/userstories/models.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/taiga/projects/userstories/models.py b/taiga/projects/userstories/models.py index f9688380..54458b3c 100644 --- a/taiga/projects/userstories/models.py +++ b/taiga/projects/userstories/models.py @@ -126,9 +126,15 @@ class UserStory(OCCModelMixin, WatchedModelMixin, BlockedMixin, TaggedMixin, mod return self.role_points def get_total_points(self): + not_null_role_points = self.role_points.select_related("points").\ + exclude(points__value__isnull=True) + + #If we only have None values the sum should be None + if not not_null_role_points: + return None + total = 0.0 - for rp in self.role_points.select_related("points"): - if rp.points.value: - total += rp.points.value + for rp in not_null_role_points: + total += rp.points.value return total