forked from DGNum/gestioCOF
Merge branch 'master' into Kerl/mails_rappel
This commit is contained in:
commit
d97708a2ee
12 changed files with 162 additions and 84 deletions
23
bda/admin.py
23
bda/admin.py
|
@ -5,6 +5,7 @@ from django.core.mail import send_mail
|
|||
from django.contrib import admin
|
||||
from django.db.models import Sum, Count
|
||||
from bda.models import Spectacle, Salle, Participant, ChoixSpectacle, Attribution, Tirage
|
||||
from django import forms
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
|
@ -121,6 +122,16 @@ Le Bureau des Arts
|
|||
self.message_user(request, u"%s été informé%s avec succès." % (message_bit, plural))
|
||||
send_attribs.short_description = u"Envoyer les résultats par mail"
|
||||
|
||||
class AttributionAdminForm(forms.ModelForm):
|
||||
def clean(self):
|
||||
cleaned_data=super(AttributionAdminForm, self).clean()
|
||||
participant = cleaned_data.get("participant")
|
||||
spectacle = cleaned_data.get("spectacle")
|
||||
if participant and spectacle:
|
||||
if participant.tirage != spectacle.tirage:
|
||||
raise forms.ValidationError(u"Erreur : le participant et le spectacle n'appartiennent pas au même tirage")
|
||||
return cleaned_data
|
||||
|
||||
class AttributionAdmin(admin.ModelAdmin):
|
||||
def paid(self, obj):
|
||||
return obj.participant.paid
|
||||
|
@ -128,18 +139,22 @@ class AttributionAdmin(admin.ModelAdmin):
|
|||
paid.boolean = True
|
||||
list_display = ("id", "spectacle", "participant", "given", "paid")
|
||||
search_fields = ('spectacle__title', 'participant__user__username', 'participant__user__first_name', 'participant__user__last_name')
|
||||
form = AttributionAdminForm
|
||||
|
||||
import autocomplete_light
|
||||
class ChoixSpectacleAdmin(admin.ModelAdmin):
|
||||
form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[])
|
||||
list_display = ("participant", "spectacle", "priority", "double_choice")
|
||||
list_filter = ("double_choice",)
|
||||
def tirage(self, obj):
|
||||
return obj.participant.tirage
|
||||
list_display = ("participant", "tirage", "spectacle", "priority", "double_choice")
|
||||
list_filter = ("double_choice", "participant__tirage")
|
||||
search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name')
|
||||
|
||||
class SpectacleAdmin(admin.ModelAdmin):
|
||||
model = Spectacle
|
||||
list_display = ("title", "date", "location", "slots", "price", "listing")
|
||||
list_filter = ("location",)
|
||||
list_display = ("title", "date", "tirage", "location", "slots", "price",
|
||||
"listing")
|
||||
list_filter = ("location", "tirage",)
|
||||
search_fields = ("title", "location__name")
|
||||
|
||||
class TirageAdmin(admin.ModelAdmin):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
{% block realcontent %}
|
||||
<h2>{{ spectacle }}</h2>
|
||||
<h3><a href="{% url "admin:bda_attribution_add" %}?spectacle={{spectacle.id}}">Ajouter une attribution</a></h3>
|
||||
<table class='etat-bda' align="center">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -25,11 +26,16 @@
|
|||
</div>
|
||||
</td>
|
||||
<td align="center">
|
||||
<div class={%if participant.given %}"greenratio"{%else%}"redratio"{%endif%}>
|
||||
{% if participant.given %}Oui{% else %}Non{%endif%}
|
||||
<div class={%if participant.given == participant.nb_places %}"greenratio"
|
||||
{%elif participant.given == 0%}"redratio"
|
||||
{%else%}"orangeratio"
|
||||
{%endif%}>
|
||||
{% if participant.given == participant.nb_places %}Oui
|
||||
{% elif participant.given == 0 %}Non
|
||||
{% else %}{{participant.given}}/{{participant.nb_places}}
|
||||
{%endif%}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
@ -41,8 +47,7 @@
|
|||
<br>
|
||||
<button type="button" onclick="toggle('export-salle')">Afficher/Cacher liste noms</button>
|
||||
<pre id="export-salle" style="display:none">
|
||||
{% for participant in participants %}{{participant.name}}{% if participant.nb_places == 2 %}
|
||||
{{participant.name}}{%endif%}
|
||||
{% for participant in participants %}{{participant.name}} : {{participant.nb_places}} places
|
||||
{% endfor %}
|
||||
</pre>
|
||||
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
<h2>Impayés</h2>
|
||||
<textarea style="width: 100%; height: 100px; margin-top: 10px;">
|
||||
{% for participant in unpaid %}{{ participant.user.email }}, {% endfor %}</textarea>
|
||||
<h3>Total : {{ unpaid|length }}</h3>
|
||||
{% endblock %}
|
||||
|
|
10
bda/views.py
10
bda/views.py
|
@ -5,6 +5,7 @@ from __future__ import division
|
|||
from django.shortcuts import render, get_object_or_404
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.db import models
|
||||
from django.db.models import Count
|
||||
from django.core import serializers
|
||||
from django.forms.models import inlineformset_factory
|
||||
import hashlib
|
||||
|
@ -302,11 +303,12 @@ def spectacle(request, tirage_id, spectacle_id):
|
|||
'name': participant.user.get_full_name,
|
||||
'username': participant.user.username,
|
||||
'email': participant.user.email,
|
||||
'given': attrib.given,
|
||||
'given': int(attrib.given),
|
||||
'paid': participant.paid,
|
||||
'nb_places': 1}
|
||||
if participant.id in participants:
|
||||
participants[participant.id]['nb_places'] += 1
|
||||
participants[participant.id]['nb_places'] += 1
|
||||
participants[participant.id]['given'] += attrib.given
|
||||
else:
|
||||
participants[participant.id] = participant_info
|
||||
|
||||
|
@ -331,7 +333,9 @@ class SpectacleListView(ListView):
|
|||
@buro_required
|
||||
def unpaid(request, tirage_id):
|
||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||
unpaid = tirage.participant_set.filter(paid=False).all()
|
||||
unpaid = tirage.participant_set \
|
||||
.annotate(nb_attributions=Count('attribution')) \
|
||||
.filter(paid=False, nb_attributions__gt=0).all()
|
||||
return render(request, "bda-unpaid.html", {"unpaid": unpaid})
|
||||
|
||||
@buro_required
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue