def add_user(): error = None form = CreateUserForm() if form.validate_on_submit(): try: UserModel.save(username=request.form['username'], password=request.form['password']) except Exception, e: error = u"そのユーザ名は登録できません" else: flash(u"登録が完了しました") return redirect(url_for('index'))
def post(self): super(UserApi, self).post() code = 0 value_list = self.get_form_data() userinfo = dict(zip(self.cloumn, value_list)) userinfo['password'] = request.form.get('password') user = UserModel(**userinfo) user.save() if not user.success: return self.render_json(code=1003) self.log(info=userinfo['name']) return self.render_json()
def post(self): name = request.json['name'] birth_date = request.json['birthDate'] gender = request.json['gender'] phone_number = request.json['phoneNumber'] disturbance_factor = request.json['disturbanceFactor'] favorite_food = request.json['favoriteFood'] user = UserModel(name=name, birth_date=birth_date, gender=gender, phone_number=phone_number) user.save() SurveyModel(disturbance_factor=disturbance_factor, favorite_food=favorite_food, user=user).save() return Response('', 200)