add transfer & reinit functions

This commit is contained in:
Ludovic Stephan 2016-10-27 23:46:57 -02:00
parent a29c73cb27
commit 56a1f8e634

View file

@ -13,6 +13,7 @@ from bda.models import Spectacle, Salle, Participant, ChoixSpectacle,\
from django import forms from django import forms
from datetime import timedelta from datetime import timedelta
from django.utils import timezone
import autocomplete_light import autocomplete_light
@ -224,6 +225,28 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
'seller__user__first_name', 'seller__user__first_name',
'seller__user__last_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(CategorieSpectacle)
admin.site.register(Spectacle, SpectacleAdmin) admin.site.register(Spectacle, SpectacleAdmin)