1 from django.db import models
2 from jsonfield.fields import JSONField
3 from django.utils.translation import ugettext_lazy as _
4 from archive.settings import FILES_PATH
6 # Create your models here.
9 class Project(models.Model):
10 """ an audiobook project, needed for specyfing sponsors """
12 name = models.CharField(max_length=128, unique=True, db_index=True, verbose_name="Nazwa")
13 sponsors = models.TextField(blank=True, null=True, verbose_name="Sponsorzy")
16 verbose_name = _("project")
17 verbose_name_plural = _("projects")
20 def __unicode__(self):
24 class Audiobook(models.Model):
25 source_file = models.FileField(upload_to=FILES_PATH, verbose_name=_('source file'), editable=False)
27 title = models.CharField(max_length=255, verbose_name=_('title'))
28 artist = models.CharField(max_length=255, verbose_name=_('artist'))
29 conductor = models.CharField(max_length=255, verbose_name=_('conductor'))
30 encoded_by = models.CharField(max_length=255, verbose_name=_('encoded by'))
31 date = models.CharField(max_length=255, verbose_name=_('date'))
32 project = models.ForeignKey(Project, verbose_name=_('project'))
33 url = models.URLField(max_length=255, verbose_name=_('book url'))
34 modified = models.DateTimeField(null=True, editable=False)
36 published_tags = JSONField(null=True, editable=False)
37 mp3_file = models.FileField(null=True, upload_to='archive/final', editable=False)
38 ogg_file = models.FileField(null=True, upload_to='archive/final', editable=False)
39 publishing_tags = JSONField(null=True, editable=False)
41 publish_wait = models.DateTimeField(null=True, editable=False) # somebody hit "publish"
42 publishing = models.BooleanField(default=False, editable=False)
43 published = models.DateTimeField(null=True, editable=False)
46 verbose_name = _("audiobook")
47 verbose_name_plural = _("audiobooks")
50 def __unicode__(self):
53 def new_publish_tags(self):
56 'copyright': 'Fundacja Nowoczesna Polska',