diff --git a/bda/templates/spectacle_list.html b/bda/templates/spectacle_list.html index a0d2ccbc..d707dde4 100644 --- a/bda/templates/spectacle_list.html +++ b/bda/templates/spectacle_list.html @@ -3,9 +3,9 @@ {% block realcontent %}

Spectacles

{% endblock %} diff --git a/bda/views.py b/bda/views.py index 1e55e076..4939e2db 100644 --- a/bda/views.py +++ b/bda/views.py @@ -11,6 +11,7 @@ import hashlib from django.core.mail import send_mail from django.utils import timezone +from django.views.generic.list import ListView from datetime import timedelta import time @@ -299,18 +300,32 @@ def spectacle(request, tirage_id, spectacle_id): spectacle = get_object_or_404(Spectacle, id = spectacle_id, tirage=tirage) return render(request, "bda-emails.html", {"spectacle": spectacle}) + +class SpectacleListView(ListView): + model = Spectacle + template_name = 'spectacle_list.html' + def get_queryset(self): + self.tirage = get_object_or_404(Tirage, id=self.kwargs['tirage_id']) + categories = Spectacle.objects.filter(tirage=self.tirage) + return categories + def get_context_data(self, **kwargs): + context = super(SpectacleListView, self).get_context_data(**kwargs) + context['tirage_id'] = self.tirage.id + return context + @buro_required def unpaid(request, tirage_id): tirage = get_object_or_404(Tirage, id=tirage_id) - unpaid = Participants.objects.filter(tirage=tirage, paid=False).all() + unpaid = Participant.objects.filter(tirage=tirage, paid=False).all() return render(request, "bda-unpaid.html", {"unpaid": unpaid}) @buro_required def liste_spectacles_ics(request, tirage_id): + tirage = get_object_or_404(Tirage, id=tirage_id) spectacles = Spectacle.objects.filter(tirage=tirage).order_by("date").all() for spectacle in spectacles: spectacle.dtend = spectacle.date + timedelta(seconds=7200) return render(request, "liste_spectacles.ics", - { "spectacles": spectacles, "tirage": tirage}, + {"spectacles": spectacles, "tirage": tirage}, content_type="text/calendar") diff --git a/cof/urls.py b/cof/urls.py index 18e4b5db..e841ee02 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -6,9 +6,9 @@ autocomplete_light.autodiscover() from django.contrib import admin admin.autodiscover() -from django.views.generic.list import ListView from django.views.generic.base import TemplateView from bda.models import Spectacle +from bda.views import SpectacleListView from gestioncof.petits_cours_views import DemandeListView urlpatterns = patterns('', @@ -40,22 +40,16 @@ urlpatterns = patterns('', url(r'^petitcours/demandes/(?P\d+)$', 'gestioncof.petits_cours_views.details', name = 'petits-cours-demande-details'), url(r'^petitcours/demandes/(?P\d+)/traitement$', 'gestioncof.petits_cours_views.traitement', name = 'petits-cours-demande-traitement'), url(r'^petitcours/demandes/(?P\d+)/retraitement$', 'gestioncof.petits_cours_views.retraitement', name = 'petits-cours-demande-retraitement'), - url(r'^bda/inscription/(?P\d+)$', 'bda.views.inscription', name = 'bda-tirage-inscription'), url(r'^bda/places/(?P\d+)$', 'bda.views.places', name = "bda-places-attribuees"), url(r'^bda/places/(?P\d+)/places_bda.ics$', 'bda.views.places_ics', name = "bda-places-attribuees-ics"), url(r'^bda/revente/(?P\d+)$', 'bda.views.revente', name = 'bda-revente'), url(r'^bda/etat-places/(?P\d+)$', 'bda.views.etat_places', name = 'bda-etat-places'), url(r'^bda/tirage/(?P\d+)$', 'bda.views.tirage'), - # FIXME - url(r'^bda/spectacles/(?P\d+)$', lambda request, tirage_id: - ListView(model=Spectacle, - queryset=Spectacle.objects.filter(tirage__id=tirage_id) - ), name ="bda-liste-spectacles"), + url(r'^bda/spectacles/(?P\d+)$', SpectacleListView.as_view() , name ="bda-liste-spectacles"), url(r'^bda/spectacles/(?P\d+)/(?P\d+)$', "bda.views.spectacle", name = "bda-spectacle"), url(r'^bda/spectacles-ics/(?P\d+)$', 'bda.views.liste_spectacles_ics', name ="bda-liste-spectacles-ics"), - url(r'^bda/spectacles/unpaid(?P\d+)$', "bda.views.unpaid", name = "bda-unpaid"), - + url(r'^bda/spectacles/unpaid/(?P\d+)$', "bda.views.unpaid", name = "bda-unpaid"), url(r'^survey/(?P\d+)$', 'gestioncof.views.survey'), url(r'^event/(?P\d+)$', 'gestioncof.views.event'), url(r'^survey/(?P\d+)/status$', 'gestioncof.views.survey_status'), diff --git a/gestioncof/templates/utile_bda.html b/gestioncof/templates/utile_bda.html index 024b2f5f..5f4f383a 100644 --- a/gestioncof/templates/utile_bda.html +++ b/gestioncof/templates/utile_bda.html @@ -10,11 +10,14 @@
  • BdA diffusion
  • BdA revente
  • -

    Premier tirage

    +

    Tirages

    + {% for tirage in tirages %} +

    {{ tirage.title }}

    + {% endfor %} {% endblock %} diff --git a/gestioncof/views.py b/gestioncof/views.py index b90b5842..def84beb 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -504,7 +504,8 @@ def utile_cof(request): @buro_required def utile_bda(request): - return render(request, "utile_bda.html", {}) + tirages = Tirage.objects.all() + return render(request, "utile_bda.html", {'tirages': tirages}) @buro_required def liste_bdadiff(request):