2014-05-08 16:59:35 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
2015-08-05 22:58:35 +00:00
|
|
|
from orchestra.forms import UserCreationForm, NonStoredUserChangeForm
|
2014-05-08 16:59:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CleanAddressMixin(object):
|
|
|
|
def clean_address_domain(self):
|
|
|
|
name = self.cleaned_data.get('address_name')
|
|
|
|
domain = self.cleaned_data.get('address_domain')
|
|
|
|
if name and not domain:
|
|
|
|
msg = _("Domain should be selected for provided address name")
|
|
|
|
raise forms.ValidationError(msg)
|
|
|
|
return domain
|
|
|
|
|
|
|
|
|
2015-08-05 22:58:35 +00:00
|
|
|
class ListCreationForm(CleanAddressMixin, UserCreationForm):
|
|
|
|
pass
|
|
|
|
|
2014-05-08 16:59:35 +00:00
|
|
|
|
2015-08-05 22:58:35 +00:00
|
|
|
class ListChangeForm(CleanAddressMixin, NonStoredUserChangeForm):
|
|
|
|
pass
|