forked from DGNum/gestioCOF
Merge branch 'Aufinal/verif_tirage' into 'master'
Ajoute une vérification de tirage lors de l'ajout d'attribution fixes #49 See merge request !50
This commit is contained in:
commit
e62483e48c
1 changed files with 18 additions and 4 deletions
22
bda/admin.py
22
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,16 @@ 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")
|
||||||
|
return cleaned_data
|
||||||
|
|
||||||
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,18 +125,21 @@ 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):
|
||||||
form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[])
|
form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[])
|
||||||
list_display = ("participant", "spectacle", "priority", "double_choice")
|
def tirage(self, obj):
|
||||||
list_filter = ("double_choice",)
|
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')
|
search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name')
|
||||||
|
|
||||||
class SpectacleAdmin(admin.ModelAdmin):
|
class SpectacleAdmin(admin.ModelAdmin):
|
||||||
model = Spectacle
|
model = Spectacle
|
||||||
list_display = ("title", "date", "location", "slots", "price")
|
list_display = ("title", "date", "tirage", "location", "slots", "price")
|
||||||
list_filter = ("location",)
|
list_filter = ("location", "tirage",)
|
||||||
search_fields = ("title", "location__name")
|
search_fields = ("title", "location__name")
|
||||||
|
|
||||||
class TirageAdmin(admin.ModelAdmin):
|
class TirageAdmin(admin.ModelAdmin):
|
||||||
|
|
Loading…
Reference in a new issue