From 038c21a80b28071bcd4ddcfc6fc523b2ee684b59 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Tue, 10 Mar 2015 00:51:06 -0400 Subject: [PATCH] Added furthest complete to project. --- project/admin.py | 2 +- project/models.py | 13 +++++++++++-- roadmap/settings.py | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/project/admin.py b/project/admin.py index 22aaff1..9540ebd 100644 --- a/project/admin.py +++ b/project/admin.py @@ -19,7 +19,7 @@ class ProjectAdmin(admin.ModelAdmin): class DueDateClass(admin.ModelAdmin): - list_display = ('__unicode__', 'project', 'due', 'completed') + list_display = ('__unicode__', 'project', 'completed_overdue_date') admin.site.register(Project, ProjectAdmin) diff --git a/project/models.py b/project/models.py index 1b53982..1a4a233 100644 --- a/project/models.py +++ b/project/models.py @@ -21,6 +21,14 @@ class Project(models.Model): def __unicode__(self): return self.title + @property + def furthest_complete(self): + sorted_duedates = self.duedate_set.order_by("-title__sort_order") + for duedate in sorted_duedates: + if duedate.completed: + return unicode(duedate) + return None + class Category(Orderable): title = models.CharField(max_length=256) @@ -38,13 +46,14 @@ class DueDate(models.Model): completed = models.BooleanField(default=False) project = models.ForeignKey("Project") + @property def completed_overdue_date(self): if self.completed: return "Completed" if not self.due: return "" - if self.due > datetime.date.today(): - return "Overdue {}".format(self.due.strftime(settings.DATE_FMT)) + if self.due < datetime.date.today(): + return "Overdue on {}".format(self.due.strftime(settings.DATE_FMT)) return self.due.strftime(settings.DATE_FMT) class Meta: diff --git a/roadmap/settings.py b/roadmap/settings.py index 5889fbb..75525ed 100644 --- a/roadmap/settings.py +++ b/roadmap/settings.py @@ -73,4 +73,4 @@ TEMPLATE_DIRS = ( from drf_settings import * -DATE_FMT = "%a %m/%d" \ No newline at end of file +DATE_FMT = "%A %m/%d" \ No newline at end of file