Spell fix
[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 pertinence 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 class Meta:
25 verbose_name = _('Style')
26 verbose_name_plural = _('Styles')
27 ordering = ('name',)
28
29 class UserProfile(models.Model):
30 user = models.OneToOneField(User)
31 headshot = models.ImageField(upload_to='user_headshots')
32 is_author = models.BooleanField()
33 """
34 The main difference is that the author have is own ads publisher
35 The default behavior of class inheritance is to create OnetoOne relationship between parent and child
36 TODO: Which fields are required to interact with the ads publisher ?
37 """
38 ADS_PUBLISHER_CHOICES = (
39 ('AS', 'Advert Stream'),
40 ('TJ', 'Traffic Junky'),
41 )
42 ads_publisher = models.CharField(max_length=50, choices=ADS_PUBLISHER_CHOICES)
43 ads_publisher_login = models.CharField(max_length=50)
44
45 class Meta:
46 verbose_name = _('User profile')
47 verbose_name_plural = _('Users profiles')
48
49 # TODO: See how to handle a group of authors and the revenue sharing ... later
50
51 class Comic_block(models.Model):
52 """
53 Let's view a comics as an images serie
54 """
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):
63 """
64 This idea is to return a visual identifier to the author, self.content is surely bogus to get the image path
65 """
66 return self.name + ' ' + self.content
67
68 class Meta:
69 verbose_name = _('Comic_block')
70 verbose_name_plural = _('Comic_blocks')
71 ordering = ('name',)
72
73 class Comic(models.Model):
74 """
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
77 """
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):
85 return self.title
86
87 class Meta:
88 ordering = ('title',)