def generate_profiles(session): from faker import Faker from models.profile import Profile from password_generator import PasswordGenerator faker = Faker() pwo = PasswordGenerator() usernames = [] mails = [] for i in range(0, 8000): profile = faker.simple_profile() while profile['username'] in usernames or profile['mail'] in mails: print('generating profile') profile = faker.simple_profile() username, name, surname, mail, address, sex, birth_date = parse_profile( profile) profile = Profile() profile.username = username profile.name = name profile.surname = surname profile.mail = mail profile.address = address profile.sex = sex profile.birth_date = birth_date profile.password = pwo.generate() profile.profile_id = i + 1 session.add(profile) usernames.append(username) mails.append(mail) session.commit()
def register(): if request.method == 'GET': return redirect('/') logging.debug('add profile form : %s', str(request.form)) logging.info('receive socket from /register-data -> profile: %s', request.form['profile-name']) form = request.form profile = Profile() profile.name = form['profile-name'] profile.firstname = form['profile-firstname'] profile.address = form['profile-address'] profile.comp_address = form['profile-comp_address'] profile.city = form['profile-city'] profile.zipcode = form['profile-zipcode'] profile.country = form['profile-country'] profile.phone = form['profile-phone'] profile.email = form['profile-email'] profile.siret = form['profile-siret'] pdao = ProfileDAO() if pdao.insert(profile): logging.info('add profile %s OK', profile.name) session['logged_in'] = pdao.field(pdao.where('email', profile.email), 'id')[0][0] else: logging.info('add profile %s FAILED', profile.name) return redirect('/')
def register(): logging.debug('add profile form : %s', str(request.form)) logging.info('receive socket from /register-data -> profile: %s', request.form['profile-name']) form = request.form if form['profile-password'] != form['profile-repassword']: return render_template('v3-login.html', error=_('Your confirmation password does not match the password you entered')) profile = Profile() profile.name = form['profile-name'] profile.firstname = form['profile-firstname'] profile.address = form['profile-address'] profile.comp_address = form['profile-comp_address'] profile.city = form['profile-city'] profile.zipcode = form['profile-zipcode'] profile.country = form['profile-country'] profile.phone = form['profile-phone'] profile.email = form['profile-email'] profile.siret = form['profile-siret'] profile.password = form['profile-password'] pdao = ProfileDAO() if pdao.insert(profile): logging.info('add profile %s OK', profile.name) session['logged_in'] = pdao.field(pdao.where('email', profile.email), 'id')[0][0] else: logging.info('add profile %s FAILED', profile.name) return render_template('v3-login.html', error=_('Impossible to create new user, please contact an admin !')) return redirect('/')