playlist privées

This commit is contained in:
Klafyvel 2018-03-28 20:30:37 +02:00
parent 22af46bbf1
commit 01ec7be090
5 changed files with 27 additions and 5 deletions

View file

@ -8,7 +8,7 @@ from player.models import Playlist, Link
class PlaylistForm(forms.ModelForm): class PlaylistForm(forms.ModelForm):
class Meta: class Meta:
model = Playlist model = Playlist
fields = ['name'] fields = ['name', 'public']
def is_valid(self): def is_valid(self):
self.instance.date = timezone.now() self.instance.date = timezone.now()

View file

@ -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"),
),
]

View file

@ -15,6 +15,10 @@ class Playlist(models.Model):
last_get = models.DateTimeField( last_get = models.DateTimeField(
verbose_name="Dernière écoute" verbose_name="Dernière écoute"
) )
public = models.BooleanField(
verbose_name="Visible sur la page d'accueil",
default=True,
)
@staticmethod @staticmethod
def reverse_token(token): def reverse_token(token):

View file

@ -16,15 +16,15 @@
</script> </script>
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-6">
<h1>{{playlist.name}}</h1> <h1>{{playlist.name}}</h1>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<a class="btn btn-success btn-sm" type='button' href=""> <a class="btn btn-outline-success btn-sm" type='button' href="">
<i class="fa fa-edit"></i> Changer le nom <i class="fa fa-edit"></i> Changer le nom
</a> </a>
</div> </div>
<div class="col-md-6"> <div class="col-md-3">
Lien de partage : <input class="input-monospace" value="{{request.get_host}}{{playlist.get_absolute_url}}" type="text" readonly=""> Lien de partage : <input class="input-monospace" value="{{request.get_host}}{{playlist.get_absolute_url}}" type="text" readonly="">
</div> </div>
</div> </div>

View file

@ -72,5 +72,5 @@ def playlist(request, token):
def all_playlist(request): 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}) return render(request, 'player/all_list.html', {'lists':p})