Ajoute une vérification de tirage
This commit is contained in:
parent
374812d702
commit
442f358cf5
2 changed files with 12 additions and 1 deletions
11
bda/admin.py
11
bda/admin.py
|
@ -5,6 +5,7 @@ from django.core.mail import send_mail
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.db.models import Sum, Count
|
from django.db.models import Sum, Count
|
||||||
from bda.models import Spectacle, Salle, Participant, ChoixSpectacle, Attribution, Tirage
|
from bda.models import Spectacle, Salle, Participant, ChoixSpectacle, Attribution, Tirage
|
||||||
|
from django import forms
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
|
@ -107,6 +108,15 @@ Le Bureau des Arts
|
||||||
self.message_user(request, u"%s été informé%s avec succès." % (message_bit, plural))
|
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"
|
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")
|
||||||
|
|
||||||
class AttributionAdmin(admin.ModelAdmin):
|
class AttributionAdmin(admin.ModelAdmin):
|
||||||
def paid(self, obj):
|
def paid(self, obj):
|
||||||
return obj.participant.paid
|
return obj.participant.paid
|
||||||
|
@ -114,6 +124,7 @@ class AttributionAdmin(admin.ModelAdmin):
|
||||||
paid.boolean = True
|
paid.boolean = True
|
||||||
list_display = ("id", "spectacle", "participant", "given", "paid")
|
list_display = ("id", "spectacle", "participant", "given", "paid")
|
||||||
search_fields = ('spectacle__title', 'participant__user__username', 'participant__user__first_name', 'participant__user__last_name')
|
search_fields = ('spectacle__title', 'participant__user__username', 'participant__user__first_name', 'participant__user__last_name')
|
||||||
|
form = AttributionAdminForm
|
||||||
|
|
||||||
import autocomplete_light
|
import autocomplete_light
|
||||||
class ChoixSpectacleAdmin(admin.ModelAdmin):
|
class ChoixSpectacleAdmin(admin.ModelAdmin):
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Participant(models.Model):
|
||||||
tirage = models.ForeignKey(Tirage)
|
tirage = models.ForeignKey(Tirage)
|
||||||
|
|
||||||
def __unicode__ (self):
|
def __unicode__ (self):
|
||||||
return u"%s" % (self.user)
|
return u"%s, %s" % (self.user, self.tirage.title)
|
||||||
|
|
||||||
DOUBLE_CHOICES = (
|
DOUBLE_CHOICES = (
|
||||||
("1", "1 place"),
|
("1", "1 place"),
|
||||||
|
|
Loading…
Reference in a new issue