diff --git a/kfet/forms.py b/kfet/forms.py index 61d4e525..021b8411 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -139,10 +139,9 @@ class KPsulOperationForm(forms.ModelForm): class Meta: model = Operation fields = ['type', 'amount', 'is_checkout', 'article', 'article_nb'] -""" -OperationFormSet = modelformset_factory( + +KPsulOperationFormSet = modelformset_factory( Operation, form = KPsulOperationForm, extra = 0, min_num = 1, validate_min = True) -""" diff --git a/kfet/migrations/0010_auto_20160806_2343.py b/kfet/migrations/0010_auto_20160806_2343.py new file mode 100644 index 00000000..60c8cc93 --- /dev/null +++ b/kfet/migrations/0010_auto_20160806_2343.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfet', '0009_auto_20160805_0720'), + ] + + operations = [ + migrations.AlterField( + model_name='operation', + name='addcost_amount', + field=models.DecimalField(max_digits=6, default=0, decimal_places=2), + ), + migrations.AlterField( + model_name='operationgroup', + name='amount', + field=models.DecimalField(max_digits=6, default=0, decimal_places=2), + ), + migrations.AlterField( + model_name='operationgroup', + name='valid_by', + field=models.ForeignKey(default=None, related_name='+', to='kfet.Account', blank=True, null=True, on_delete=django.db.models.deletion.PROTECT), + ), + ] diff --git a/kfet/views.py b/kfet/views.py index b7d6cdde..6f478d7d 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -361,12 +361,7 @@ def kpsul(request): data['operationgroup_form'] = KPsulOperationGroupForm() data['trigramme_form'] = KPsulAccountForm() data['checkout_form'] = KPsulCheckoutForm() - OperationFormSet = modelformset_factory( - Operation, - form = KPsulOperationForm, - extra = 0, - min_num = 1, validate_min = True) - operation_formset = OperationFormSet(queryset=Operation.objects.none()) + operation_formset = KPsulOperationFormSet(queryset=Operation.objects.none()) data['operation_formset'] = operation_formset return render(request, 'kfet/kpsul.html', data) @@ -408,8 +403,8 @@ def kpsul_perform_operations(request): return JsonResponse(data, status=400) operationgroup_form = KPsulOperationGroupForm(request.POST) - operationgroup = operationgroup_form.save(commit = False) - operation_formset = OperationFormSet(request.POST) + operationgroup = operationgroup_form.save(commit = False) + operation_formset = KPsulOperationFormSet(request.POST) operations = operation_formset.save(commit = False) for operation in operations: operationgroup.amount += operation.amount