Permalink
Browse files

Organisation is required for non-individual accounts.

Signed-off-by: Chris Lamb <lamby@debian.org>
  • Loading branch information...
1 parent 908f958 commit 7e1f44cedbf5071963e8e63df433a9545a558d98 @lamby lamby committed with Sep 28, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/librement/profile/forms.py
@@ -12,6 +12,7 @@
from django import forms
from django.contrib.auth.models import User
+from .enums import AccountEnum
from .models import Profile
class ProfileForm(forms.ModelForm):
@@ -36,6 +37,16 @@ class Meta:
'country',
)
+ def clean_organisation(self):
+ val = self.cleaned_data['organisation']
+
+ if self.instance.account_type != AccountEnum.INDIVIDUAL and val == '':
+ raise forms.ValidationError(
+ "Required field for company/non-profit accounts"
+ )
+
+ return val
+
class URLForm(forms.ModelForm):
username = forms.RegexField(regex=r'^[\w-]+$')

0 comments on commit 7e1f44c

Please sign in to comment.