def populatevendor() : populateadmin() from hawkers.models import db, User # add a vendor user vendor_user = User() vendor_user.first_name = 'Test' vendor_user.last_name = 'Vendor' vendor_user.login = '******' vendor_user.email = '*****@*****.**' vendor_user.password = generate_password_hash('vndrP') vendor_user.hawker = None vendor_user.is_admin = False db.session.add(vendor_user) db.session.commit()
def populateadmin() : from hawkers.models import db, User print User.query.delete(), " rows deleted from User" # add admin user admin_user = User() admin_user.first_name = 'Admin' admin_user.last_name = 'istrator' admin_user.login = '******' admin_user.email = '*****@*****.**' admin_user.password = generate_password_hash(app.config['ADMIN_PASSWORD']) admin_user.hawker = None admin_user.is_admin = True db.session.add(admin_user) db.session.commit()
def add_owner() : user_form = UserForm(request.form) if request.method == 'POST' and user_form.validate() : user = User() user.first_name = user_form.first_name.data user.last_name = user_form.last_name.data user.login = user_form.login.data user.email = user_form.email.data user.password = generate_password_hash(user.login) db.session.add(user) db.session.commit() return redirect(url_for('vendor_page.index')) return render_template('addowner.html', form=user_form)