Added furthest complete to project.
This commit is contained in:
parent
f9be1484b1
commit
038c21a80b
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -73,4 +73,4 @@ TEMPLATE_DIRS = (
|
||||
|
||||
from drf_settings import *
|
||||
|
||||
DATE_FMT = "%a %m/%d"
|
||||
DATE_FMT = "%A %m/%d"
|
Loading…
Reference in New Issue
Block a user