models: add released flag for releases
This commit is contained in:
parent
f21b23e849
commit
de492c7a9e
18
label/migrations/0004_release_released.py
Normal file
18
label/migrations/0004_release_released.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.6 on 2021-08-23 14:54
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('label', '0003_auto_20170818_1202'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='release',
|
||||||
|
name='released',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
21
label/migrations/0005_auto_20210823_1658.py
Normal file
21
label/migrations/0005_auto_20210823_1658.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Generated by Django 3.2.6 on 2021-08-23 14:58
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def publish_all_releases(apps, schema_editor):
|
||||||
|
Release = apps.get_model('label', 'Release')
|
||||||
|
for release in Release.objects.all():
|
||||||
|
release.released = True
|
||||||
|
release.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('label', '0004_release_released'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(publish_all_releases),
|
||||||
|
]
|
|
@ -45,6 +45,7 @@ class Release(models.Model):
|
||||||
release_type: see TYPE_HINT
|
release_type: see TYPE_HINT
|
||||||
year: year of release
|
year: year of release
|
||||||
cover: image file associated to this release
|
cover: image file associated to this release
|
||||||
|
released: show this release publicly
|
||||||
"""
|
"""
|
||||||
|
|
||||||
TYPE_HINT = 'full-length (0), EP (1), Split (2), Démo (3)'
|
TYPE_HINT = 'full-length (0), EP (1), Split (2), Démo (3)'
|
||||||
|
@ -58,6 +59,7 @@ class Release(models.Model):
|
||||||
year = models.IntegerField()
|
year = models.IntegerField()
|
||||||
embed = models.TextField(blank=True, help_text=EMBED_HINT)
|
embed = models.TextField(blank=True, help_text=EMBED_HINT)
|
||||||
description = models.TextField(blank=True)
|
description = models.TextField(blank=True)
|
||||||
|
released = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
|
@ -29,7 +29,7 @@ def artist_view(request, slug):
|
||||||
|
|
||||||
def releases_view(request):
|
def releases_view(request):
|
||||||
artists = Artist.objects.all()
|
artists = Artist.objects.all()
|
||||||
releases = Release.objects.all()
|
releases = Release.objects.filter(released=True)
|
||||||
|
|
||||||
releases_and_infos = []
|
releases_and_infos = []
|
||||||
for release in releases:
|
for release in releases:
|
||||||
|
@ -50,7 +50,7 @@ def releases_view(request):
|
||||||
|
|
||||||
def release_view(request, tag):
|
def release_view(request, tag):
|
||||||
ident = get_id_from_catalog_tag(tag)
|
ident = get_id_from_catalog_tag(tag)
|
||||||
release = get_object_or_404(Release, ident = ident)
|
release = get_object_or_404(Release, ident=ident, released=True)
|
||||||
contribs = get_contribs(release.contributors.all())
|
contribs = get_contribs(release.contributors.all())
|
||||||
context = {'release': release, 'contribs': contribs}
|
context = {'release': release, 'contribs': contribs}
|
||||||
return render(request, 'label/release.html', context)
|
return render(request, 'label/release.html', context)
|
||||||
|
|
Loading…
Reference in a new issue