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