From 01ec7be09004fe46fd19aecdf757b955089d800c Mon Sep 17 00:00:00 2001 From: Klafyvel Date: Wed, 28 Mar 2018 20:30:37 +0200 Subject: [PATCH] =?UTF-8?q?playlist=20priv=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- player/forms.py | 2 +- player/migrations/0004_playlist_public.py | 18 ++++++++++++++++++ player/models.py | 4 ++++ player/templates/player/playlist.html | 6 +++--- player/views.py | 2 +- 5 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 player/migrations/0004_playlist_public.py diff --git a/player/forms.py b/player/forms.py index dc504bb..21e8c2e 100644 --- a/player/forms.py +++ b/player/forms.py @@ -8,7 +8,7 @@ from player.models import Playlist, Link class PlaylistForm(forms.ModelForm): class Meta: model = Playlist - fields = ['name'] + fields = ['name', 'public'] def is_valid(self): self.instance.date = timezone.now() diff --git a/player/migrations/0004_playlist_public.py b/player/migrations/0004_playlist_public.py new file mode 100644 index 0000000..a5eb319 --- /dev/null +++ b/player/migrations/0004_playlist_public.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.3 on 2018-03-28 17:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('player', '0003_auto_20180328_1612'), + ] + + operations = [ + migrations.AddField( + model_name='playlist', + name='public', + field=models.BooleanField(default=True, verbose_name="Visible sur la page d'accueil"), + ), + ] diff --git a/player/models.py b/player/models.py index 982d5a5..c994a81 100644 --- a/player/models.py +++ b/player/models.py @@ -15,6 +15,10 @@ class Playlist(models.Model): last_get = models.DateTimeField( verbose_name="Dernière écoute" ) + public = models.BooleanField( + verbose_name="Visible sur la page d'accueil", + default=True, + ) @staticmethod def reverse_token(token): diff --git a/player/templates/player/playlist.html b/player/templates/player/playlist.html index 740e180..3a865b4 100644 --- a/player/templates/player/playlist.html +++ b/player/templates/player/playlist.html @@ -16,15 +16,15 @@
-
+

{{playlist.name}}

-
+
Lien de partage :
diff --git a/player/views.py b/player/views.py index 55f2db4..1eaa15f 100644 --- a/player/views.py +++ b/player/views.py @@ -72,5 +72,5 @@ def playlist(request, token): def all_playlist(request): - p = Playlist.objects.all().order_by('date') + p = Playlist.objects.filter(public=True).order_by('date') return render(request, 'player/all_list.html', {'lists':p})