def adduser(): """ Build the view used to add new accounts """ form = RegisterForm() if form.validate_on_submit(): try: user = Users(username=form.username.data, email=form.email.data, specialties=form.specialties.data.split(','), interests=form.interests.data.split(',')) user.password = form.password.data user.save() token = user.generate_confirmation_token() send_email(user.email, 'Confirmare email', 'users/email/confirm', user=user, token=token) flash('Contul a fost adaugat!', category='alert-success') except Exception as err: flash('Utilizatorul are deja cont!', category='alert-warning') return redirect(url_for('users.list')) return render_template('users/add.html', pagetitle='Adauga utilizator', form=form)
def registeruser(): """ Build the view used to add new accounts """ form = RegisterForm() if form.validate_on_submit(): try: user = Users(username=form.username.data, email=form.email.data, specialties=form.specialties.data.split(','), interests=form.interests.data.split(',')) user.password = form.password.data user.save() token = user.generate_confirmation_token() send_email(user.email, 'Confirmare email', 'users/email/confirm', user=user, token=token) flash( 'Contul a fost adaugat! Va rugam confirmati adresa de email!', category='alert-success') except Exception as err: flash('Contul nu poate fi creat!', category='alert-warning') return redirect(url_for('users.login')) return render_template('users/login.html', pagetitle='Inregistrare', form=form, login=False)
def create_admins(admin): from app.users.models import Users try: user = Users.objects(email=admin['email']).get() except: user = Users(email=admin['email'],username=admin['username'],permissions='full',status=True) user.password = admin['password'] user.save()
def registeruser(): """ Build the view used to add new accounts """ form = RegisterForm() if form.validate_on_submit(): try: user = Users(username=form.username.data,email=form.email.data,specialties=form.specialties.data.split(','),interests=form.interests.data.split(',')) user.password = form.password.data user.save() token = user.generate_confirmation_token() send_email(user.email,'Confirmare email','users/email/confirm',user=user,token=token) flash('Contul a fost adaugat! Va rugam confirmati adresa de email!', category='alert-success') except Exception as err: flash('Contul nu poate fi creat!', category='alert-warning') return redirect(url_for('users.login')) return render_template('users/login.html',pagetitle='Inregistrare',form=form,login=False)
def adduser(): """ Build the view used to add new accounts """ form = RegisterForm() if form.validate_on_submit(): try: user = Users(username=form.username.data,email=form.email.data,specialties=form.specialties.data.split(','),interests=form.interests.data.split(',')) user.password = form.password.data user.save() token = user.generate_confirmation_token() send_email(user.email,'Confirmare email','users/email/confirm',user=user,token=token) flash('Contul a fost adaugat!', category='alert-success') except Exception as err: flash('Utilizatorul are deja cont!', category='alert-warning') return redirect(url_for('users.list')) return render_template('users/add.html',pagetitle='Adauga utilizator',form=form)