-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
59 lines (44 loc) · 1.77 KB
/
models.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from django.db import models
from django.contrib.auth.models import User
class Feed(models.Model):
url = models.URLField()
title = models.CharField(max_length=255)
link = models.URLField(blank=True, null=True)
updated = models.DateTimeField()
etag = models.CharField(max_length=255, blank=True, null=True)
modified = models.DateTimeField(blank=True, null=True)
alive = models.BooleanField(default=True)
def __unicode__(self):
return u'%s <%s>' % (self.title, self.url)
class Entry(models.Model):
feed = models.ForeignKey(Feed, related_name='entries')
uri = models.CharField(max_length=255)
title = models.CharField(max_length=255)
link = models.URLField(blank=True, null=True)
published = models.DateTimeField()
updated = models.DateTimeField()
summary = models.TextField(blank=True, null=True)
content = models.TextField(blank=True, null=True)
class Meta:
verbose_name_plural = 'entries'
ordering = ['-published']
def __unicode__(self):
return u'%s <%s>' % (self.title, self.feed)
class Subscription(models.Model):
user = models.ForeignKey(User, related_name='reader_subscriptions')
feed = models.ForeignKey(Feed, related_name='subscriptions')
custom_title = models.CharField(max_length=255, blank=True, null=True)
@property
def title(self):
return self.custom_title if self.custom_title else self.feed.title
def __unicode__(self):
return u'%s <%s>' % (self.user, self.feed)
class UserEntry(models.Model):
user = models.ForeignKey(User, related_name='reader_userentries')
entry = models.ForeignKey(Entry, related_name='userentries')
read = models.BooleanField(default=False)
class Meta:
verbose_name = 'user entry relationship'
verbose_name_plural = 'user entry relationships'
def __unicode__(self):
return u'%s <%s>' % (self.user, self.entry)