1
0
Fork 0
IdreXyz/label/models.py

60 lines
1.8 KiB
Python
Raw Normal View History

2015-03-14 22:38:12 +01:00
from django.db import models
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):
""" An Artist of the label.
Attributes:
name: project / band name
image: image file associated with this project
"""
name = models.CharField(max_length = 64)
2015-05-02 13:06:39 +02:00
slug = models.SlugField()
2015-03-14 22:38:12 +01:00
image = models.ImageField(upload_to = "artists")
url_bandcamp = models.URLField(blank = True)
url_soundcloud = models.URLField(blank = True)
genre = models.CharField(max_length = 256)
description = models.TextField(blank = True)
def __str__(self):
return self.name
2015-05-02 13:06:39 +02:00
def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)
2015-03-14 22:38:12 +01:00
class Meta(object):
ordering = ("name",)
2015-05-02 13:06:39 +02:00
rel_types_hint = "full-length (0), EP (1), Split (2), Démo (3)"
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
release_type: see below
year: year of release
cover: image file associated to this release
"""
ident = models.IntegerField()
title = models.CharField(max_length = 256)
contributors = models.ManyToManyField(Artist)
2015-05-02 13:06:39 +02:00
release_type = models.IntegerField(default = 0, help_text = rel_types_hint)
2015-03-14 22:38:12 +01:00
cover = models.ImageField(upload_to = "releases")
year = models.IntegerField()
embed = models.TextField(blank = True)
description = models.TextField(blank = True)
def __str__(self):
return self.title
class Meta(object):
ordering = ("ident", "title")