1 | from django.db import models
|
---|
2 |
|
---|
3 | class LiveEntryManager(models.Manager):
|
---|
4 | def get_query_set(self):
|
---|
5 | return super(LiveEntryManager, self).get_query_set().filter(
|
---|
6 | release_date__lte=datetime.datetime.now(),
|
---|
7 | status=Entry.STATUS_LIVE
|
---|
8 | )
|
---|
9 |
|
---|
10 | class Entry(models.Model):
|
---|
11 | STATUS_DRAFT = 1
|
---|
12 | STATUS_QUEUED = 2
|
---|
13 | STATUS_LIVE = 3
|
---|
14 |
|
---|
15 | ENTRY_STATUS_CHOICES = (
|
---|
16 | (STATUS_DRAFT, "Draft"),
|
---|
17 | (STATUS_QUEUED, "Queued"),
|
---|
18 | (STATUS_LIVE, "Live"),
|
---|
19 | )
|
---|
20 |
|
---|
21 | release_date = models.DateTimeField(
|
---|
22 | blank=True,
|
---|
23 | db_index=True,
|
---|
24 | default=datetime.datetime.now,
|
---|
25 | editable=True,
|
---|
26 | help_text="Don't change this after publishing; it breaks URLs."
|
---|
27 | )
|
---|
28 | status = models.PositiveSmallIntegerField(choices=ENTRY_STATUS_CHOICES)
|
---|
29 |
|
---|
30 | live = LiveEntryManager()
|
---|