2015-03-14 22:38:12 +01:00
|
|
|
from django.db import models
|
2016-02-01 18:42:01 +01:00
|
|
|
from django.db.models.signals import pre_save
|
|
|
|
from django.dispatch.dispatcher import receiver
|
2015-05-02 13:06:39 +02:00
|
|
|
from django.template.defaultfilters import slugify
|
2015-03-14 22:38:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Artist(models.Model):
|
2016-02-01 18:42:01 +01:00
|
|
|
""" An Artist of the label. """
|
2016-02-02 18:30:43 +01:00
|
|
|
|
2017-08-17 15:52:09 +02:00
|
|
|
GENRE_HINT = 'lowercase please!'
|
|
|
|
DESC_HINT = 'Markdown or HTML formatting supported'
|
|
|
|
TYPE_HINT = 'main roster (0), side project (1)'
|
|
|
|
|
2017-08-15 15:26:32 +02:00
|
|
|
name = models.CharField(max_length=64)
|
2015-05-02 13:06:39 +02:00
|
|
|
slug = models.SlugField()
|
2017-08-15 15:26:32 +02:00
|
|
|
image = models.ImageField(upload_to='artists')
|
|
|
|
url_bandcamp = models.URLField(blank=True)
|
|
|
|
url_soundcloud = models.URLField(blank=True)
|
2017-08-17 15:52:09 +02:00
|
|
|
genre = models.CharField(max_length=256, help_text=GENRE_HINT)
|
|
|
|
description = models.TextField(blank=True, help_text=DESC_HINT)
|
|
|
|
artist_type = models.IntegerField(default=0, help_text=TYPE_HINT)
|
2015-03-14 22:38:12 +01:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
class Meta(object):
|
2017-08-15 15:26:32 +02:00
|
|
|
ordering = ('name',)
|
|
|
|
|
2015-03-14 22:38:12 +01:00
|
|
|
|
2017-08-17 15:52:09 +02:00
|
|
|
@receiver(pre_save, sender=Artist)
|
2016-02-01 18:42:01 +01:00
|
|
|
def _artist_pre_save(sender, instance, **kwargs):
|
|
|
|
instance.slug = slugify(instance.name)
|
|
|
|
|
2015-03-14 22:38:12 +01:00
|
|
|
|
|
|
|
class Release(models.Model):
|
|
|
|
""" A release (album, EP, ...) of the label.
|
|
|
|
|
|
|
|
Each release has an associated number "ident" to use in the catalog. It has
|
|
|
|
of course a title, several possible artists, and other informations.
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
ident: catalog number
|
|
|
|
title: release title
|
|
|
|
contributors: list of Artists who contributed to this release
|
2017-08-17 15:21:14 +02:00
|
|
|
release_type: see TYPE_HINT
|
2015-03-14 22:38:12 +01:00
|
|
|
year: year of release
|
|
|
|
cover: image file associated to this release
|
|
|
|
"""
|
2016-02-02 18:30:43 +01:00
|
|
|
|
2017-08-17 15:21:14 +02:00
|
|
|
TYPE_HINT = 'full-length (0), EP (1), Split (2), Démo (3)'
|
|
|
|
EMBED_HINT = 'HTML iframe -- for Bandcamp, add the whole tracklist'
|
2017-08-15 15:26:32 +02:00
|
|
|
|
2017-08-17 19:36:54 +02:00
|
|
|
ident = models.IntegerField(unique=True)
|
2017-08-15 15:26:32 +02:00
|
|
|
title = models.CharField(max_length=256)
|
2015-03-14 22:38:12 +01:00
|
|
|
contributors = models.ManyToManyField(Artist)
|
2017-08-17 15:21:14 +02:00
|
|
|
release_type = models.IntegerField(default=0, help_text=TYPE_HINT)
|
2017-08-15 15:26:32 +02:00
|
|
|
cover = models.ImageField(upload_to='releases')
|
2015-03-14 22:38:12 +01:00
|
|
|
year = models.IntegerField()
|
2017-08-17 15:21:14 +02:00
|
|
|
embed = models.TextField(blank=True, help_text=EMBED_HINT)
|
2017-08-15 15:26:32 +02:00
|
|
|
description = models.TextField(blank=True)
|
2015-03-14 22:38:12 +01:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
class Meta(object):
|
2017-08-17 19:36:54 +02:00
|
|
|
ordering = ('-ident',)
|
2017-08-17 19:13:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
class VideoClip(models.Model):
|
|
|
|
""" A video clip. """
|
|
|
|
|
|
|
|
title = models.CharField(max_length=256)
|
|
|
|
artist = models.ForeignKey(Artist, related_name='videos')
|
|
|
|
year = models.IntegerField()
|
|
|
|
embed = models.TextField()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
class Meta(object):
|
2017-08-17 19:36:54 +02:00
|
|
|
ordering = ('-year', 'title')
|