1 from django.db import models
2 from jsonfield.fields import JSONField
3 from django.utils.translation import ugettext_lazy as _
5 # Create your models here.
8 class Project(models.Model):
9 """ an audiobook project, needed for specyfing sponsors """
11 name = models.CharField(max_length=128, unique=True, db_index=True, verbose_name="Nazwa")
12 sponsors = models.TextField(blank=True, null=True, verbose_name="Sponsorzy")
15 verbose_name = _("project")
16 verbose_name_plural = _("projects")
19 def __unicode__(self):
23 class Audiobook(models.Model):
24 source_file = models.FileField(upload_to='archive/files', verbose_name=_('source file'), editable=False)
26 title = models.CharField(max_length=255, verbose_name=_('title'))
27 artist = models.CharField(max_length=255, verbose_name=_('artist'))
28 conductor = models.CharField(max_length=255, verbose_name=_('conductor'))
29 encoded_by = models.CharField(max_length=255, verbose_name=_('encoded by'))
30 date = models.CharField(max_length=255, verbose_name=_('date'))
31 project = models.ForeignKey(Project, verbose_name=_('project'))
32 url = models.URLField(max_length=255, verbose_name=_('book url'))
33 modified = models.DateTimeField(null=True, editable=False)
35 published_tags = JSONField(null=True, editable=False)
36 mp3_file = models.FileField(null=True, upload_to='archive/final', editable=False)
37 ogg_file = models.FileField(null=True, upload_to='archive/final', editable=False)
38 publishing_tags = JSONField(null=True, editable=False)
40 publish_wait = models.DateTimeField(null=True, editable=False) # somebody hit "publish"
41 publishing = models.BooleanField(default=False, editable=False)
42 published = models.DateTimeField(null=True, editable=False)
45 verbose_name = _("audiobook")
46 verbose_name_plural = _("audiobooks")
49 def __unicode__(self):
52 def new_publish_tags(self):
55 'copyright': 'Fundacja Nowoczesna Polska',