Fewer requests on create/update spectaclerevente in bda admin.
- O(#participant) -> O(1) requests
This commit is contained in:
parent
0750551d7c
commit
ce70269e7b
1 changed files with 19 additions and 0 deletions
19
bda/admin.py
19
bda/admin.py
|
@ -230,6 +230,24 @@ class SalleAdmin(admin.ModelAdmin):
|
|||
search_fields = ('name', 'address')
|
||||
|
||||
|
||||
class SpectacleReventeAdminForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['answered_mail'].queryset = (
|
||||
Participant.objects
|
||||
.select_related('user', 'tirage')
|
||||
)
|
||||
self.fields['seller'].queryset = (
|
||||
Participant.objects
|
||||
.select_related('user', 'tirage')
|
||||
)
|
||||
self.fields['soldTo'].queryset = (
|
||||
Participant.objects
|
||||
.select_related('user', 'tirage')
|
||||
)
|
||||
|
||||
|
||||
class SpectacleReventeAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
Administration des reventes de spectacles
|
||||
|
@ -252,6 +270,7 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
|
|||
|
||||
actions = ['transfer', 'reinit']
|
||||
actions_on_bottom = True
|
||||
form = SpectacleReventeAdminForm
|
||||
|
||||
def transfer(self, request, queryset):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue