Fixed address forward email validation
This commit is contained in:
parent
b4950815a5
commit
49b7be33e3
|
@ -18,7 +18,7 @@ def validate_emailname(value):
|
||||||
raise ValidationError(msg)
|
raise ValidationError(msg)
|
||||||
value += '@localhost'
|
value += '@localhost'
|
||||||
try:
|
try:
|
||||||
EmailValidator(value)
|
EmailValidator()(value)
|
||||||
except ValidationError:
|
except ValidationError:
|
||||||
raise ValidationError(msg)
|
raise ValidationError(msg)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ def validate_forward(value):
|
||||||
if '@' in destination:
|
if '@' in destination:
|
||||||
if not destination[-1].isalpha():
|
if not destination[-1].isalpha():
|
||||||
raise ValidationError(msg)
|
raise ValidationError(msg)
|
||||||
EmailValidator(destination)
|
EmailValidator()(destination)
|
||||||
else:
|
else:
|
||||||
if not Mailbox.objects.filter(user__username=destination).exists():
|
if not Mailbox.objects.filter(user__username=destination).exists():
|
||||||
raise ValidationError(msg)
|
raise ValidationError(msg)
|
||||||
|
|
|
@ -4,6 +4,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orchestra.core import services
|
from orchestra.core import services
|
||||||
from orchestra.core.validators import validate_name
|
from orchestra.core.validators import validate_name
|
||||||
|
from orchestra.models.fields import NullableCharField
|
||||||
|
|
||||||
|
|
||||||
class MiscService(models.Model):
|
class MiscService(models.Model):
|
||||||
|
@ -13,6 +14,9 @@ class MiscService(models.Model):
|
||||||
help_text=_("Human readable name"))
|
help_text=_("Human readable name"))
|
||||||
description = models.TextField(_("description"), blank=True,
|
description = models.TextField(_("description"), blank=True,
|
||||||
help_text=_("Optional description"))
|
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,
|
has_amount = models.BooleanField(_("has amount"), default=False,
|
||||||
help_text=_("Designates whether this service has <tt>amount</tt> "
|
help_text=_("Designates whether this service has <tt>amount</tt> "
|
||||||
"property or not."))
|
"property or not."))
|
||||||
|
@ -35,6 +39,8 @@ class Miscellaneous(models.Model):
|
||||||
related_name='instances')
|
related_name='instances')
|
||||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
account = models.ForeignKey('accounts.Account', verbose_name=_("account"),
|
||||||
related_name='miscellaneous')
|
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)
|
description = models.TextField(_("description"), blank=True)
|
||||||
amount = models.PositiveIntegerField(_("amount"), default=1)
|
amount = models.PositiveIntegerField(_("amount"), default=1)
|
||||||
is_active = models.BooleanField(_("active"), default=True,
|
is_active = models.BooleanField(_("active"), default=True,
|
||||||
|
@ -54,5 +60,10 @@ class Miscellaneous(models.Model):
|
||||||
except type(self).account.field.rel.to.DoesNotExist:
|
except type(self).account.field.rel.to.DoesNotExist:
|
||||||
return self.is_active
|
return self.is_active
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
if self.identifier:
|
||||||
|
self.identifier = self.identifier.strip()
|
||||||
|
self.description = self.description.strip()
|
||||||
|
|
||||||
|
|
||||||
services.register(Miscellaneous)
|
services.register(Miscellaneous)
|
||||||
|
|
Loading…
Reference in New Issue