# CCS CS Lab Delicious Models # # Douglas Thrift # # $Id$ from ccscslab.facebook.models import DualUserMixin from datetime import datetime from django.db import models class User(models.Model, DualUserMixin): person = models.ForeignKey('main.Person', related_name = 'delicious_user_set') user = models.ForeignKey('facebook.User', blank = True, null = True, related_name = 'delicious_user_set') name = models.CharField(max_length = 50) title = models.CharField(blank = True, max_length = 75) description = models.CharField(blank = True, max_length = 1000) updated = models.DateTimeField(auto_now = True, default = datetime.utcfromtimestamp(0)) count = models.PositiveIntegerField(default = 0) class Meta: ordering = ('name',) def __unicode__(self): return self.name def get_absolute_url(self): return 'http://delicious.com/' + self.name class Bookmark(models.Model): user = models.ForeignKey(User) hash = models.CharField(max_length = 32) url = models.TextField() description = models.CharField(max_length = 1000) notes = models.CharField(blank = True, max_length = 1000) tags = models.TextField() posted = models.DateTimeField() others = models.PositiveIntegerField(default = 0) class Meta: ordering = ('-posted', 'user') unique_together = ('user', 'hash', 'url') def __unicode__(self): return self.description def get_absolute_url(self): return 'http://delicious.com/url/' + self.hash def get_tags(self): return self.tags.split(' ')