interface de revente de places
This commit is contained in:
parent
ca39dc813b
commit
2aaf9f681e
2 changed files with 37 additions and 25 deletions
|
@ -1,26 +1,29 @@
|
||||||
{% extends "base_title.html" %}
|
{% extends "base_title.html" %}
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
|
|
||||||
{% block extra_head %}
|
|
||||||
<link type="text/css" rel="stylesheet" href="{% static "css/bda.css" %}" />
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block realcontent %}
|
{% block realcontent %}
|
||||||
|
|
||||||
<h1>Revente de place</h1>
|
<h1>Revente de place</h1>
|
||||||
<form action="" method="post" id="resellform">
|
{% if no_resell %}
|
||||||
|
<h2>Places non revendues</h2>
|
||||||
|
<form action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% if form.spectacle.errors %}<ul class="errorlist"><li>Sélectionnez un spetacle</li></ul>{% endif %}
|
<ol>
|
||||||
<p>
|
{% for attribution in no_resell %}
|
||||||
<pre>
|
<li>{{attribution.spectacle}} <input type="checkbox" name="resell" value="{{attribution.id}}"></li>
|
||||||
Bonjour,<br />
|
{% endfor %}
|
||||||
<br />
|
</ol>
|
||||||
Je souhaite revendre {{ form.count }} place(s) pour {{ form.spectacle }}.<br />
|
<input type="submit" value="Revendre les places sélectionnées">
|
||||||
Contactez-moi par email si vous êtes intéressé !<br />
|
</form>
|
||||||
<br />
|
{%endif%}
|
||||||
{{ user.get_full_name }} ({{ user.email }})
|
<h2>Places en cours de revente</h2>
|
||||||
</pre>
|
<form action="" method="post">
|
||||||
</p>
|
{% csrf_token %}
|
||||||
<input type="submit" value="Envoyer" />
|
<ol>
|
||||||
|
{% for attribution in resell %}
|
||||||
|
<li>{{attribution.spectacle}} <input type="checkbox" name="annul" value="{{attribution.id}}"></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
<input type="submit" value="Annuler les reventes sélectionnées">
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
25
bda/views.py
25
bda/views.py
|
@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.contrib import messages
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
|
@ -21,10 +22,10 @@ import time
|
||||||
|
|
||||||
from gestioncof.decorators import cof_required, buro_required
|
from gestioncof.decorators import cof_required, buro_required
|
||||||
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution,\
|
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution,\
|
||||||
Tirage, render_template
|
Tirage, render_template, SpectacleRevente
|
||||||
from bda.algorithm import Algorithm
|
from bda.algorithm import Algorithm
|
||||||
|
|
||||||
from bda.forms import BaseBdaFormSet, TokenForm, ResellForm
|
from bda.forms import BaseBdaFormSet, TokenForm
|
||||||
|
|
||||||
|
|
||||||
@cof_required
|
@cof_required
|
||||||
|
@ -302,13 +303,21 @@ def revente(request, tirage_id):
|
||||||
if not participant.paid:
|
if not participant.paid:
|
||||||
return render(request, "bda-notpaid.html", {})
|
return render(request, "bda-notpaid.html", {})
|
||||||
if request.POST:
|
if request.POST:
|
||||||
form = ResellForm(participant, request.POST)
|
for attr_id in request.POST.getlist('resell'):
|
||||||
if form.is_valid():
|
attribution = Attribution.objects.get(id=int(attr_id))
|
||||||
return do_resell(request, form)
|
revente = SpectacleRevente(attribution=attribution)
|
||||||
else:
|
revente.save()
|
||||||
form = ResellForm(participant)
|
for attr_id in request.POST.getlist('annul'):
|
||||||
|
revente = SpectacleRevente.objects.get(attribution__pk=attr_id)
|
||||||
|
revente.delete()
|
||||||
|
|
||||||
|
attributions = participant.attribution_set.filter(
|
||||||
|
spectacle__date__gte=timezone.now)
|
||||||
|
resell = attributions.filter(spectaclerevente__isnull=False)
|
||||||
|
no_resell = attributions.filter(spectaclerevente__isnull=True)
|
||||||
return render(request, "bda-revente.html",
|
return render(request, "bda-revente.html",
|
||||||
{"form": form, 'tirage': tirage})
|
{"participant": participant, 'tirage': tirage,
|
||||||
|
"resell": resell, "no_resell": no_resell})
|
||||||
|
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
|
|
Loading…
Reference in a new issue