def update_monitoring_options(owner, emails): """Set `emails` as global e-mail alert's recipients.""" from mist.api.helpers import is_email_valid # FIXME Send e-mails as a list, instead of string? emails = emails.replace(' ', '') emails = emails.replace('\n', ',') emails = emails.replace('\r', ',') owner.alerts_email = [ email for email in emails.split(',') if is_email_valid(email) ] owner.save() trigger_session_update(owner, ['monitoring']) return {'alerts_email': owner.alerts_email}
def update_monitoring_options(owner, emails): """Set `emails` as global e-mail alert's recipients.""" from mist.api.helpers import is_email_valid # FIXME Send e-mails as a list, instead of string? emails = emails.replace(" ", "") emails = emails.replace("\n", ",") emails = emails.replace("\r", ",") owner.alerts_email = [ email for email in emails.split(",") if is_email_valid(email) ] owner.save() trigger_session_update(owner, ["monitoring"]) return {"alerts_email": owner.alerts_email}
def clean(self): """Perform e-mail address validation.""" for email in self.emails: if not is_email_valid(email): raise me.ValidationError('Invalid e-mail address: %s' % email)