forked from DGNum/gestioCOF
Prettify revente/tirages
This commit is contained in:
parent
625825cf3f
commit
5c8164dd3b
4 changed files with 81 additions and 37 deletions
35
bda/forms.py
35
bda/forms.py
|
@ -159,12 +159,13 @@ class InscriptionReventeForm(forms.Form):
|
|||
|
||||
|
||||
class ReventeTirageAnnulForm(forms.Form):
|
||||
reventes = ReventeModelMultipleChoiceField(
|
||||
own=False,
|
||||
label="",
|
||||
reventes = TemplateLabelField(
|
||||
queryset=SpectacleRevente.objects.none(),
|
||||
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",
|
||||
)
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
|
@ -175,22 +176,22 @@ class ReventeTirageAnnulForm(forms.Form):
|
|||
|
||||
|
||||
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")
|
||||
|
||||
self.fields["reventes"] = TemplateLabelField(
|
||||
queryset=(
|
||||
SpectacleRevente.objects.filter(
|
||||
notif_sent=True, shotgun=False, tirage_done=False
|
||||
)
|
||||
.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",
|
||||
)
|
||||
|
||||
|
||||
|
|
8
bda/templates/bda/forms/revente_other_label_table.html
Normal file
8
bda/templates/bda/forms/revente_other_label_table.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% with spectacle=revente.attribution.spectacle user=revente.seller.user %}
|
||||
<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>
|
||||
<td>{{user.first_name}} {{user.last_name}}</td>
|
||||
<td data-sort-value="{{ revente.date_tirage | date:"U" }}">{{ revente.date_tirage }}</td>
|
||||
{% endwith %}
|
|
@ -1,45 +1,69 @@
|
|||
{% 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 }}
|
||||
</div>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
{% 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 +73,12 @@
|
|||
</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 %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -500,10 +500,13 @@ 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},
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue