def validate(self, user): if not Form.validate(self): return False if not user.check_password(self.old_password.data): self.old_password.errors.append(u"原密码错误.") return False return True
def validate(self): if Form.validate(self): if not self.estimate_num.hidden: if self.ad_type.data == AD_TYPE_NORMAL: if self.max_order_num.data > self.estimate_num.data: self.max_order_num.errors.append( u"最大预订不能大于预估量(如果新添加了广告单元, 请先保存, 然后根据计算所得调整)") return False elif self.ad_type.data == AD_TYPE_CPD: if self.cpd_num.data > self.estimate_num.data: self.cpd_num.errors.append(u"CPD量不能大于预估量") return False units = AdUnit.gets(self.units.data) medium = Medium.get(self.medium.data) if not units: self.units.errors.append(u"所含广告单元不能为空") return False for u in units: if u.medium != medium: self.units.errors.append( u"%s不属于%s" % (u.display_name, medium.name)) return False return True else: return False
def validate(self): if Form.validate(self): if not self.estimate_num.hidden: if self.ad_type.data == AD_TYPE_NORMAL: if self.max_order_num.data > self.estimate_num.data: self.max_order_num.errors.append( u"最大预订不能大于预估量(如果新添加了广告单元, 请先保存, 然后根据计算所得调整)") return False elif self.ad_type.data == AD_TYPE_CPD: if self.cpd_num.data > self.estimate_num.data: self.cpd_num.errors.append(u"CPD量不能大于预估量") return False units = AdUnit.gets(self.units.data) medium = Medium.get(self.medium.data) if not units: self.units.errors.append(u"所含广告单元不能为空") return False for u in units: if u.medium != medium: self.units.errors.append(u"%s不属于%s" % (u.display_name, medium.name)) return False return True else: return False
def validate(self, vali_email=True): if not Form.validate(self): return False user = User.get_by_email(email=self.email.data.lower()) if vali_email and user: self.email.errors.append(u' 该邮箱用户已存在') return False return True
def validate(self): if Form.validate(self): if any(self.direct_sales.data + self.agent_sales.data): return True else: self.direct_sales.errors.append(u"销售不能全为空") return False return False
def validate(self): if Form.validate(self): if any(self.sales.data): return True else: self.sales.errors.append(u"销售不能为空") return False return False
def validate(self): if Form.validate(self): if any(self.medium_users.data): return True else: self.medium_users.errors.append(u"直接销售和渠道销售不能全为空") return False return False
def validate(self): if Form.validate(self): if any(self.sales.data): return True else: self.sales.errors.append(u"销售不能为空") return False return False
def validate(self): if Form.validate(self): if any(self.direct_sales.data + self.agent_sales.data): return True else: self.direct_sales.errors.append(u"销售不能全为空") return False return False
def validate(self): if not Form.validate(self): return False user = User.get_by_email(email=self.email.data.lower()) if user and user.check_password(self.password.data): return user else: self.email.errors.append(u"用户名或者密码错误.") return False
def validate(self): if Form.validate(self): positions = AdPosition.gets(self.positions.data) medium = Medium.get(self.medium.data) for p in positions: if p.medium != medium: self.positions.errors.append( u"%s不属于%s" % (p.display_name, medium.name)) return False return True else: return False
def validate(self): if Form.validate(self): positions = AdPosition.gets(self.positions.data) medium = Medium.get(self.medium.data) for p in positions: if p.medium != medium: self.positions.errors.append(u"%s不属于%s" % (p.display_name, medium.name)) return False return True else: return False
def validate(self): if Form.validate(self): if self.alipay.data: return True else: if not self.bank.data: self.bank.errors.append(u"开户行和支付宝不能全为空") return False elif not self.card.data: self.card.errors.append(u"需提供开户行的银行卡号") return False else: return True return False
def validate(self): if Form.validate(self): if self.alipay.data: return True else: if not self.bank.data: self.bank.errors.append(u"开户行和支付宝不能全为空") return False elif not self.card.data: self.card.errors.append(u"需提供开户行的银行卡号") return False else: return True return False