Fewer requests on descriptions and catalogue views
This commit is contained in:
parent
98f355ed20
commit
bbe6f41962
1 changed files with 15 additions and 6 deletions
21
bda/views.py
21
bda/views.py
|
@ -710,7 +710,11 @@ def send_rappel(request, spectacle_id):
|
|||
|
||||
def descriptions_spectacles(request, tirage_id):
|
||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||
shows_qs = tirage.spectacle_set
|
||||
shows_qs = (
|
||||
tirage.spectacle_set
|
||||
.select_related('location')
|
||||
.prefetch_related('quote_set')
|
||||
)
|
||||
category_name = request.GET.get('category', '')
|
||||
location_id = request.GET.get('location', '')
|
||||
if category_name:
|
||||
|
@ -721,7 +725,7 @@ def descriptions_spectacles(request, tirage_id):
|
|||
except ValueError:
|
||||
return HttpResponseBadRequest(
|
||||
"La variable GET 'location' doit contenir un entier")
|
||||
return render(request, 'descriptions.html', {'shows': shows_qs.all()})
|
||||
return render(request, 'descriptions.html', {'shows': shows_qs})
|
||||
|
||||
|
||||
def catalogue(request, request_type):
|
||||
|
@ -794,7 +798,11 @@ def catalogue(request, request_type):
|
|||
)
|
||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||
|
||||
shows_qs = tirage.spectacle_set
|
||||
shows_qs = (
|
||||
tirage.spectacle_set
|
||||
.select_related('location')
|
||||
.prefetch_related('quote_set')
|
||||
)
|
||||
if categories_id:
|
||||
shows_qs = shows_qs.filter(category__id__in=categories_id)
|
||||
if locations_id:
|
||||
|
@ -813,14 +821,15 @@ def catalogue(request, request_type):
|
|||
'vips': spectacle.vips,
|
||||
'description': spectacle.description,
|
||||
'slots_description': spectacle.slots_description,
|
||||
'quotes': list(Quote.objects.filter(spectacle=spectacle).values(
|
||||
'author', 'text')),
|
||||
'quotes': [dict(author=quote.author,
|
||||
text=quote.text)
|
||||
for quote in spectacle.quote_set.all()],
|
||||
'image': spectacle.getImgUrl(),
|
||||
'ext_link': spectacle.ext_link,
|
||||
'price': spectacle.price,
|
||||
'slots': spectacle.slots
|
||||
}
|
||||
for spectacle in shows_qs.all()
|
||||
for spectacle in shows_qs
|
||||
]
|
||||
return JsonResponse(data_return, safe=False)
|
||||
# Si la requête n'est pas de la forme attendue, on quitte avec une erreur
|
||||
|
|
Loading…
Reference in a new issue