Remplace filter
par _set
quand c'est possible
Par exemple `Spectacle.objects.filter(tirage=tirage)` devient `tirage.spectacle_set`
This commit is contained in:
parent
688dce33d5
commit
ccd38d2723
1 changed files with 6 additions and 6 deletions
12
bda/views.py
12
bda/views.py
|
@ -38,7 +38,7 @@ def etat_places(request, tirage_id):
|
||||||
.all() \
|
.all() \
|
||||||
.values('spectacle','spectacle__title') \
|
.values('spectacle','spectacle__title') \
|
||||||
.annotate(total=models.Count('spectacle'))
|
.annotate(total=models.Count('spectacle'))
|
||||||
spectacles = Spectacle.objects.filter(tirage=tirage).all()
|
spectacles = tirage.spectacle_set.all()
|
||||||
spectacles_dict = {}
|
spectacles_dict = {}
|
||||||
total = 0
|
total = 0
|
||||||
for spectacle in spectacles:
|
for spectacle in spectacles:
|
||||||
|
@ -142,7 +142,7 @@ def inscription(request, tirage_id):
|
||||||
"choices": choices})
|
"choices": choices})
|
||||||
def formfield_callback(f, **kwargs):
|
def formfield_callback(f, **kwargs):
|
||||||
if f.name == "spectacle":
|
if f.name == "spectacle":
|
||||||
kwargs['queryset'] = Spectacle.objects.filter(tirage=tirage)
|
kwargs['queryset'] = tirage.spectacle_set
|
||||||
return f.formfield(**kwargs)
|
return f.formfield(**kwargs)
|
||||||
BdaFormSet = inlineformset_factory(
|
BdaFormSet = inlineformset_factory(
|
||||||
Participant,
|
Participant,
|
||||||
|
@ -189,8 +189,8 @@ def do_tirage(request, tirage_id):
|
||||||
tirage_elt.save()
|
tirage_elt.save()
|
||||||
start = time.time()
|
start = time.time()
|
||||||
data = {}
|
data = {}
|
||||||
shows = Spectacle.objects.filter(tirage=tirage_elt).select_related().all()
|
shows = tirage_elt.spectacle_set.select_related().all()
|
||||||
members = Participant.objects.filter(tirage=tirage_elt).all()
|
members = tirage_elt.spectacle_set.all()
|
||||||
choices = ChoixSpectacle.objects.filter(spectacle__tirage=tirage_elt).order_by(
|
choices = ChoixSpectacle.objects.filter(spectacle__tirage=tirage_elt).order_by(
|
||||||
'participant', 'priority').select_related().all()
|
'participant', 'priority').select_related().all()
|
||||||
algo = Algorithm(shows, members, choices)
|
algo = Algorithm(shows, members, choices)
|
||||||
|
@ -324,13 +324,13 @@ class SpectacleListView(ListView):
|
||||||
@buro_required
|
@buro_required
|
||||||
def unpaid(request, tirage_id):
|
def unpaid(request, tirage_id):
|
||||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||||
unpaid = Participant.objects.filter(tirage=tirage, paid=False).all()
|
unpaid = tirage.participant_set.filter(paid=False).all()
|
||||||
return render(request, "bda-unpaid.html", {"unpaid": unpaid})
|
return render(request, "bda-unpaid.html", {"unpaid": unpaid})
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
def liste_spectacles_ics(request, tirage_id):
|
def liste_spectacles_ics(request, tirage_id):
|
||||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||||
spectacles = Spectacle.objects.filter(tirage=tirage).order_by("date").all()
|
spectacles = tirage.spectacle_set.order_by("date").all()
|
||||||
for spectacle in spectacles:
|
for spectacle in spectacles:
|
||||||
spectacle.dtend = spectacle.date + timedelta(seconds=7200)
|
spectacle.dtend = spectacle.date + timedelta(seconds=7200)
|
||||||
return render(request, "liste_spectacles.ics",
|
return render(request, "liste_spectacles.ics",
|
||||||
|
|
Loading…
Reference in a new issue