forked from DGNum/gestioCOF
add transfer & reinit functions
This commit is contained in:
parent
a29c73cb27
commit
56a1f8e634
1 changed files with 23 additions and 0 deletions
23
bda/admin.py
23
bda/admin.py
|
@ -13,6 +13,7 @@ from bda.models import Spectacle, Salle, Participant, ChoixSpectacle,\
|
|||
from django import forms
|
||||
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
|
@ -224,6 +225,28 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
|
|||
'seller__user__first_name',
|
||||
'seller__user__last_name']
|
||||
|
||||
actions = ['transfer', 'reinit', ]
|
||||
actions_on_bottom = True
|
||||
|
||||
def transfer(self, request, queryset):
|
||||
for revente in queryset.all():
|
||||
if revente.soldTo:
|
||||
attrib = revente.attribution
|
||||
attrib.participant = revente.soldTo
|
||||
attrib.save()
|
||||
transfer.short_description = "Transférer les reventes sélectionnées"
|
||||
|
||||
def reinit(self, request, queryset):
|
||||
for revente in queryset.all():
|
||||
revente.date = timezone.now() - timedelta(hours=1)
|
||||
revente.soldTo = None
|
||||
revente.notif_sent = False
|
||||
revente.tirage_done = False
|
||||
if revente.answered_mail:
|
||||
revente.answered_mail.clear()
|
||||
revente.save()
|
||||
reinit.short_description = "Réinitialiser les reventes sélectionnées"
|
||||
|
||||
|
||||
admin.site.register(CategorieSpectacle)
|
||||
admin.site.register(Spectacle, SpectacleAdmin)
|
||||
|
|
Loading…
Reference in a new issue