forked from DGNum/gestioCOF
buy more than one place
This commit is contained in:
parent
0282f62886
commit
2a56f8e255
|
@ -44,6 +44,14 @@ class AttributionModelMultipleChoiceField(forms.ModelMultipleChoiceField):
|
|||
return "%s" % obj.spectacle
|
||||
|
||||
|
||||
class BuyResellForm(forms.Form):
|
||||
num = forms.ChoiceField(choices=[])
|
||||
|
||||
def __init__(self, spectacle, *args, **kwargs):
|
||||
super(BuyResellForm, self).__init__(*args, **kwargs)
|
||||
self.fields['num'].choices = range(1, spectacle.revente.count())
|
||||
|
||||
|
||||
class ResellForm(forms.Form):
|
||||
attributions = AttributionModelMultipleChoiceField(
|
||||
queryset=Attribution.objects.none(),
|
||||
|
|
|
@ -28,7 +28,7 @@ from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution,\
|
|||
from bda.algorithm import Algorithm
|
||||
|
||||
from bda.forms import BaseBdaFormSet, TokenForm, ResellForm, AnnulForm,\
|
||||
InscriptionReventeForm
|
||||
InscriptionReventeForm, BuyResellForm
|
||||
|
||||
|
||||
@cof_required
|
||||
|
@ -435,8 +435,11 @@ def buy_revente(request, spectacle_id):
|
|||
return render(request, "bda-no-revente.html", {})
|
||||
|
||||
if request.POST:
|
||||
idx = random.randint(0, reventes.count() - 1)
|
||||
revente = reventes.all()[idx]
|
||||
form = BuyResellForm(spectacle, request.POST)
|
||||
if form.is_valid():
|
||||
num = form.cleaned_data['num']
|
||||
reventes = random.sample(reventes.all(), num)
|
||||
for revente in reventes:
|
||||
revente.soldTo = participant
|
||||
revente.save()
|
||||
mail = """Bonjour !
|
||||
|
|
Loading…
Reference in a new issue