forked from DGNum/gestioCOF
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:
commit
eb83c58f05
14 changed files with 363 additions and 188 deletions
215
bda/forms.py
215
bda/forms.py
|
@ -1,5 +1,6 @@
|
|||
from django import forms
|
||||
from django.forms.models import BaseInlineFormSet
|
||||
from django.template import loader
|
||||
from django.utils import timezone
|
||||
|
||||
from bda.models import Attribution, Spectacle, SpectacleRevente
|
||||
|
@ -38,142 +39,146 @@ class TokenForm(forms.Form):
|
|||
token = forms.CharField(widget=forms.widgets.Textarea())
|
||||
|
||||
|
||||
class AttributionModelMultipleChoiceField(forms.ModelMultipleChoiceField):
|
||||
def label_from_instance(self, obj):
|
||||
return str(obj.spectacle)
|
||||
class TemplateLabelField(forms.ModelMultipleChoiceField):
|
||||
"""
|
||||
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`
|
||||
"""
|
||||
|
||||
|
||||
class ReventeModelMultipleChoiceField(forms.ModelMultipleChoiceField):
|
||||
def __init__(self, *args, own=True, **kwargs):
|
||||
def __init__(
|
||||
self,
|
||||
label_template_name=None,
|
||||
context_object_name="obj",
|
||||
option_template_name=None,
|
||||
*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):
|
||||
label = "{show}{suffix}"
|
||||
suffix = ""
|
||||
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"
|
||||
if self.label_template_name is None:
|
||||
return super().label_from_instance(obj)
|
||||
else:
|
||||
# Ce n'est pas à nous : on ne voit jamais l'acheteur
|
||||
suffix = " -- Vendue par {firstname} {lastname}".format(
|
||||
firstname=obj.seller.user.first_name, lastname=obj.seller.user.last_name
|
||||
return loader.render_to_string(
|
||||
self.label_template_name, context={self.context_object_name: obj}
|
||||
)
|
||||
|
||||
return label.format(show=str(obj.attribution.spectacle), suffix=suffix)
|
||||
|
||||
# Formulaires pour revente_manage
|
||||
|
||||
|
||||
class ResellForm(forms.Form):
|
||||
attributions = AttributionModelMultipleChoiceField(
|
||||
label="",
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["attributions"].queryset = (
|
||||
participant.attribution_set.filter(spectacle__date__gte=timezone.now())
|
||||
self.fields["attributions"] = TemplateLabelField(
|
||||
queryset=participant.attribution_set.filter(
|
||||
spectacle__date__gte=timezone.now()
|
||||
)
|
||||
.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):
|
||||
reventes = ReventeModelMultipleChoiceField(
|
||||
own=True,
|
||||
label="",
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["reventes"].queryset = (
|
||||
participant.original_shows.filter(
|
||||
self.fields["reventes"] = TemplateLabelField(
|
||||
label="",
|
||||
queryset=participant.original_shows.filter(
|
||||
attribution__spectacle__date__gte=timezone.now(), soldTo__isnull=True
|
||||
)
|
||||
.select_related(
|
||||
"attribution__spectacle", "attribution__spectacle__location"
|
||||
)
|
||||
.order_by("-date")
|
||||
)
|
||||
|
||||
|
||||
class InscriptionReventeForm(forms.Form):
|
||||
spectacles = forms.ModelMultipleChoiceField(
|
||||
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")
|
||||
.order_by("-date"),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
required=False,
|
||||
label_template_name="bda/forms/revente_self_label_table.html",
|
||||
option_template_name="bda/forms/checkbox_table.html",
|
||||
context_object_name="revente",
|
||||
)
|
||||
|
||||
|
||||
class SoldForm(forms.Form):
|
||||
reventes = ReventeModelMultipleChoiceField(
|
||||
own=True,
|
||||
label="",
|
||||
queryset=Attribution.objects.none(),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["reventes"].queryset = (
|
||||
participant.original_shows.filter(soldTo__isnull=False)
|
||||
self.fields["reventes"] = TemplateLabelField(
|
||||
queryset=participant.original_shows.filter(soldTo__isnull=False)
|
||||
.exclude(soldTo=participant)
|
||||
.select_related(
|
||||
"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",
|
||||
)
|
||||
|
|
1
bda/templates/bda/forms/attribution_label_table.html
Normal file
1
bda/templates/bda/forms/attribution_label_table.html
Normal file
|
@ -0,0 +1 @@
|
|||
{% include 'bda/forms/spectacle_label_table.html' with spectacle=attribution.spectacle %}
|
4
bda/templates/bda/forms/checkbox_table.html
Normal file
4
bda/templates/bda/forms/checkbox_table.html
Normal 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>
|
1
bda/templates/bda/forms/date_tirage.html
Normal file
1
bda/templates/bda/forms/date_tirage.html
Normal file
|
@ -0,0 +1 @@
|
|||
<td data-sort-value="{{ revente.date_tirage | date:"U" }}">{{ revente.date_tirage }}</td>
|
3
bda/templates/bda/forms/revente_other_label_table.html
Normal file
3
bda/templates/bda/forms/revente_other_label_table.html
Normal 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' %}
|
2
bda/templates/bda/forms/revente_self_label_table.html
Normal file
2
bda/templates/bda/forms/revente_self_label_table.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
{% include 'bda/forms/spectacle_label_table.html' with spectacle=revente.attribution.spectacle %}
|
||||
{% include 'bda/forms/date_tirage.html' %}
|
4
bda/templates/bda/forms/revente_sold_label_table.html
Normal file
4
bda/templates/bda/forms/revente_sold_label_table.html
Normal 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 %}
|
4
bda/templates/bda/forms/spectacle_label_table.html
Normal file
4
bda/templates/bda/forms/spectacle_label_table.html
Normal 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>
|
|
@ -1,35 +1,45 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
|
||||
<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 />
|
||||
|
||||
<h3>Places non revendues</h3>
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
<div class="bg-info text-info center-block">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
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
|
||||
que les notifications soient envoyées aux intéressé·e·s.
|
||||
</div>
|
||||
<div class="bootstrap-form-reduce">
|
||||
{% csrf_token %}
|
||||
{{ resellform|bootstrap }}
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<input type="submit" class="btn btn-primary" name="resell" value="Revendre les places sélectionnées">
|
||||
</div>
|
||||
<div class="bg-info text-info center-block">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
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
|
||||
que les notifications soient envoyées aux intéressé·e·s.
|
||||
</div>
|
||||
{% csrf_token %}
|
||||
<table class="table table-striped stupidtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th data-sort="string">Titre</th>
|
||||
<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>
|
||||
|
||||
<hr />
|
||||
{% endif %}
|
||||
|
||||
{% if annul_reventes %}
|
||||
{% if annul_exists %}
|
||||
<h3>Places en cours de revente</h3>
|
||||
<form action="" method="post">
|
||||
<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.
|
||||
</div>
|
||||
{% csrf_token %}
|
||||
<div class='form-group'>
|
||||
<div class='multiple-checkbox'>
|
||||
<ul>
|
||||
{% for revente in annul_reventes %}
|
||||
<li>{{ revente.tag }} {{ revente.choice_label }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<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 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">
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
{% endif %}
|
||||
|
||||
{% if sold_reventes %}
|
||||
{% if sold_exists %}
|
||||
<h3>Places revendues</h3>
|
||||
<form action="" method="post">
|
||||
<div class="bg-info text-info center-block">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
Pour chaque revente, vous devez soit l'annuler soit la confirmer pour
|
||||
transférer la place la place à la personne tirée au sort.
|
||||
<div class="bg-info text-info center-block">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
Pour chaque revente, vous devez soit l'annuler soit la confirmer pour
|
||||
transférer la place la place à la personne tirée au sort.
|
||||
|
||||
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
|
||||
sort.
|
||||
</div>
|
||||
<div class="bootstrap-form-reduce">
|
||||
{% csrf_token %}
|
||||
{{ soldform|bootstrap }}
|
||||
</div>
|
||||
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
|
||||
sort.
|
||||
</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 à</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="reinit">Réinitialiser</button>
|
||||
</form>
|
||||
{% 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>
|
||||
{% 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 %}
|
||||
|
|
|
@ -2,11 +2,26 @@
|
|||
|
||||
{% block realcontent %}
|
||||
<h2>Places disponibles immédiatement</h2>
|
||||
{% if shotgun %}
|
||||
<ul class="list-unstyled">
|
||||
{% for spectacle in shotgun %}
|
||||
<li><a href="{% url "bda-revente-buy" spectacle.id %}">{{spectacle}}</a></li>
|
||||
{% endfor %}
|
||||
{% if spectacles %}
|
||||
<table class="table table-striped stupidtable" id="bda-shotgun">
|
||||
<thead>
|
||||
<tr>
|
||||
<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 %}
|
||||
<p> Pas de places disponibles immédiatement, désolé !</p>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles%}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>Inscriptions pour BdA-Revente</h2>
|
||||
<form action="" class="form-horizontal" method="post">
|
||||
<div class="bg-info text-info center-block">
|
||||
<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 />
|
||||
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
|
||||
|
@ -21,26 +21,45 @@
|
|||
<button type="button"
|
||||
class="btn btn-primary"
|
||||
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>
|
||||
<input type="submit"
|
||||
class="btn btn-primary"
|
||||
value="S'inscrire pour les places sélectionnées">
|
||||
</form>
|
||||
|
||||
<script type="text/javascript" src="{% static "js/joequery-Stupid-Table-Plugin/stupidtable.js" %}"></script>
|
||||
<script language="JavaScript">
|
||||
function select(check) {
|
||||
checkboxes = document.getElementsByName("spectacles");
|
||||
for(var i=0, n=checkboxes.length; i < n; i++) {
|
||||
checkboxes[i].checked = check;
|
||||
}
|
||||
}
|
||||
function select(check) {
|
||||
checkboxes = document.getElementsByName("spectacles");
|
||||
for(var i=0, n=checkboxes.length; i < n; i++) {
|
||||
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>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,45 +1,70 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
|
||||
<h2>Tirages au sort de reventes</h2>
|
||||
|
||||
{% if annulform.reventes %}
|
||||
{% if annul_exists %}
|
||||
<h3>Les reventes auxquelles vous êtes inscrit·e</h3>
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
<div class="bg-info text-info center-block">
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
Vous pouvez vous désinscrire des reventes suivantes tant que le tirage n'a
|
||||
pas eu lieu.
|
||||
</div>
|
||||
<div class="bootstrap-form-reduce">
|
||||
{% csrf_token %}
|
||||
{{ annulform|bootstrap }}
|
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||
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.
|
||||
</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">
|
||||
<input type="submit"
|
||||
class="btn btn-primary"
|
||||
name="annul"
|
||||
value="Se désinscrire des tirages sélectionnés">
|
||||
value="Se désister des tirages sélectionnés">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
{% endif %}
|
||||
|
||||
{% if subform.reventes %}
|
||||
<hr />
|
||||
|
||||
{% if sub_exists %}
|
||||
|
||||
<h3>Tirages en cours</h3>
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
<div class="bg-info text-info center-block">
|
||||
<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 class="bootstrap-form-reduce">
|
||||
{% csrf_token %}
|
||||
{{ subform|bootstrap }}
|
||||
</div>
|
||||
<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 subform.reventes %}{{ checkbox }}{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-actions">
|
||||
<input type="submit"
|
||||
class="btn btn-primary"
|
||||
|
@ -49,4 +74,27 @@
|
|||
</form>
|
||||
{% 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 %}
|
||||
|
|
25
bda/views.py
25
bda/views.py
|
@ -450,6 +450,10 @@ def revente_manage(request, tirage_id):
|
|||
new_date = timezone.now() - SpectacleRevente.remorse_time
|
||||
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(
|
||||
request,
|
||||
"bda/revente/manage.html",
|
||||
|
@ -458,6 +462,9 @@ def revente_manage(request, tirage_id):
|
|||
"soldform": soldform,
|
||||
"annulform": annulform,
|
||||
"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(
|
||||
request,
|
||||
"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
|
||||
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:
|
||||
messages.info(
|
||||
request,
|
||||
"Des reventes existent déjà pour certains de "
|
||||
"ces spectacles, vérifie les places "
|
||||
"ces spectacles, vérifiez les places "
|
||||
"disponibles sans tirage !",
|
||||
)
|
||||
if inscrit_revente:
|
||||
shows = map("<li>{!s}</li>".format, inscrit_revente)
|
||||
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))
|
||||
)
|
||||
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]
|
||||
|
||||
return render(request, "bda/revente/shotgun.html", {"shotgun": shotgun})
|
||||
return render(request, "bda/revente/shotgun.html", {"spectacles": shotgun})
|
||||
|
||||
|
||||
@buro_required
|
||||
|
|
|
@ -187,6 +187,18 @@ form.petit-cours_form .remove-btn {
|
|||
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 {
|
||||
background: #F0F0F0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue