Merge branch 'master' into django-1.10
[mygpo.git] / mygpo / chapters / models.py
blob6f43f94aee369feb040d8e69f93a43f0e7cb8887
1 from django.db import models
2 from django.conf import settings
4 from mygpo.core.models import UpdateInfoModel
5 from mygpo.podcasts.models import Episode
8 class Chapter(UpdateInfoModel):
9 """ A chapter of an Episode """
11 # Seconds at which the chapter starts and ends
12 start = models.IntegerField()
13 end = models.IntegerField()
15 # name or label of the chapter
16 label = models.CharField(max_length=100)
18 # indicates if the chapter is an advertisement
19 advertisement = models.BooleanField(default=False)
21 # the user that created the chapter
22 user = models.ForeignKey(settings.AUTH_USER_MODEL,
23 on_delete=models.CASCADE)
25 # the episode to which the chapter belongs
26 episode = models.ForeignKey(Episode, on_delete=models.CASCADE)
28 class Meta:
29 index_together = [
30 ('user', 'episode', 'created'),
31 ('episode', 'user', 'start', 'end'),