Adds messages and balance check

This commit is contained in:
nikolark committed 2012-02-23 02:53:09 +01:00
1 parent 54ec001fb1
commit e7d499aeca
8 files changed
+123 -52

No files matched your search

+8 -1
View File
@@ -1,9 +1,16 @@
# coding: utf-8
from django import forms
from django.utils.translation import ugettext as _
from models import *
class OrderForm(forms.ModelForm):
# TODO : validate that the customer can afford the order
def clean_customer(self):
if self.cleaned_data['customer'].get_profile().balance <= 0:
raise forms.ValidationError(_("Du har negativ saldo og kan ikke kjøpe noe."))
return self.cleaned_data['customer']
class Meta:
model = Order
fields = ('customer',)