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
25
bda/forms.py
25
bda/forms.py
|
@ -159,12 +159,13 @@ class InscriptionReventeForm(forms.Form):
|
||||||
|
|
||||||
|
|
||||||
class ReventeTirageAnnulForm(forms.Form):
|
class ReventeTirageAnnulForm(forms.Form):
|
||||||
reventes = ReventeModelMultipleChoiceField(
|
reventes = TemplateLabelField(
|
||||||
own=False,
|
|
||||||
label="",
|
|
||||||
queryset=SpectacleRevente.objects.none(),
|
queryset=SpectacleRevente.objects.none(),
|
||||||
widget=forms.CheckboxSelectMultiple,
|
widget=forms.CheckboxSelectMultiple,
|
||||||
required=False,
|
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):
|
def __init__(self, participant, *args, **kwargs):
|
||||||
|
@ -175,22 +176,22 @@ class ReventeTirageAnnulForm(forms.Form):
|
||||||
|
|
||||||
|
|
||||||
class ReventeTirageForm(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):
|
def __init__(self, participant, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields["reventes"].queryset = (
|
|
||||||
|
self.fields["reventes"] = TemplateLabelField(
|
||||||
|
queryset=(
|
||||||
SpectacleRevente.objects.filter(
|
SpectacleRevente.objects.filter(
|
||||||
notif_sent=True, shotgun=False, tirage_done=False
|
notif_sent=True, shotgun=False, tirage_done=False
|
||||||
)
|
)
|
||||||
.exclude(confirmed_entry=participant)
|
.exclude(confirmed_entry=participant)
|
||||||
.select_related("attribution__spectacle")
|
.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" %}
|
{% 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">
|
<p>
|
||||||
<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.
|
||||||
Vous pouvez vous désinscrire des reventes suivantes tant que le tirage n'a
|
</p>
|
||||||
pas eu lieu.
|
|
||||||
</div>
|
|
||||||
<div class="bootstrap-form-reduce">
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ annulform|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 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 +73,12 @@
|
||||||
</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 %}
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% 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(
|
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},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue