diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-12-07 15:45:16 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-12-07 15:45:16 +0300 |
commit | a468bf346af9f86b4a9e5d3ba027e0debad948cc (patch) | |
tree | 3e29605eee1ae4bcb5a7b6a4e3af5216732843e1 /app/models/global_milestone.rb | |
parent | 359d94607c2df324bc5cd9591bded05dbe9ca157 (diff) | |
parent | ff08ce9ca4bef1a4f81f7a4b323614a639efe959 (diff) |
Merge branch 'gsmethells/gitlab-ce-sort-by-due-date'
Diffstat (limited to 'app/models/global_milestone.rb')
-rw-r--r-- | app/models/global_milestone.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb index 85aa71662fe..8bfc79d88f8 100644 --- a/app/models/global_milestone.rb +++ b/app/models/global_milestone.rb @@ -19,6 +19,14 @@ class GlobalMilestone @title.to_slug.to_s end + def expired? + if due_date + due_date.past? + else + false + end + end + def projects milestones.map { |milestone| milestone.project } end @@ -98,4 +106,25 @@ class GlobalMilestone def complete? total_items_count == closed_items_count end + + def due_date + return @due_date if defined?(@due_date) + + @due_date = + if @milestones.all? { |x| x.due_date == @milestones.first.due_date } + @milestones.first.due_date + else + nil + end + end + + def expires_at + if due_date + if due_date.past? + "expired at #{due_date.stamp("Aug 21, 2011")}" + else + "expires at #{due_date.stamp("Aug 21, 2011")}" + end + end + end end |