Fixed address forward email validation

This commit is contained in:
Marc Aymerich 2014-11-12 12:46:41 +00:00
parent b4950815a5
commit 49b7be33e3
2 changed files with 13 additions and 2 deletions

View File

@ -18,7 +18,7 @@ def validate_emailname(value):
raise ValidationError(msg)
value += '@localhost'
try:
EmailValidator(value)
EmailValidator()(value)
except ValidationError:
raise ValidationError(msg)
@ -35,7 +35,7 @@ def validate_forward(value):
if '@' in destination:
if not destination[-1].isalpha():
raise ValidationError(msg)
EmailValidator(destination)
EmailValidator()(destination)
else:
if not Mailbox.objects.filter(user__username=destination).exists():
raise ValidationError(msg)

View File

@ -4,6 +4,7 @@ from django.utils.translation import ugettext_lazy as _
from orchestra.core import services
from orchestra.core.validators import validate_name
from orchestra.models.fields import NullableCharField
class MiscService(models.Model):
@ -13,6 +14,9 @@ class MiscService(models.Model):
help_text=_("Human readable name"))
description = models.TextField(_("description"), blank=True,
help_text=_("Optional description"))
has_identifier = models.BooleanField(_("has identifier"), default=True,
help_text=_("Designates if this service has a <b>unique text</b> field that "
"identifies it or not."))
has_amount = models.BooleanField(_("has amount"), default=False,
help_text=_("Designates whether this service has <tt>amount</tt> "
"property or not."))
@ -35,6 +39,8 @@ class Miscellaneous(models.Model):
related_name='instances')
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
related_name='miscellaneous')
identifier = NullableCharField(_("identifier"), max_length=256, null=True, unique=True,
blank=True, help_text=_("A unique identifier for this service."))
description = models.TextField(_("description"), blank=True)
amount = models.PositiveIntegerField(_("amount"), default=1)
is_active = models.BooleanField(_("active"), default=True,
@ -53,6 +59,11 @@ class Miscellaneous(models.Model):
return self.is_active and self.account.is_active
except type(self).account.field.rel.to.DoesNotExist:
return self.is_active
def clean(self):
if self.identifier:
self.identifier = self.identifier.strip()
self.description = self.description.strip()
services.register(Miscellaneous)