diff --git a/game/migrations/0017_youtubecredentials_title.py b/game/migrations/0017_youtubecredentials_title.py new file mode 100644 index 0000000..89870e4 --- /dev/null +++ b/game/migrations/0017_youtubecredentials_title.py @@ -0,0 +1,17 @@ +# Generated by Django 5.2.3 on 2025-06-15 08:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("game", "0016_alter_groupleader_member"), + ] + + operations = [ + migrations.AddField( + model_name="youtubecredentials", + name="title", + field=models.CharField(blank=True), + ), + ] diff --git a/game/models.py b/game/models.py index a3f104d..1f8ce2f 100644 --- a/game/models.py +++ b/game/models.py @@ -11,6 +11,7 @@ from . import tasks class YoutubeCredentials(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) credentials = models.JSONField() + title = models.CharField(blank=True) class Group(models.Model): diff --git a/game/tasks.py b/game/tasks.py index ceb5777..22a7dc0 100644 --- a/game/tasks.py +++ b/game/tasks.py @@ -8,7 +8,6 @@ from . import models @shared_task def generate_playlist(creds, game_pk): game = models.MusikGame.objects.get(pk=game_pk) - creds.pop("channel_title") credentials = google.oauth2.credentials.Credentials(**creds) yt_api = googleapiclient.discovery.build("youtube", "v3", credentials=credentials) pl_request = yt_api.playlists().insert( @@ -48,7 +47,6 @@ def generate_playlist(creds, game_pk): @shared_task def delete_playlist(creds, playlist_id): - creds.pop("channel_title") credentials = google.oauth2.credentials.Credentials(**creds) yt_api = googleapiclient.discovery.build("youtube", "v3", credentials=credentials) diff --git a/game/templates/game/home.html b/game/templates/game/home.html index 27511b5..5a290a5 100644 --- a/game/templates/game/home.html +++ b/game/templates/game/home.html @@ -9,7 +9,7 @@ {% if not user.youtubecredentials.credentials %} Me connecter au compte Youtube {% else %} - Connecté au compte Youtube {{ user.youtubecredentials.credentials.channel_title }}. + Connecté au compte Youtube {{ user.youtubecredentials.title }}. {% endif %}