def clean_name(self): name = self.cleaned_data.get('name', '') self.mailbox = u"{}@{}".format(name, self.domain) if not pure_english_regex(name): raise forms.ValidationError(_(u"邮箱名称只能由字母、数字或下划线点横杠组成!")) if Mailbox.objects.exclude(id=self.instance.id).filter( name=name, domain=self.domain): raise forms.ValidationError(_(u"邮箱名称'{}'重复").format(name)) return name
def clean_name(self): name = self.cleaned_data.get('name') if not name: raise forms.ValidationError(_(u"请输入权限名")) if not pure_english_regex(name): raise forms.ValidationError(_(u"请使用英文名称,可以使用数字、字母以及特殊字符(._-)")) if MyPermission.objects.exclude(id=self.instance.id).filter( name=name).exists(): raise forms.ValidationError(_(u"不能重复添加权限名")) return name
def clean_eenumber(self): data = self.cleaned_data.get('eenumber', '') if data: tel_mobile = self.cleaned_data.get('tel_mobile', '') if not pure_english_regex(data): raise forms.ValidationError(_(u"工号只能由字母、数字或下划线点横杠组成!")) if MailboxUser.objects.exclude(id=self.instance.id).filter( eenumber=data, domain=self.domain): raise forms.ValidationError(_(u"工号'{}'重复").format(data)) if tel_mobile and tel_mobile == data: raise forms.ValidationError(_(u"工号和手机号一样,不能保存!")) return data