Add a comics taxonomy field.
[webcomics.git] / comicsporn / models.py
CommitLineData
298255d2 1from django.contrib.auth.models import User
315e96d4 2from django.db import models
298255d2 3from django.utils.translation import ugettext_lazy as _
c8070854 4
315e96d4 5
c8070854 6# A very basic data model to begin with
298255d2
JB
7# TODO:
8# - Create sensible default options with translation;
9# - Test the authentification framework;
8e174089 10# - Ensure relevance of the comics building way : block by block;
298255d2
JB
11# - Test upload to images file outside the DB ...;
12# - ...
298255d2
JB
13class Style(models.Model):
14 """
15 TODO: The choice list should be in DB
16 """
17 TAG_NAME_CHOICES = (
18 (_('MG'), _('Manga')),
19 (_('HF'), _('Heroic Fantasy')),
662464ae 20 (_('SF'), _('Science Fiction')),
3b8035e2 21 )
298255d2
JB
22 name = models.CharField(_('name'), max_length=30, choices=TAG_NAME_CHOICES)
23 def __unicode__(self):
24 return self.name
8e174089 25
298255d2
JB
26 class Meta:
27 verbose_name = _('Style')
28 verbose_name_plural = _('Styles')
29 ordering = ('name',)
30
31class UserProfile(models.Model):
32 user = models.OneToOneField(User)
c8070854
JB
33 headshot = models.ImageField(upload_to='user_headshots')
34 is_author = models.BooleanField()
298255d2
JB
35 """
36 The main difference is that the author have is own ads publisher
3be31c18 37 The default behavior of class inheritance is to create OnetoOne relationship between parent and child
298255d2
JB
38 TODO: Which fields are required to interact with the ads publisher ?
39 """
654133ef 40 ADS_PUBLISHER_CHOICES = (
3b8035e2 41 ('AS', 'Advert Stream'),
654133ef 42 ('TJ', 'Traffic Junky'),
3b8035e2 43 )
8e174089
JB
44 ads_publisher = models.CharField(_('Ads publisher'), max_length=50, choices=ADS_PUBLISHER_CHOICES)
45 ads_publisher_login = models.CharField(_('Ads publisher login'), max_length=50)
298255d2
JB
46
47 class Meta:
48 verbose_name = _('User profile')
49 verbose_name_plural = _('Users profiles')
50
51# TODO: See how to handle a group of authors and the revenue sharing ... later
c8070854 52
298255d2
JB
53class Comic_block(models.Model):
54 """
3b8035e2 55 Let's view a comics as an image series
298255d2 56 """
25a48ac4 57 name = models.CharField(_('name'), max_length=50) # probably not useful, it's just simpler to assemble afterwards for author
298255d2
JB
58 number = models.IntegerField(_('number'))
59 content = models.ImageField(upload_to='block_contents')
60 # TODO: probably not useful
61 is_complete = models.BooleanField()
62 upload_datetime = models.DateTimeField(_('upload_datetime'), auto_now=True)
63 authors = models.ManyToManyField(UserProfile, verbose_name=_('authors'))
64 def __unicode__(self):
65 """
66 This idea is to return a visual identifier to the author, self.content is surely bogus to get the image path
67 """
68 return self.name + ' ' + self.content
c8070854 69
298255d2
JB
70 class Meta:
71 verbose_name = _('Comic_block')
72 verbose_name_plural = _('Comic_blocks')
73 ordering = ('name',)
c8070854 74
298255d2
JB
75class Comic(models.Model):
76 """
77 A comic is build from N blocks, whatever they are
78 The ManytoMany relationship is not really required but it much more reflect really : authors can share block between comic
79 """
8e174089 80 title = models.CharField(_('title'), max_length=50)
c8070854 81 rating = models.FloatField()
298255d2
JB
82 is_online = models.BooleanField()
83 publication_date = models.DateField(auto_now=True)
84 blocks = models.ManyToManyField(Comic_block)
85 styles = models.ManyToManyField(Style)
86 def __unicode__(self):
87 return self.title
88
89 class Meta:
8e174089
JB
90 verbose_name = _('Comic')
91 verbose_name_plural = _('Comics')
298255d2 92 ordering = ('title',)