blob: 0a4f445e4c1b9eec71281257ee3257a9e9c27388 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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'),)
|