From 39a548fd2629f3b6383990264b2e331b3aea99fb Mon Sep 17 00:00:00 2001 From: eliott Date: Sat, 3 Nov 2007 03:45:10 -0400 Subject: Initial import for public release... Special Note Prior to git import, approx 90% of the code was done by Judd Vinet. Thanks Judd! --- todolists/models.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 todolists/models.py (limited to 'todolists/models.py') diff --git a/todolists/models.py b/todolists/models.py new file mode 100644 index 0000000..0a4f445 --- /dev/null +++ b/todolists/models.py @@ -0,0 +1,31 @@ +from django.db import models +from django.contrib.auth.models import User +from archlinux.packages.models import Package + +class TodolistManager(models.Manager): + def get_incomplete(self): + results = [] + for l in self.all().order_by('-date_added'): + if TodolistPkg.objects.filter(list=l.id).filter(complete=False).count() > 0: + results.append(l) + return results + +class Todolist(models.Model): + id = models.AutoField(primary_key=True) + creator = models.ForeignKey(User) + name = models.CharField(maxlength=255) + description = models.TextField() + date_added = models.DateField(auto_now_add=True) + objects = TodolistManager() + class Meta: + db_table = 'todolists' + +class TodolistPkg(models.Model): + id = models.AutoField(primary_key=True) + list = models.ForeignKey(Todolist) + pkg = models.ForeignKey(Package) + complete = models.BooleanField(default=False) + class Meta: + db_table = 'todolists_pkgs' + unique_together = (('list','pkg'),) + -- cgit v1.2.3-24-g4f1b