Ajout d'un attribu listing
aux spectacles
Indique si les places sont sur listing ou au contraire sont des places physiques. L'interface admin sépare en deux les spectacles listing/non-listing.
This commit is contained in:
parent
8ab7fac3be
commit
fae1cee647
2 changed files with 17 additions and 2 deletions
18
bda/admin.py
18
bda/admin.py
|
@ -15,10 +15,24 @@ class ChoixSpectacleInline(admin.TabularInline):
|
||||||
|
|
||||||
class AttributionInline(admin.TabularInline):
|
class AttributionInline(admin.TabularInline):
|
||||||
model = Attribution
|
model = Attribution
|
||||||
|
extra = 0
|
||||||
|
def get_queryset(self, request):
|
||||||
|
qs = super(AttributionInline, self).get_queryset(request)
|
||||||
|
return qs.filter(spectacle__listing=False)
|
||||||
|
|
||||||
|
class AttributionInlineListing(admin.TabularInline):
|
||||||
|
model = Attribution
|
||||||
|
exclude = ('given', )
|
||||||
|
extra = 0
|
||||||
|
def get_queryset(self, request):
|
||||||
|
qs = super(AttributionInlineListing, self).get_queryset(request)
|
||||||
|
return qs.filter(spectacle__listing=True)
|
||||||
|
|
||||||
class ParticipantAdmin(admin.ModelAdmin):
|
class ParticipantAdmin(admin.ModelAdmin):
|
||||||
#inlines = [ChoixSpectacleInline]
|
#inlines = [ChoixSpectacleInline]
|
||||||
inlines = [AttributionInline]
|
inlines = [
|
||||||
|
AttributionInline,
|
||||||
|
AttributionInlineListing]
|
||||||
def get_queryset(self, request):
|
def get_queryset(self, request):
|
||||||
return Participant.objects.annotate(nb_places = Count('attributions'),
|
return Participant.objects.annotate(nb_places = Count('attributions'),
|
||||||
total = Sum('attributions__price'))
|
total = Sum('attributions__price'))
|
||||||
|
@ -124,7 +138,7 @@ class ChoixSpectacleAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
class SpectacleAdmin(admin.ModelAdmin):
|
class SpectacleAdmin(admin.ModelAdmin):
|
||||||
model = Spectacle
|
model = Spectacle
|
||||||
list_display = ("title", "date", "location", "slots", "price")
|
list_display = ("title", "date", "location", "slots", "price", "listing")
|
||||||
list_filter = ("location",)
|
list_filter = ("location",)
|
||||||
search_fields = ("title", "location__name")
|
search_fields = ("title", "location__name")
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ class Spectacle(models.Model):
|
||||||
slots = models.IntegerField("Places")
|
slots = models.IntegerField("Places")
|
||||||
priority = models.IntegerField("Priorité", default=1000)
|
priority = models.IntegerField("Priorité", default=1000)
|
||||||
tirage = models.ForeignKey(Tirage)
|
tirage = models.ForeignKey(Tirage)
|
||||||
|
listing = models.BooleanField("Les places sont sur listing")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Spectacle"
|
verbose_name = "Spectacle"
|
||||||
|
|
Loading…
Reference in a new issue