Exemplo n.º 1
0
 def validate_email(self, field):
     if re.fullmatch('^[a-zA-Z0-9\-._]+@[a-zA-Z0-9._\-]+\.[a-zA-Z0-9_\-]+$',
                     field.data) is None:
         raise ValidationError('Not a valid email address')
     if User.email_exists(
             field.data) and field.data != User.get_email(session['id']):
         raise ValidationError('email occupied')
Exemplo n.º 2
0
def settings_profile_view():
    if g.permission < 1:
        flash(NOT_AUTH_MSG, 'text-warning')
        return redirect('/')
    form = EditProfileForm()
    if form.validate_on_submit():
        User.update_profile(session['id'], form.login.data,
                            form.first_name.data, form.last_name.data,
                            form.birth_date.data, form.gender.data,
                            form.preferences.data, form.biography.data,
                            form.city.data, form.show_location.data)
        if form.passwd.data != '':
            User.update_passwd(session['id'], form.passwd.data)
        if form.email.data != User.get_email(session['id']):
            flash(UPDATE_EMAIL, 'text-success')
            User.send_update_email_rwquest(form.email.data, session['login'],
                                           session['id'])
        if form.interests.data != ', '.join(
                User.get_interests_list(session['id'])):
            User.update_interesrs(session['id'], form.interests.data)
        flash(UPDATED, 'text-success')
    User.fill_edit_profile_form_from_db(form, session['id'])
    return render_template('settings_profile.html', form=form)