def post(self): err = JsOb() form = self.json if not form.email: err.email = 'Please input email' else: emails = form.email.replace(' ', '').split(',') for e in emails: if not is_email(e): err.email = 'Email not valid, email=%s' % e elif User.count(dict(email=e, deleted=False)): err.email = "email %s already in use" % e if not form.account: err.account = 'Pleast input your account' if not form.password: err.password = '******' elif not is_valid_password(form.password): err.password = '******' kw = dict(email=emails, password=form.password, account=form.account, role_id=form.role_id, skype_id=form.skype_id, phone=form.phone) if not err: user = User._create(**kw) self.render(err)
def post(self): err = JsOb() user_id = self.json._id user_edit = User._get(user_id) if not self.json.account: err.account = u'Account not be empty!' elif self.json.account != user_edit.account and User.count( dict(account=self.json.account, deleted=False)): err.account = u'Account already in use!' if not self.json.email: err.email = u'Email not be empty!' else: emails = self.json.email.replace(' ', '').split(',') for e in emails: if not is_email(e): err.email = 'Email not valid, email=%s' % e elif e not in user_edit.email and User.count( dict(email=e, deleted=False)): err.email = "email %s already in use" % e if self.json.password: if self.json.password != user_edit.password and not is_valid_password( self.json.password): err.password = u'password not valid!' if not err: content = dict(account=self.json.account, role_id=self.json.role_id, email=emails, password=self.json.password, skype_id=self.json.skype_id, phone=self.json.phone) res = User._update(user_id, **content) if not res: err.update = u'update user:{} failure'.format(user_id) self.render(err)
def post(self): err = JsOb() form = self.json if not form.email: err.email = 'Please input email' else: emails = form.email.replace(' ', '').split(';') for e in emails: if not is_email(e): err.email = 'Email not valid, email=%s' % e elif User.count(dict(email=e, deleted=False)): err.email = "email %s already in use" % e if not form.account: err.account = 'Pleast input your account' if not form.password: err.password = '******' elif not is_valid_password(form.password): err.password = '******' if form.password != form.confirmPassword: err.confirmPassword = '******' if not form.country: err.country = 'Please input Country' if not form.company: err.company = 'Please input Company' if not form.skype_id: err.skype = 'Please input Skype ID' if not form.phone: err.phone = 'Please input Phone' if not self.json.captcha_code: err.captcha_code = 'Please input captcha code' elif not captcha_verify(self.json.captcha_key, self.json.captcha_code): err.captcha_code = 'captcha code incorrect' if not err: kw = dict( email=emails, password=form.password, account=form.account, role_id=Role.affiliate()._id, skype_id=form.skype_id, phone=form.phone, ) user = User._create(**kw) payment = { 'invoice_frequency': '', 'threshold': '', 'payment_method': '', 'beneficiary': '', 'account_number': '', 'bank': '', 'route': '', 'paypal': '' } affiliate = Affiliate._save(**dict(user_id=int(user._id), country=form.country, status='2', company=form.company, payment=payment)) self.render(err)