1 from django.db import models
3 # Create your models here.
4 class PartCache(models.Model):
5 document_id = models.CharField(max_length=255)
6 user_id = models.CharField(max_length=64, blank=True)
7 part_id = models.CharField(max_length=255)
10 def update_cache(me, docid, userid, old, new):
14 related = me.objects.filter(user_id=userid, document_id=docid)
16 missing = old.difference(new)
17 related.filter(part_id__in=missing).delete()
19 created = new.difference(old)
22 me.objects.create(user_id=userid, document_id=docid, part_id=part)