Prettify revente/manage

This commit is contained in:
Ludovic Stephan 2019-01-07 16:24:30 +01:00
parent 010ce0df3e
commit f66a54bb73
5 changed files with 101 additions and 48 deletions

View file

@ -103,27 +103,26 @@ class ReventeModelMultipleChoiceField(forms.ModelMultipleChoiceField):
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):
def __init__(self, participant, *args, **kwargs): def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["reventes"] = ReventeModelMultipleChoiceField( self.fields["reventes"] = TemplateLabelField(
own=True,
label="", label="",
queryset=participant.original_shows.filter( queryset=participant.original_shows.filter(
attribution__spectacle__date__gte=timezone.now(), soldTo__isnull=True attribution__spectacle__date__gte=timezone.now(), soldTo__isnull=True
@ -134,6 +133,9 @@ class AnnulForm(forms.Form):
.order_by("-date"), .order_by("-date"),
widget=forms.CheckboxSelectMultiple, widget=forms.CheckboxSelectMultiple,
required=False, required=False,
label_template_name="bda/forms/revente_self_label_table.html",
option_template_name="bda/forms/checkbox_table.html",
context_object_name="revente",
) )
@ -194,8 +196,7 @@ class ReventeTirageForm(forms.Form):
class SoldForm(forms.Form): class SoldForm(forms.Form):
def __init__(self, participant, *args, **kwargs): def __init__(self, participant, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["reventes"] = ReventeModelMultipleChoiceField( self.fields["reventes"] = TemplateLabelField(
own=True,
label="", label="",
queryset=participant.original_shows.filter(soldTo__isnull=False) queryset=participant.original_shows.filter(soldTo__isnull=False)
.exclude(soldTo=participant) .exclude(soldTo=participant)
@ -203,5 +204,8 @@ class SoldForm(forms.Form):
"attribution__spectacle", "attribution__spectacle__location" "attribution__spectacle", "attribution__spectacle__location"
), ),
widget=forms.CheckboxSelectMultiple, 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",
) )

View file

@ -0,0 +1,6 @@
{% with spectacle=attribution.spectacle %}
<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>
{% endwith %}

View file

@ -0,0 +1,7 @@
{% with spectacle=revente.attribution.spectacle %}
<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 data-sort-value="{{ revente.date_tirage | date:"U" }}">{% if revente.tirage_done %}Tirage infructueux{% else %}{{ revente.date_tirage }}{% endif %}</td>
{% endwith %}

View file

@ -0,0 +1,7 @@
{% with spectacle=revente.attribution.spectacle user=revente.soldTo.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><a href="mailto:{{ user.email }}">{{user.first_name}} {{user.last_name}}</a></td>
{% endwith %}

View file

@ -11,19 +11,30 @@
<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 />
@ -37,15 +48,21 @@
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>
@ -55,19 +72,31 @@
{% if sold_exists %} {% 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>