forked from DGNum/gestioCOF
gère les places demandées
This commit is contained in:
parent
a607f35342
commit
e9e0be7960
4 changed files with 59 additions and 1 deletions
|
@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
import calendar
|
import calendar
|
||||||
import datetime
|
import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
@ -256,3 +257,34 @@ class SpectacleRevente(models.Model):
|
||||||
|
|
||||||
connection = mail.get_connection()
|
connection = mail.get_connection()
|
||||||
connection.send_messages(mails_to_send)
|
connection.send_messages(mails_to_send)
|
||||||
|
|
||||||
|
def tirage(self):
|
||||||
|
inscrits = self.interested
|
||||||
|
spectacle = self.attribution.spectacle
|
||||||
|
user = self.attribution.participant.user
|
||||||
|
if inscrits.exists():
|
||||||
|
idx = random.randint(0, inscrits.count() - 1)
|
||||||
|
winner = inscrits.all()[idx]
|
||||||
|
self.soldTo = winner
|
||||||
|
mail_buyer = """Bonjour,
|
||||||
|
|
||||||
|
Tu as été tiré-e au sort pour racheter une place pour %s le %s (%s) à %0.02f€.
|
||||||
|
Tu peux contacter le vendeur à l'adresse %s.
|
||||||
|
|
||||||
|
Chaleureusement,
|
||||||
|
Le BdA""" % (spectacle.title, spectacle.date_no_seconds(),
|
||||||
|
spectacle.location, spectacle.price, user.email)
|
||||||
|
|
||||||
|
mail.send_mail("BdA-Revente : %s" % spectacle.title,
|
||||||
|
mail_buyer, "bda@ens.fr", [winner.user.email],
|
||||||
|
fail_silently=False)
|
||||||
|
mail_seller = """Bonjour,
|
||||||
|
La personne tirée au sort pour racheter ta place pour %s est %s.
|
||||||
|
Tu peux le/la contacter à l'adresse %s.
|
||||||
|
|
||||||
|
Chaleureusement,
|
||||||
|
Le BdA""" % (spectacle.title, winner.user.get_full_name(), winner.user.email)
|
||||||
|
|
||||||
|
mail.send_mail("BdA-Revente : %s" % spectacle.title,
|
||||||
|
mail_seller, "bda@ens.fr", [user.email],
|
||||||
|
fail_silently=False)
|
||||||
|
|
9
bda/templates/bda-interested.html
Normal file
9
bda/templates/bda-interested.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{% extends "base_title.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
|
||||||
|
{% block realcontent %}
|
||||||
|
<h2>Inscription à une revente</h2>
|
||||||
|
<p class="success"> Votre inscription pour a bien été enregistrée !</p>
|
||||||
|
<p>Le tirage au sort pour cette revente ({{spectacle}}) sera effectué le {{date}}.
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -38,6 +38,9 @@ urlpatterns = [
|
||||||
url(r'^buy-revente/(?P<spectacle_id>\d+)$',
|
url(r'^buy-revente/(?P<spectacle_id>\d+)$',
|
||||||
"bda.views.buy_revente",
|
"bda.views.buy_revente",
|
||||||
name="bda-buy-revente"),
|
name="bda-buy-revente"),
|
||||||
|
url(r'^revente-interested/(?P<revente_id>\d+)$',
|
||||||
|
"bda.views.revente_interested",
|
||||||
|
name='bda-revente-interested'),
|
||||||
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'),
|
||||||
|
|
14
bda/views.py
14
bda/views.py
|
@ -318,6 +318,20 @@ def revente(request, tirage_id):
|
||||||
"annulform": annulform, "resellform": resellform})
|
"annulform": annulform, "resellform": resellform})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def revente_interested(request, revente_id):
|
||||||
|
revente = get_object_or_404(SpectacleRevente, id=revente_id)
|
||||||
|
participant, created = Participant.objects.get_or_create(
|
||||||
|
user=request.user, tirage=revente.attribution.spectacle.tirage)
|
||||||
|
if timezone.now() < revente.date + timedelta(hours=1) or revente.shotgun:
|
||||||
|
return render(request, "bda-wrongtime.html", {})
|
||||||
|
|
||||||
|
revente.interested.add(participant)
|
||||||
|
return render(request, "bda-interested.html",
|
||||||
|
{"spectacle": revente.attribution.spectacle,
|
||||||
|
"date": revente.expiration_time})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def list_revente(request, tirage_id):
|
def list_revente(request, tirage_id):
|
||||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||||
|
|
Loading…
Reference in a new issue