1 from django
.db
import models
2 from django
.contrib
.auth
.models
import User
3 from django
.utils
.translation
import ugettext_lazy
as _
5 # A very basic data model to begin with
7 # - Create sensible default options with translation;
8 # - Test the authentification framework;
9 # - Ensure pertinence of the comics building way : block by block;
10 # - Test upload to images file outside the DB ...;
13 class Style(models
.Model
):
15 TODO: The choice list should be in DB
18 (_('MG'), _('Manga')),
19 (_('HF'), _('Heroic Fantasy')),
21 name
= models
.CharField(_('name'), max_length
=30, choices
=TAG_NAME_CHOICES
)
22 def __unicode__(self
):
25 verbose_name
= _('Style')
26 verbose_name_plural
= _('Styles')
29 class UserProfile(models
.Model
):
30 user
= models
.OneToOneField(User
)
31 headshot
= models
.ImageField(upload_to
='user_headshots')
32 is_author
= models
.BooleanField()
34 The main difference is that the author have is own ads publisher
35 The default behaviour of class inheritance is to create OnetoOne relationship between parent and child
36 TODO: Which fields are required to interact with the ads publisher ?
38 ADS_PUBLISHER_CHOICES
= (
39 ('AS', 'Advert Stream'),
40 ('TJ', 'Traffic Junky'),
42 ads_publisher
= models
.CharField(max_length
=50, choices
=ADS_PUBLISHER_CHOICES
)
43 ads_publisher_login
= models
.CharField(max_length
=50)
46 verbose_name
= _('User profile')
47 verbose_name_plural
= _('Users profiles')
49 # TODO: See how to handle a group of authors and the revenue sharing ... later
51 class Comic_block(models
.Model
):
53 Let's view a comics as an images serie
55 name
= models
.CharField(_('name'), max_length
=50) # probably not useful, it's just simplier to assemble afterwards for author
56 number
= models
.IntegerField(_('number'))
57 content
= models
.ImageField(upload_to
='block_contents')
58 # TODO: probably not useful
59 is_complete
= models
.BooleanField()
60 upload_datetime
= models
.DateTimeField(_('upload_datetime'), auto_now
=True)
61 authors
= models
.ManyToManyField(UserProfile
, verbose_name
=_('authors'))
62 def __unicode__(self
):
64 This idea is to return a visual identifier to the author, self.content is surely bogus to get the image path
66 return self
.name
+ ' ' + self
.content
69 verbose_name
= _('Comic_block')
70 verbose_name_plural
= _('Comic_blocks')
73 class Comic(models
.Model
):
75 A comic is build from N blocks, whatever they are
76 The ManytoMany relationship is not really required but it much more reflect really : authors can share block between comic
78 title
= models
.CharField(max_length
=50)
79 rating
= models
.FloatField()
80 is_online
= models
.BooleanField()
81 publication_date
= models
.DateField(auto_now
=True)
82 blocks
= models
.ManyToManyField(Comic_block
)
83 styles
= models
.ManyToManyField(Style
)
84 def __unicode__(self
):