From 68334e15d72abb9bec96d1a08928752dbcc3767f Mon Sep 17 00:00:00 2001 From: Hugo Roussille Date: Thu, 16 Mar 2017 05:50:02 +0100 Subject: [PATCH] Gestion des citations --- bda/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bda/views.py b/bda/views.py index cdc7a296..31ac3296 100644 --- a/bda/views.py +++ b/bda/views.py @@ -25,7 +25,7 @@ from django.views.generic.list import ListView from gestioncof.decorators import cof_required, buro_required from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution,\ - Tirage, SpectacleRevente, Salle + Tirage, SpectacleRevente, Salle, Quote from bda.algorithm import Algorithm from bda.forms import BaseBdaFormSet, TokenForm, ResellForm, AnnulForm,\ InscriptionReventeForm, SoldForm @@ -691,7 +691,9 @@ def catalogue(request,request_type): except: return '' + specquotes = lambda spectacle: [{'author': str(quote.author), 'text': str(quote.text)} for quote in Quote.objects.filter(spectacle = spectacle).all()] + # On convertit les descriptions à envoyer en une liste facilement JSONifiable (il devrait y avoir un moyen plus efficace en redéfinissant le serializer de JSON) - data_return = [{'title': spectacle.title, 'category': str(spectacle.category), 'date': str(spectacle.date), 'location': str(spectacle.location), 'vips': spectacle.vips, 'description': spectacle.description, 'slots_description': spectacle.slots_description, 'image': getImgUrl(spectacle), 'ext_link': spectacle.ext_link, 'price': spectacle.price, 'slots': spectacle.slots} for spectacle in shows_qs.all()] + data_return = [{'title': spectacle.title, 'category': str(spectacle.category), 'date': str(spectacle.date), 'location': str(spectacle.location), 'vips': spectacle.vips, 'description': spectacle.description, 'slots_description': spectacle.slots_description, 'quotes': specquotes(spectacle),'image': getImgUrl(spectacle), 'ext_link': spectacle.ext_link, 'price': spectacle.price, 'slots': spectacle.slots} for spectacle in shows_qs.all()] return HttpResponse(json.dumps(data_return)) return HttpResponseBadRequest() # Si la requête n'est pas de la forme attendue, on quitte avec une erreur