Merge branch 'Aufinal/bda_shotgun' into 'master'

Aufinal/bda shotgun

Déplace les places disponibles immédiatement dans un lien à part

See merge request !94
This commit is contained in:
Martin Pepin 2016-10-13 16:12:02 +02:00
commit 816e395032
5 changed files with 43 additions and 13 deletions

View file

@ -0,0 +1,14 @@
{% extends "base_title.html" %}
{% block realcontent %}
<h2>Places disponibles immédiatement</h2>
{% if shotgun %}
<ul class="list-unstyled">
{% for spectacle in shotgun %}
<li><a href="{% url "bda-buy-revente" spectacle.id %}">{{spectacle}}</a></li>
{% endfor %}
{% else %}
<p> Pas de places disponibles immédiatement, désolé !</p>
{% endif %}
{% endblock %}

View file

@ -28,15 +28,6 @@
<input type="submit" class="btn btn-primary" value="S'inscrire pour les places sélectionnées"> <input type="submit" class="btn btn-primary" value="S'inscrire pour les places sélectionnées">
</form> </form>
{% if shotgun %}
<br>
<h3>Places disponibles immédiatement</h3>
<ul class="list-unstyled">
{% for spectacle in shotgun %}
<li><a href="{% url "bda-buy-revente" spectacle.id %}">{{spectacle}}</a></li>
{% endfor %}
{% endif %}
<script language="JavaScript"> <script language="JavaScript">
function select(check) { function select(check) {
checkboxes = document.getElementsByName("spectacles"); checkboxes = document.getElementsByName("spectacles");

View file

@ -33,14 +33,17 @@ urlpatterns = [
views.unpaid, views.unpaid,
name="bda-unpaid"), name="bda-unpaid"),
url(r'^liste-revente/(?P<tirage_id>\d+)$', url(r'^liste-revente/(?P<tirage_id>\d+)$',
"bda.views.list_revente", views.list_revente,
name="bda-liste-revente"), name="bda-liste-revente"),
url(r'^buy-revente/(?P<spectacle_id>\d+)$', url(r'^buy-revente/(?P<spectacle_id>\d+)$',
"bda.views.buy_revente", views.buy_revente,
name="bda-buy-revente"), name="bda-buy-revente"),
url(r'^revente-interested/(?P<revente_id>\d+)$', url(r'^revente-interested/(?P<revente_id>\d+)$',
"bda.views.revente_interested", views.revente_interested,
name='bda-revente-interested'), name='bda-revente-interested'),
url(r'^revente-immediat/(?P<tirage_id>\d+)$',
views.revente_shotgun,
name="bda-shotgun"),
url(r'^mails-rappel/(?P<spectacle_id>\d+)$', views.send_rappel), url(r'^mails-rappel/(?P<spectacle_id>\d+)$', views.send_rappel),
url(r'^descriptions/(?P<tirage_id>\d+)$', views.descriptions_spectacles, url(r'^descriptions/(?P<tirage_id>\d+)$', views.descriptions_spectacles,
name='bda-descriptions'), name='bda-descriptions'),

View file

@ -438,7 +438,7 @@ def buy_revente(request, spectacle_id):
if reventes.filter(seller=participant).exists(): if reventes.filter(seller=participant).exists():
revente = reventes.filter(seller=participant)[0] revente = reventes.filter(seller=participant)[0]
revente.delete() revente.delete()
return HttpResponseRedirect(reverse("bda-liste-revente", return HttpResponseRedirect(reverse("bda-shotgun",
args=[tirage.id])) args=[tirage.id]))
reventes_shotgun = [] reventes_shotgun = []
for revente in reventes.all(): for revente in reventes.all():
@ -473,6 +473,27 @@ Contacte-moi si tu es toujours intéressé·e !
"user": request.user}) "user": request.user})
@login_required
def revente_shotgun(request, tirage_id):
tirage = get_object_or_404(Tirage, id=tirage_id)
spectacles = tirage.spectacle_set.filter(
date__gte=timezone.now())
shotgun = []
for spectacle in spectacles:
revente_objects = SpectacleRevente.objects.filter(
attribution__spectacle=spectacle,
soldTo__isnull=True)
revente_count = 0
for revente in revente_objects:
if revente.shotgun:
revente_count += 1
if revente_count:
shotgun.append(spectacle)
return render(request, "bda-shotgun.html",
{"shotgun": shotgun})
@buro_required @buro_required
def spectacle(request, tirage_id, spectacle_id): def spectacle(request, tirage_id, spectacle_id):
tirage = get_object_or_404(Tirage, id=tirage_id) tirage = get_object_or_404(Tirage, id=tirage_id)

View file

@ -44,6 +44,7 @@
<li><a href="{% url "bda-places-attribuees" tirage.id %}">Mes places</a></li> <li><a href="{% url "bda-places-attribuees" tirage.id %}">Mes places</a></li>
<li><a href="{% url "bda-revente" tirage.id %}">Revendre une place</a></li> <li><a href="{% url "bda-revente" tirage.id %}">Revendre une place</a></li>
<li><a href="{% url "bda-liste-revente" tirage.id %}">S'inscrire à BdA-Revente</a></li> <li><a href="{% url "bda-liste-revente" tirage.id %}">S'inscrire à BdA-Revente</a></li>
<li><a href="{% url "bda-shotgun" tirage.id %}">Places disponibles immédiatement</a></li>
{% endif %} {% endif %}
</ul> </ul>
{% endfor %} {% endfor %}