Merge branch 'Aufinal/prettify-revente' into 'master'

Rend BdA-Revente un peu plus joli

See merge request klub-dev-ens/gestioCOF!338
This commit is contained in:
Martin Pepin 2019-01-13 14:29:48 +01:00
commit eb83c58f05
14 changed files with 363 additions and 188 deletions

View file

@ -1,5 +1,6 @@
from django import forms from django import forms
from django.forms.models import BaseInlineFormSet from django.forms.models import BaseInlineFormSet
from django.template import loader
from django.utils import timezone from django.utils import timezone
from bda.models import Attribution, Spectacle, SpectacleRevente from bda.models import Attribution, Spectacle, SpectacleRevente
@ -38,142 +39,146 @@ class TokenForm(forms.Form):
token = forms.CharField(widget=forms.widgets.Textarea()) token = forms.CharField(widget=forms.widgets.Textarea())
class AttributionModelMultipleChoiceField(forms.ModelMultipleChoiceField): class TemplateLabelField(forms.ModelMultipleChoiceField):
def label_from_instance(self, obj): """
return str(obj.spectacle) Extends ModelMultipleChoiceField to offer two more customization options :
- `label_from_instance` can be used with a template file
- the widget rendering template can be specified with `option_template_name`
"""
def __init__(
class ReventeModelMultipleChoiceField(forms.ModelMultipleChoiceField): self,
def __init__(self, *args, own=True, **kwargs): label_template_name=None,
context_object_name="obj",
option_template_name=None,
*args,
**kwargs
):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.own = own self.label_template_name = label_template_name
self.context_object_name = context_object_name
if option_template_name is not None:
self.widget.option_template_name = option_template_name
def label_from_instance(self, obj): def label_from_instance(self, obj):
label = "{show}{suffix}" if self.label_template_name is None:
suffix = "" return super().label_from_instance(obj)
if self.own:
# C'est notre propre revente : informations sur le statut
if obj.soldTo is not None:
suffix = " -- Vendue à {firstname} {lastname}".format(
firstname=obj.soldTo.user.first_name,
lastname=obj.soldTo.user.last_name,
)
elif obj.shotgun:
suffix = " -- Tirage infructueux"
elif obj.notif_sent:
suffix = " -- Inscriptions au tirage en cours"
else: else:
# Ce n'est pas à nous : on ne voit jamais l'acheteur return loader.render_to_string(
suffix = " -- Vendue par {firstname} {lastname}".format( self.label_template_name, context={self.context_object_name: obj}
firstname=obj.seller.user.first_name, lastname=obj.seller.user.last_name
) )
return label.format(show=str(obj.attribution.spectacle), suffix=suffix)
# Formulaires pour revente_manage
class ResellForm(forms.Form): class ResellForm(forms.Form):
attributions = AttributionModelMultipleChoiceField(
label="",
queryset=Attribution.objects.none(),
widget=forms.CheckboxSelectMultiple,
required=False,
)
def __init__(self, participant, *args, **kwargs): def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["attributions"].queryset = ( self.fields["attributions"] = TemplateLabelField(
participant.attribution_set.filter(spectacle__date__gte=timezone.now()) queryset=participant.attribution_set.filter(
spectacle__date__gte=timezone.now()
)
.exclude(revente__seller=participant) .exclude(revente__seller=participant)
.select_related("spectacle", "spectacle__location", "participant__user") .select_related("spectacle", "spectacle__location", "participant__user"),
widget=forms.CheckboxSelectMultiple,
required=False,
label_template_name="bda/forms/attribution_label_table.html",
option_template_name="bda/forms/checkbox_table.html",
context_object_name="attribution",
) )
class AnnulForm(forms.Form): class AnnulForm(forms.Form):
reventes = ReventeModelMultipleChoiceField(
own=True,
label="",
queryset=Attribution.objects.none(),
widget=forms.CheckboxSelectMultiple,
required=False,
)
def __init__(self, participant, *args, **kwargs): def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["reventes"].queryset = ( self.fields["reventes"] = TemplateLabelField(
participant.original_shows.filter( label="",
queryset=participant.original_shows.filter(
attribution__spectacle__date__gte=timezone.now(), soldTo__isnull=True attribution__spectacle__date__gte=timezone.now(), soldTo__isnull=True
) )
.select_related( .select_related(
"attribution__spectacle", "attribution__spectacle__location" "attribution__spectacle", "attribution__spectacle__location"
) )
.order_by("-date") .order_by("-date"),
) widget=forms.CheckboxSelectMultiple,
required=False,
label_template_name="bda/forms/revente_self_label_table.html",
class InscriptionReventeForm(forms.Form): option_template_name="bda/forms/checkbox_table.html",
spectacles = forms.ModelMultipleChoiceField( context_object_name="revente",
queryset=Spectacle.objects.none(),
widget=forms.CheckboxSelectMultiple,
required=False,
)
def __init__(self, tirage, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["spectacles"].queryset = tirage.spectacle_set.select_related(
"location"
).filter(date__gte=timezone.now())
class ReventeTirageAnnulForm(forms.Form):
reventes = ReventeModelMultipleChoiceField(
own=False,
label="",
queryset=SpectacleRevente.objects.none(),
widget=forms.CheckboxSelectMultiple,
required=False,
)
def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["reventes"].queryset = participant.entered.filter(
soldTo__isnull=True
).select_related("attribution__spectacle", "seller__user")
class ReventeTirageForm(forms.Form):
reventes = ReventeModelMultipleChoiceField(
own=False,
label="",
queryset=SpectacleRevente.objects.none(),
widget=forms.CheckboxSelectMultiple,
required=False,
)
def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["reventes"].queryset = (
SpectacleRevente.objects.filter(
notif_sent=True, shotgun=False, tirage_done=False
)
.exclude(confirmed_entry=participant)
.select_related("attribution__spectacle")
) )
class SoldForm(forms.Form): class SoldForm(forms.Form):
reventes = ReventeModelMultipleChoiceField(
own=True,
label="",
queryset=Attribution.objects.none(),
widget=forms.CheckboxSelectMultiple,
)
def __init__(self, participant, *args, **kwargs): def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["reventes"].queryset = ( self.fields["reventes"] = TemplateLabelField(
participant.original_shows.filter(soldTo__isnull=False) queryset=participant.original_shows.filter(soldTo__isnull=False)
.exclude(soldTo=participant) .exclude(soldTo=participant)
.select_related( .select_related(
"attribution__spectacle", "attribution__spectacle__location" "attribution__spectacle", "attribution__spectacle__location"
) ),
widget=forms.CheckboxSelectMultiple,
label_template_name="bda/forms/revente_sold_label_table.html",
option_template_name="bda/forms/checkbox_table.html",
context_object_name="revente",
)
# Formulaire pour revente_subscribe
class InscriptionReventeForm(forms.Form):
def __init__(self, tirage, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["spectacles"] = TemplateLabelField(
queryset=tirage.spectacle_set.select_related("location").filter(
date__gte=timezone.now()
),
widget=forms.CheckboxSelectMultiple,
required=False,
label_template_name="bda/forms/spectacle_label_table.html",
option_template_name="bda/forms/checkbox_table.html",
context_object_name="spectacle",
)
# Formulaires pour revente_tirages
class ReventeTirageAnnulForm(forms.Form):
def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["reventes"] = TemplateLabelField(
queryset=participant.entered.filter(soldTo__isnull=True).select_related(
"attribution__spectacle", "seller__user"
),
widget=forms.CheckboxSelectMultiple,
required=False,
label_template_name="bda/forms/revente_other_label_table.html",
option_template_name="bda/forms/checkbox_table.html",
context_object_name="revente",
)
class ReventeTirageForm(forms.Form):
def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["reventes"] = TemplateLabelField(
queryset=(
SpectacleRevente.objects.filter(
notif_sent=True,
shotgun=False,
tirage_done=False,
attribution__spectacle__tirage=participant.tirage,
)
.exclude(confirmed_entry=participant)
.select_related("attribution__spectacle")
),
widget=forms.CheckboxSelectMultiple,
required=False,
label_template_name="bda/forms/revente_other_label_table.html",
option_template_name="bda/forms/checkbox_table.html",
context_object_name="revente",
) )

View file

@ -0,0 +1 @@
{% include 'bda/forms/spectacle_label_table.html' with spectacle=attribution.spectacle %}

View file

@ -0,0 +1,4 @@
<tr>
<td><input type="{{ widget.type }}" name="{{ widget.name }}" {% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %}></td>
{{ widget.label }}
</tr>

View file

@ -0,0 +1 @@
<td data-sort-value="{{ revente.date_tirage | date:"U" }}">{{ revente.date_tirage }}</td>

View file

@ -0,0 +1,3 @@
{% include 'bda/forms/spectacle_label_table.html' with spectacle=revente.attribution.spectacle %}
{% with user=revente.seller.user %} <td>{{user.first_name}} {{user.last_name}}</td> {% endwith%}
{% include 'bda/forms/date_tirage.html' %}

View file

@ -0,0 +1,2 @@
{% include 'bda/forms/spectacle_label_table.html' with spectacle=revente.attribution.spectacle %}
{% include 'bda/forms/date_tirage.html' %}

View file

@ -0,0 +1,4 @@
{% include 'bda/forms/spectacle_label_table.html' with spectacle=revente.attribution.spectacle %}
{% with user=revente.soldTo.user %}
<td><a href="mailto:{{ user.email }}">{{user.first_name}} {{user.last_name}}</a></td>
{% endwith %}

View file

@ -0,0 +1,4 @@
<td>{{ spectacle.title }}</td>
<td data-sort-value="{{ spectacle.timestamp }}">{{ spectacle.date }}</td>
<td data-sort-value="{{ spectacle.location }}">{{ spectacle.location }}</td>
<td data-sort-value="{{ spectacle.price |stringformat:".3f" }}">{{ spectacle.price |floatformat }}€</td>

View file

@ -1,35 +1,45 @@
{% extends "base_title.html" %} {% extends "base_title.html" %}
{% load bootstrap %} {% load staticfiles %}
{% block realcontent %} {% block realcontent %}
<h2>Gestion des places que je revends</h2> <h2>Gestion des places que je revends</h2>
{% with resell_attributions=resellform.attributions annul_reventes=annulform.reventes sold_reventes=soldform.reventes %}
{% if resell_attributions %} {% if resell_exists %}
<br /> <br />
<h3>Places non revendues</h3> <h3>Places non revendues</h3>
<form class="form-horizontal" action="" method="post"> <form class="form-horizontal" action="" method="post">
<div class="bg-info text-info center-block"> <div class="bg-info text-info center-block">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
Cochez les places que vous souhaitez revendre, et validez. Vous aurez Cochez les places que vous souhaitez revendre, et validez. Vous aurez
ensuite 1h pour changer d'avis avant que la revente soit confirmée et ensuite 1h pour changer d'avis avant que la revente soit confirmée et
que les notifications soient envoyées aux intéressé·e·s. que les notifications soient envoyées aux intéressé·e·s.
</div> </div>
<div class="bootstrap-form-reduce"> {% csrf_token %}
{% csrf_token %} <table class="table table-striped stupidtable">
{{ resellform|bootstrap }} <thead>
</div> <tr>
<div class="form-actions"> <th></th>
<input type="submit" class="btn btn-primary" name="resell" value="Revendre les places sélectionnées"> <th data-sort="string">Titre</th>
</div> <th data-sort="string">Lieu</th>
<th data-sort="int">Date</th>
<th data-sort="int">Prix</th>
</tr>
</thead>
<tbody>
{% for checkbox in resellform.attributions %}{{ checkbox }}{% endfor %}
</tbody>
</table>
<div class="form-actions">
<input type="submit" class="btn btn-primary" name="resell" value="Revendre les places sélectionnées">
</div>
</form> </form>
<hr /> <hr />
{% endif %} {% endif %}
{% if annul_reventes %} {% if annul_exists %}
<h3>Places en cours de revente</h3> <h3>Places en cours de revente</h3>
<form action="" method="post"> <form action="" method="post">
<div class="bg-info text-info center-block"> <div class="bg-info text-info center-block">
@ -37,44 +47,76 @@
Vous pouvez annuler les reventes qui n'ont pas encore trouvé preneur·se. Vous pouvez annuler les reventes qui n'ont pas encore trouvé preneur·se.
</div> </div>
{% csrf_token %} {% csrf_token %}
<div class='form-group'> <table class="table table-striped stupidtable">
<div class='multiple-checkbox'> <thead>
<ul> <tr>
{% for revente in annul_reventes %} <th></th>
<li>{{ revente.tag }} {{ revente.choice_label }}</li> <th data-sort="string">Titre</th>
{% endfor %} <th data-sort="int">Date</th>
</ul> <th data-sort="string">Lieu</th>
</div> <th data-sort="int">Prix</th>
</div> <th data-sort="int">Tirage le</th>
</tr>
</thead>
<tbody>
{% for checkbox in annulform.reventes %}{{ checkbox }}{% endfor %}
</tbody>
</table>
<input type="submit" class="btn btn-primary" name="annul" value="Annuler les reventes sélectionnées"> <input type="submit" class="btn btn-primary" name="annul" value="Annuler les reventes sélectionnées">
</form> </form>
<hr /> <hr />
{% endif %} {% endif %}
{% if sold_reventes %} {% if sold_exists %}
<h3>Places revendues</h3> <h3>Places revendues</h3>
<form action="" method="post"> <form action="" method="post">
<div class="bg-info text-info center-block"> <div class="bg-info text-info center-block">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
Pour chaque revente, vous devez soit l'annuler soit la confirmer pour Pour chaque revente, vous devez soit l'annuler soit la confirmer pour
transférer la place la place à la personne tirée au sort. transférer la place la place à la personne tirée au sort.
L'annulation sert par exemple à pouvoir remettre la place en jeu si L'annulation sert par exemple à pouvoir remettre la place en jeu si
vous ne parvenez pas à entrer en contact avec la personne tirée au vous ne parvenez pas à entrer en contact avec la personne tirée au
sort. sort.
</div> </div>
<div class="bootstrap-form-reduce"> {% csrf_token %}
{% csrf_token %} <table class="table table-striped stupidtable">
{{ soldform|bootstrap }} <thead>
</div> <tr>
<th></th>
<th data-sort="string">Titre</th>
<th data-sort="int">Date</th>
<th data-sort="string">Lieu</th>
<th data-sort="int">Prix</th>
<th>Vendue à</th>
</tr>
</thead>
<tbody>
{% for checkbox in soldform.reventes %}{{ checkbox }}{% endfor %}
</tbody>
</table>
<button type="submit" class="btn btn-primary" name="transfer">Transférer</button> <button type="submit" class="btn btn-primary" name="transfer">Transférer</button>
<button type="submit" class="btn btn-primary" name="reinit">Réinitialiser</button> <button type="submit" class="btn btn-primary" name="reinit">Réinitialiser</button>
</form> </form>
{% endif %} {% endif %}
{% if not resell_attributions and not annul_reventes and not sold_reventes %} {% if not resell_exists and not annul_exists and not sold_exists %}
<p>Plus de reventes possibles !</p> <p>Plus de reventes possibles !</p>
{% endif %} {% endif %}
{% endwith %} <script type="text/javascript" src="{% static "js/joequery-Stupid-Table-Plugin/stupidtable.js" %}"></script>
<script language="JavaScript">
$(function(){
$("table.stupidtable").stupidtable();
});
$("tr").click(function() {
$(this).find("input[type=checkbox]").click()
});
$("input[type=checkbox]").click(function(e) {
e.stopPropagation();
});
</script>
{% endblock %} {% endblock %}

View file

@ -2,11 +2,26 @@
{% block realcontent %} {% block realcontent %}
<h2>Places disponibles immédiatement</h2> <h2>Places disponibles immédiatement</h2>
{% if shotgun %} {% if spectacles %}
<ul class="list-unstyled"> <table class="table table-striped stupidtable" id="bda-shotgun">
{% for spectacle in shotgun %} <thead>
<li><a href="{% url "bda-revente-buy" spectacle.id %}">{{spectacle}}</a></li> <tr>
{% endfor %} <th data-sort="string">Titre</th>
<th data-sort="int">Date</th>
<th data-sort="string">Lieu</th>
<th data-sort="int">Prix</th>
<th></th>
</tr>
</thead>
<tbody>
{% for spectacle in spectacles %}
<tr>
{% include "bda/forms/spectacle_label_table.html" with spectacle=spectacle %}
<td class="button"><a role="button" class="btn btn-primary" href="{% url 'bda-revente-buy' spectacle.id %}">Racheter</a>
</tr>
{% endfor %}
</tbody>
</table>
{% else %} {% else %}
<p> Pas de places disponibles immédiatement, désolé !</p> <p> Pas de places disponibles immédiatement, désolé !</p>
{% endif %} {% endif %}

View file

@ -1,12 +1,12 @@
{% extends "base_title.html" %} {% extends "base_title.html" %}
{% load bootstrap %} {% load staticfiles%}
{% block realcontent %} {% block realcontent %}
<h2>Inscriptions pour BdA-Revente</h2> <h2>Inscriptions pour BdA-Revente</h2>
<form action="" class="form-horizontal" method="post"> <form action="" class="form-horizontal" method="post">
<div class="bg-info text-info center-block"> <div class="bg-info text-info center-block">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
Cochez les spectacles pour lesquels vous souhaitez recevoir un Cochez les spectacles pour lesquels vous souhaitez recevoir une
notification quand une place est disponible en revente. <br /> notification quand une place est disponible en revente. <br />
Lorsque vous validez vos choix, si un tirage au sort est en cours pour Lorsque vous validez vos choix, si un tirage au sort est en cours pour
un des spectacles que vous avez sélectionné, vous serez automatiquement un des spectacles que vous avez sélectionné, vous serez automatiquement
@ -21,26 +21,45 @@
<button type="button" <button type="button"
class="btn btn-primary" class="btn btn-primary"
onClick="select(false)">Tout désélectionner</button> onClick="select(false)">Tout désélectionner</button>
<table class="table table-striped stupidtable">
<thead>
<tr>
<th></th>
<th data-sort="string">Titre</th>
<th data-sort="int">Date</th>
<th data-sort="string">Lieu</th>
<th data-sort="int">Prix</th>
</tr>
</thead>
<tbody>
{% for checkbox in form.spectacles %}{{ checkbox }}{% endfor %}
</tbody>
</table>
<div class="multiple-checkbox">
<ul>
{% for checkbox in form.spectacles %}
<li>{{ checkbox }}</li>
{% endfor %}
</ul>
</div>
</div> </div>
<input type="submit" <input type="submit"
class="btn btn-primary" class="btn btn-primary"
value="S'inscrire pour les places sélectionnées"> value="S'inscrire pour les places sélectionnées">
</form> </form>
<script type="text/javascript" src="{% static "js/joequery-Stupid-Table-Plugin/stupidtable.js" %}"></script>
<script language="JavaScript"> <script language="JavaScript">
function select(check) { function select(check) {
checkboxes = document.getElementsByName("spectacles"); checkboxes = document.getElementsByName("spectacles");
for(var i=0, n=checkboxes.length; i < n; i++) { for(var i=0, n=checkboxes.length; i < n; i++) {
checkboxes[i].checked = check; checkboxes[i].checked = check;
} }
} }
$(function(){
$("table.stupidtable").stupidtable();
});
$("tr").click(function() {
$(this).find("input[type=checkbox]").click()
});
$("input[type=checkbox]").click(function(e) {
e.stopPropagation();
});
</script> </script>
{% endblock %} {% endblock %}

View file

@ -1,45 +1,70 @@
{% extends "base_title.html" %} {% extends "base_title.html" %}
{% load bootstrap %} {% load staticfiles %}
{% block realcontent %} {% block realcontent %}
<h2>Tirages au sort de reventes</h2> <h2>Tirages au sort de reventes</h2>
{% if annulform.reventes %} {% if annul_exists %}
<h3>Les reventes auxquelles vous êtes inscrit·e</h3> <h3>Les reventes auxquelles vous êtes inscrit·e</h3>
<form class="form-horizontal" action="" method="post"> <form class="form-horizontal" action="" method="post">
<div class="bg-info text-info center-block"> <div class="bg-info text-info center-block">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
Vous pouvez vous désinscrire des reventes suivantes tant que le tirage n'a Voici la liste des reventes auxquelles vous êtes inscrit·e ; si vous ne souhaitez plus participer au tirage au sort vous pouvez vous en désister.
pas eu lieu.
</div>
<div class="bootstrap-form-reduce">
{% csrf_token %}
{{ annulform|bootstrap }}
</div> </div>
{% csrf_token %}
<table class="table table-striped stupidtable">
<thead>
<tr>
<th></th>
<th data-sort="string">Titre</th>
<th data-sort="int">Date</th>
<th data-sort="string">Lieu</th>
<th data-sort="int">Prix</th>
<th>Vendue par</th>
<th data-sort="int">Tirage le</th>
</tr>
</thead>
<tbody>
{% for checkbox in annulform.reventes %}{{ checkbox }}{% endfor %}
</tbody>
</table>
<div class="form-actions"> <div class="form-actions">
<input type="submit" <input type="submit"
class="btn btn-primary" class="btn btn-primary"
name="annul" name="annul"
value="Se désinscrire des tirages sélectionnés"> value="Se désister des tirages sélectionnés">
</div> </div>
</form> </form>
<hr />
{% endif %} {% endif %}
{% if subform.reventes %} <hr />
{% if sub_exists %}
<h3>Tirages en cours</h3> <h3>Tirages en cours</h3>
<form class="form-horizontal" action="" method="post"> <form class="form-horizontal" action="" method="post">
<div class="bg-info text-info center-block"> <div class="bg-info text-info center-block">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
Vous pouvez vous inscrire aux tirage en cours suivants. Vous pouvez vous inscrire aux tirages en cours suivants.
</div> </div>
<div class="bootstrap-form-reduce">
{% csrf_token %} {% csrf_token %}
{{ subform|bootstrap }} <table class="table table-striped stupidtable">
</div> <thead>
<tr>
<th></th>
<th data-sort="string">Titre</th>
<th data-sort="int">Date</th>
<th data-sort="string">Lieu</th>
<th data-sort="int">Prix</th>
<th>Vendue par</th>
<th data-sort="int">Tirage le</th>
</tr>
</thead>
<tbody>
{% for checkbox in subform.reventes %}{{ checkbox }}{% endfor %}
</tbody>
</table>
<div class="form-actions"> <div class="form-actions">
<input type="submit" <input type="submit"
class="btn btn-primary" class="btn btn-primary"
@ -49,4 +74,27 @@
</form> </form>
{% endif %} {% endif %}
{% if not annul_exists and not sub_exists %}
<div class="bg-info text-info center-block">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
Aucune revente n'est active pour le moment !
</div>
{% endif %}
<script type="text/javascript" src="{% static "js/joequery-Stupid-Table-Plugin/stupidtable.js" %}"></script>
<script language="JavaScript">
$(function(){
$("table.stupidtable").stupidtable();
});
$("tr").click(function() {
$(this).find("input[type=checkbox]").click()
});
$("input[type=checkbox]").click(function(e) {
e.stopPropagation();
});
</script>
{% endblock %} {% endblock %}

View file

@ -450,6 +450,10 @@ def revente_manage(request, tirage_id):
new_date = timezone.now() - SpectacleRevente.remorse_time new_date = timezone.now() - SpectacleRevente.remorse_time
revente.reset(new_date=new_date) revente.reset(new_date=new_date)
sold_exists = soldform.fields["reventes"].queryset.exists()
annul_exists = annulform.fields["reventes"].queryset.exists()
resell_exists = resellform.fields["attributions"].queryset.exists()
return render( return render(
request, request,
"bda/revente/manage.html", "bda/revente/manage.html",
@ -458,6 +462,9 @@ def revente_manage(request, tirage_id):
"soldform": soldform, "soldform": soldform,
"annulform": annulform, "annulform": annulform,
"resellform": resellform, "resellform": resellform,
"sold_exists": sold_exists,
"annul_exists": annul_exists,
"resell_exists": resell_exists,
}, },
) )
@ -505,10 +512,18 @@ def revente_tirages(request, tirage_id):
), ),
) )
annul_exists = annulform.fields["reventes"].queryset.exists()
sub_exists = subform.fields["reventes"].queryset.exists()
return render( return render(
request, request,
"bda/revente/tirages.html", "bda/revente/tirages.html",
{"annulform": annulform, "subform": subform}, {
"annulform": annulform,
"subform": subform,
"annul_exists": annul_exists,
"sub_exists": sub_exists,
},
) )
@ -574,18 +589,18 @@ def revente_subscribe(request, tirage_id):
) )
# Messages # Messages
if success: if success:
messages.success(request, "Ton inscription a bien été prise en compte") messages.success(request, "Votre inscription a bien été prise en compte")
if deja_revente: if deja_revente:
messages.info( messages.info(
request, request,
"Des reventes existent déjà pour certains de " "Des reventes existent déjà pour certains de "
"ces spectacles, vérifie les places " "ces spectacles, vérifiez les places "
"disponibles sans tirage !", "disponibles sans tirage !",
) )
if inscrit_revente: if inscrit_revente:
shows = map("<li>{!s}</li>".format, inscrit_revente) shows = map("<li>{!s}</li>".format, inscrit_revente)
msg = ( msg = (
"Tu as été inscrit à des reventes en cours pour les spectacles " "Vous avez été inscrit·e à des reventes en cours pour les spectacles "
"<ul>{:s}</ul>".format("\n".join(shows)) "<ul>{:s}</ul>".format("\n".join(shows))
) )
messages.info(request, msg, extra_tags="safe") messages.info(request, msg, extra_tags="safe")
@ -662,7 +677,7 @@ def revente_shotgun(request, tirage_id):
) )
shotgun = [sp for sp in spectacles if len(sp.shotguns) > 0] shotgun = [sp for sp in spectacles if len(sp.shotguns) > 0]
return render(request, "bda/revente/shotgun.html", {"shotgun": shotgun}) return render(request, "bda/revente/shotgun.html", {"spectacles": shotgun})
@buro_required @buro_required

View file

@ -187,6 +187,18 @@ form.petit-cours_form .remove-btn {
margin-top : 10px; margin-top : 10px;
} }
table#bda-shotgun td {
padding: 14px;
}
table#bda-shotgun td.button {
padding: 8px;
}
table#bda-shotgun a, table#bda-shotgun a:hover {
color: #FFF
}
tr.dynamic-form td { tr.dynamic-form td {
background: #F0F0F0; background: #F0F0F0;
} }