def post(self, id): body = request.data kwargs = json.loads(body) kwargs['user_id'] = id usr = model.User(**kwargs) usr.persist() return usr.to_json()
def post(self): data = request.get_json(force=True) contact_number = data.get("contact_number") email = data.get("email") address = data.get("address") # username = data.get("username") unhashed_password = data.get("password") if unhashed_password is None: abort(400) password = make_hashed_password(unhashed_password) this_user = model.User( contact_number=contact_number, email=email, # username = username, password=password, ) db.session.add(this_user) db.session.commit() user_dict = this_user.to_dict() del user_dict["password"] return jsonify(user_dict)
def _get_survey_users(self): users = [] for index, row in self.df.iterrows(): gis_user = model.User() gis_user.id = row['user'] user_profile = self.df[self.df['user'] == row['user']].ix[:, 6:10].values[0] s = sum(user_profile) user_profile = [float(i)/s for i in user_profile] gis_user.rock = user_profile[3] gis_user.dirt = user_profile[1] gis_user.woodland = user_profile[2] gis_user.asphalt = user_profile[0] gis_user.ranking_list = row.tolist()[10:36] gis_user.survey_time = row['time'] self.session.query(model.User).filter(model.User.id == row['user']).delete() self.session.add(gis_user) users.append(gis_user) self.session.commit() return users
def signup(): form = forms.signupform() mssg = "" if form.validate_on_submit(): user = model.User.query.filter_by(username = form.username.data).first() if user is None: hashed_pass = generate_password_hash(form.password.data , method='sha256') new_user = model.User(username = form.username.data , password = hashed_pass) db.session.add(new_user) db.session.commit() db.session.close() return redirect(url_for('login')) else: return render_template('signup.html' , formsign = form ,subtitle = "Signup" ,error_mssg = "Email already exists.") db.session.close() return render_template('signup.html' , subtitle = "Signup" , formsign = form , error_mssg = mssg),200