Added furthest complete to project.

This commit is contained in:
Tyrel Souza 2015-03-10 00:51:06 -04:00
parent f9be1484b1
commit 038c21a80b
3 changed files with 13 additions and 4 deletions

View File

@ -19,7 +19,7 @@ class ProjectAdmin(admin.ModelAdmin):
class DueDateClass(admin.ModelAdmin): class DueDateClass(admin.ModelAdmin):
list_display = ('__unicode__', 'project', 'due', 'completed') list_display = ('__unicode__', 'project', 'completed_overdue_date')
admin.site.register(Project, ProjectAdmin) admin.site.register(Project, ProjectAdmin)

View File

@ -21,6 +21,14 @@ class Project(models.Model):
def __unicode__(self): def __unicode__(self):
return self.title 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): class Category(Orderable):
title = models.CharField(max_length=256) title = models.CharField(max_length=256)
@ -38,13 +46,14 @@ class DueDate(models.Model):
completed = models.BooleanField(default=False) completed = models.BooleanField(default=False)
project = models.ForeignKey("Project") project = models.ForeignKey("Project")
@property
def completed_overdue_date(self): def completed_overdue_date(self):
if self.completed: if self.completed:
return "Completed" return "Completed"
if not self.due: if not self.due:
return "" return ""
if self.due > datetime.date.today(): if self.due < datetime.date.today():
return "Overdue {}".format(self.due.strftime(settings.DATE_FMT)) return "Overdue on {}".format(self.due.strftime(settings.DATE_FMT))
return self.due.strftime(settings.DATE_FMT) return self.due.strftime(settings.DATE_FMT)
class Meta: class Meta:

View File

@ -73,4 +73,4 @@ TEMPLATE_DIRS = (
from drf_settings import * from drf_settings import *
DATE_FMT = "%a %m/%d" DATE_FMT = "%A %m/%d"