コード例 #1
0
def edit_profile():
    if current_user.hindi != True:
        form = EditProfileForm(current_user.username)
    else:
        form = EditProfileFormHINDI(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        current_user.darkmode = form.darkmode.data
        current_user.hindi = form.hindi.data
        current_user.email = form.email.data
        db.session.commit()
        if current_user.hindi != True:
            flash(_('Your changes have been saved.'))
        else:
            flash(_('आपका बदलाव सहेज लिया गया है।'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
        form.darkmode.data = current_user.darkmode
        form.hindi.data = current_user.hindi
        form.email.data = current_user.email
    if current_user.hindi != True:
        return render_template('edit_profile.html', title=_('Edit Profile'),
                            form=form,dm=current_user.darkmode)
    else:
        return render_template('Hindi/edit_profile.html', title=_('Edit Profile'),
                            form=form,dm=current_user.darkmode)
コード例 #2
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        dt = form.dtype.data
        current_user.diatype = dtype(dt)
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        current_user.height = form.height.data
        current_user.weight = form.weight.data
        current_user.kkal = form.kkal.data
        current_user.sugarlevel = form.BG.data
        current_user.carbohydrates_level = form.carb.data
        current_user.BMI = BMI(form)
        db.session.commit()
        flash(_('Изменения сохранены'))
        return redirect(url_for('auth.edit_profile'))
    elif request.method == 'GET':
        if current_user.doctor == 0:
            dt = curdtype()
            form.dtype.data = dt
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
        form.height.data = current_user.height
        form.weight.data = current_user.weight
        form.BG.data = current_user.sugarlevel
        form.kkal.data = current_user.kkal
        form.carb.data = current_user.carbohydrates_level
    return render_template('edit_profile.html',
                           title=_('Edit Profile'),
                           form=form)
コード例 #3
0
ファイル: routes.py プロジェクト: cp2004/Scoreboard-web
def edit_profile():
    current_app.logger.info(
        f"{request.method} Request for edit profile from user { current_user.username } IP {request.remote_addr} "
    )
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_app.logger.debug(
            f"Edit profile form validated for user {current_user.username}")
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        current_user.initial = form.initial.data
        current_user.email = form.email.data
        db.session.commit()
        flash('Your changes have been saved.', category='success')
        return redirect(url_for('main.user', username=current_user.username))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
        form.initial.data = current_user.initial
        form.email.data = current_user.email

    games = game_data.getIndex()
    return render_template('main/edit_profile.html',
                           reversed=reversed,
                           title='Edit Profile',
                           form=form,
                           user=current_user,
                           games=games,
                           game_data=game_data,
                           User=User)
コード例 #4
0
def edit_profile():
    """
    This allows editing of the profile.
    """

    # Instantiate the form
    form = EditProfileForm(current_user.username)

    # If past validation, during submission,
    if form.validate_on_submit():

        # assign username, about me info
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash("Your changes have been saved.")
        return redirect(url_for("main.edit_profile"))

    # if it is just to get data, load from database.
    elif request.method == "GET":
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me

    return render_template("edit_profile.html",
                           title="Edit Profile",
                           form=form)
コード例 #5
0
ファイル: views.py プロジェクト: yanxinorg/zheye
def edit_profile():
    """编辑个人资料"""
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.location = form.location.data
        current_user.sex = form.sex.data
        current_user.short_intr = form.short_intr.data
        current_user.school = form.school.data
        current_user.industry = form.industry.data
        current_user.discipline = form.discipline.data
        current_user.introduction = form.introduction.data
        db.session.add(current_user)
        db.session.commit()

        flash(constant.PROFILE_UPDATE)
        return redirect(url_for('main.people', username=current_user.username))

    form.name.data = current_user.name
    form.sex.data = current_user.sex or "man"
    form.short_intr.data = current_user.short_intr
    form.industry.data = current_user.industry
    form.school.data = current_user.school
    form.discipline.data = current_user.discipline
    form.introduction.data = current_user.introduction
    form.location.data = current_user.location

    return render_template('edit_profile.html', form=form, user=current_user, base64=base64)
コード例 #6
0
ファイル: routes.py プロジェクト: robertsvensk/webb_app_flask
def messages():
    current_user.last_message_read_time = datetime.utcnow()
    current_user.add_notification('unread_message_count', 0)
    db.session.commit()

    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Your changes have been saved.'))
        return redirect(url_for('main.user', username=username))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me

    page = request.args.get('page', 1, type=int)
    messages = current_user.messages_received.order_by(
        Message.timestamp.desc()).paginate(
            page, current_app.config['POSTS_PER_PAGE'], False)
    next_url = url_for('main.messages', page=messages.next_num) \
        if messages.has_next else None
    prev_url = url_for('main.messages', page=messages.prev_num) \
        if messages.has_prev else None
    return render_template('messages.html',
                           user=current_user,
                           messages=messages.items,
                           form=form,
                           next_url=next_url,
                           prev_url=prev_url)
コード例 #7
0
ファイル: routes.py プロジェクト: Stefan12321/meta-python_st
def account_settings():
    form = EditProfileForm(current_user.username)
    languages = ['uk', 'ru', 'en']

    select = request.form.get("languages")
    form.username.data = current_user.username
    if select == None:
        active_language = languages[0]
        if form.validate_on_submit():
            if form.username.data != None:
                current_user.username = form.username.data
            if form.password.data != None:
                current_user.password_hash = generate_password_hash(
                    form.password.data)
                print(current_user.password_hash)
            db.session.commit()
            flash(_('Your changes have been saved.'))
            return redirect(url_for('main.account_settings'))
    else:
        print(languages.index(select))
        active_language = languages[languages.index(select)]
        # print(session['lang'])
        session['lang'] = active_language
        # form.password.data = current_user.password_hash
        # pbkdf2:sha256:260000$EkCXwYeTYP39AJay$7084d46648ca80703fb6e87ca59378d9ccc4a57fcdd4db972d42b310de9df0bf
    return render_template('account_settings.html',
                           title=_('Account settings'),
                           form=form,
                           languages=languages,
                           active_language=active_language)
コード例 #8
0
ファイル: routes.py プロジェクト: ritacarp/bookreview
def edit_profile():
    print(f"\n\n1)  in main.edit_profile, method={request.method}")
    form = EditProfileForm()
    # if request.method == "POST":
    if form.validate_on_submit():
        print(
            f"2)  in main.edit_profile, in validate_on_submit method should be POST, methid is {request.method}"
        )
        person = People.query.filter_by(username=current_user.username).first()
        if person is not None:
            person.email = form.email.data
            person.first_name = form.first_name.data
            person.last_name = form.last_name.data
            print(f"3)  in main.edit_profile, before commit")
            db.session.commit()
            print(f"4)  in main.edit_profile, after commit")
            flash("Your profile has been updated successfully", "success")
            return redirect(url_for('main.person', username=person.username))

    person = People.query.filter_by(username=current_user.username).first()
    form.username.data = person.username
    form.email.data = person.email
    form.first_name.data = person.first_name
    form.last_name.data = person.last_name
    form.submit.label.text = 'Update Profile'

    return render_template('editProfile.html', title='Edit Profile', form=form)
コード例 #9
0
ファイル: routes.py プロジェクト: robertsvensk/webb_app_flask
def user(username):
    user = User.query.filter_by(username=username).first_or_404()
    page = request.args.get('page', 1, type=int)

    if user == current_user:
        form = EditProfileForm(current_user.username)
        if form.validate_on_submit():
            current_user.username = form.username.data
            current_user.about_me = form.about_me.data
            db.session.commit()
            flash(_('Your changes have been saved.'))
            return redirect(url_for('main.user', username=username))
        elif request.method == 'GET':
            form.username.data = current_user.username
            form.about_me.data = current_user.about_me
    else:
        form = MessageForm()
        if form.validate_on_submit():
            msg = Message(author=current_user,
                          recipient=user,
                          body=form.message.data)
            db.session.add(msg)
            user.add_notification('unread_message_count', user.new_message())
            db.session.commit()
            flash(_('Your message has been sent.'))
            return redirect(url_for('main.user', username=username))

    messages = current_user.messages_received \
        .order_by(Message.timestamp.desc()) \
        .limit(2)

    posts = current_user.posts.paginate(page,
                                        current_app.config['POSTS_PER_PAGE'],
                                        False)
    next_url = url_for('main.user', username=user.username, page=posts.next_num) \
        if posts.has_next else None
    prev_url = url_for('main.user', username=user.username, page=posts.prev_num) \
        if posts.has_prev else None
    return render_template('user.html',
                           form=form,
                           user=user,
                           messages=messages,
                           posts=posts.items,
                           next_url=next_url,
                           prev_url=prev_url)
コード例 #10
0
def edit_profile():
    form = EditProfileForm(current_user)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about = form.about.data
        db.session.commit()
        return "Updated successfully"
    else:
        return "There was an error!"
コード例 #11
0
def edit_profile():
    form = EditProfileForm(current_user.login)
    cursor = conn.cursor()
    vuz = form.SelVUZ.data
    cursor.execute('select idFack,nameFack from facultet where idvuz = %s', [vuz])
    fack = cursor.fetchall()
    conn.commit()
    kolvofack = len(fack)
    form.SelFack.choices = fack
    Fack = form.SelFack.data
    cursor.execute('select idKafedra,nameKafedra from kafedra where idfack = %s', [Fack])
    kaf = cursor.fetchall()
    conn.commit()
    form.SelKaf.choices = kaf
    Kaf = form.SelKaf.data
    if form.validate_on_submit():
        cursor = conn.cursor()
        current_user.fio = form.fio.data
        current_user.phone = form.phone.data
        current_user.gender = form.gender.data
        current_user.about_me = form.about_me.data
        current_user.avatar = form.avatar.data
        cursor.execute(
            'update Uzer set fio = %s, login = %s, phone = %s, gender = %s, about_me = %s, avatar = %s where login = %s',
            [current_user.fio, form.login.data, current_user.phone, current_user.gender, current_user.about_me,
             current_user.avatar, current_user.login])
        conn.commit()
        cursor.execute('SELECT iduser FROM VO WHERE iduser = %s', [current_user.id])
        iduser = cursor.fetchone()
        conn.commit()
        if iduser is None:
            cursor.execute('INSERT INTO VO(iduser,idvuz,idfack,idkafedra) VALUES(%s,%s,%s,%s)',
                           [current_user.id, vuz, Fack, Kaf])
            conn.commit()
        else:
            cursor.execute('UPDATE VO SET idvuz = %s,idfack = %s, idkafedra = %s WHERE iduser = %s',
                           [vuz, Fack, Kaf, current_user.id])
            conn.commit()
        current_user.login = form.login.data
        flash(_('Your changes have been saved.'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.fio.data = current_user.fio
        form.login.data = current_user.login
        form.phone.data = current_user.phone
        form.gender.data = current_user.gender
        form.about_me.data = current_user.about_me
        form.avatar.data = current_user.avatar
        cursor.execute('SELECT idvuz,idfack,idkafedra from VO where iduser = %s', [current_user.id])
        numb = cursor.fetchone()
        if numb is not None:
            form.SelVUZ.data = numb[0]
            form.SelFack.data = numb[1]
            form.SelKaf.data = numb[2]
    return render_template('edit_profile.html', title=_('Edit Profile'),
                           form=form, vuz=vuz, kolvofack=kolvofack, Kaf=Kaf, fack=fack)
コード例 #12
0
ファイル: routes.py プロジェクト: jacksmion/microblog
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title=_('Edit Profile'), form=form)
コード例 #13
0
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.add(current_user)
        flash('修改成功')
        return redirect(url_for('.user', username=current_user.username))
    form.username.data = current_user.username
    form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form)
コード例 #14
0
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('main.show_user', username=current_user.username))
    elif request.method == 'GET':
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title='Edit Profile',
                           form=form)
コード例 #15
0
ファイル: routes.py プロジェクト: Ploddish/eurovision-webapp
def edit_profile():
	form = EditProfileForm(current_user.username)
	if form.validate_on_submit():
		current_user.username = form.username.data
		current_user.emoji = form.emoji.data
		db.session.commit()		#pylint: disable=E1101
		flash('Your changes have been saved.')
		return redirect(url_for('main.user', username=current_user.username))
	elif request.method == 'GET':
		form.username.data = current_user.username
		form.emoji.data = current_user.emoji
	return render_template('edit_profile.html', title='Edit Profile', form=form)
コード例 #16
0
def edit_profile():
    form = EditProfileForm(original_username=current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Your changes have been saved.')
        return redirect(
            url_for('main.userprofile', username=current_user.username))
    return render_template('edit_profile.html',
                           title='Edit Profile',
                           form=form)
コード例 #17
0
ファイル: routes.py プロジェクト: dm-Andy/microblog
def profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('修改成功'))
        return redirect(url_for('main.profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('profile.html', title=_('个人资料编辑'), form=form)
コード例 #18
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.favorite_ip = form.favorite_ip.data
        db.session.commit()
        flash('Saved your changes, sir.')
        return redirect(url_for('main.user', username=current_user.username))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.favorite_ip.data = current_user.favorite_ip
    return render_template('edit_profile.html', title='Edit Profile', form=form)
コード例 #19
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.update_profile(form.username.data, form.about_me.data)
        flash(_('Your changes have been saved.'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me

    return render_template('edit_profile.html',
                           title=_('Edit Profile'),
                           form=form)
コード例 #20
0
ファイル: routes.py プロジェクト: dungdiver/X_pro_flask
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        db.session.commit()
        flash('Đã sửa')
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        return render_template('edit_profile.html',
                               title='Edit Profile',
                               form=form)
コード例 #21
0
ファイル: routes.py プロジェクト: sawafrolov/FlaskExample
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        update_user_profile(current_user, form.username.data,
                            form.about_me.data)
        flash(_("Your changes have been saved."))
        return redirect(url_for("main.user", username=current_user.username))
    form.username.data = current_user.username
    form.about_me.data = current_user.about_me
    return render_template("main/edit_profile.html",
                           title=_("Edit Profile"),
                           form=form)
コード例 #22
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Изменения успешно сохранены'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form, title=_('Редактировать профиль'))
コード例 #23
0
ファイル: routes.py プロジェクト: andrejceraj/Flask-blog
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Your changes are successfully saved')
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form)
コード例 #24
0
ファイル: routes.py プロジェクト: kadakia/rohanapp
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('main.edit_profile')) # Shouldn't we redirect to the user's updated profile?
    elif request.method == 'GET':
        form.username.data = current_user.username # fields pre-populated with current data
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title = 'Edit Profile', form = form)
コード例 #25
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Ваши изменения были сохранены')
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form )
コード例 #26
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        User.commit_user()
        flash(_('Your changes have been saved'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form, title='Edit Profile')
コード例 #27
0
def edit():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_("Изменения успешно сохранены"))
        return redirect(url_for("main.edit"))
    elif request.method == "GET":
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template("main/edit_profile.html", form=form)
コード例 #28
0
def edit_profile():
    form=EditProfileForm()
    if form.validate_on_submit():
        current_user.username=form.username.data
        current_user.about_me=form.about_me.data
        db.session.commit()
        flash(_('Your profile has been updated'))
        return redirect(url_for('main.edit_profile'))
    elif request.method =='GET':
        form.username.data=current_user.username
        form.about_me.data=current_user.about_me
    return render_template('edit_profile.html',title=_('Edit profile'),form=form)
コード例 #29
0
ファイル: routes.py プロジェクト: hgirish/microblog
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash("Your changes have been saved.")
        return redirect(url_for("main.edit_profile"))
    elif request.method == "GET":
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template("edit_profile.html", title="Edit Profile", form=form)
コード例 #30
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Suas mudanças foram salvas.'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title=_('Editar Perfil'), form=form)
コード例 #31
0
ファイル: views.py プロジェクト: keer2345/flasky
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        db.session.add(current_user)
        flash('Your profile has been updated')
        return redirect(url_for('.user', username=current_user.username))
    form.name.data = current_user.name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form)
コード例 #32
0
ファイル: routes.py プロジェクト: hvosdt/microblog
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Your changes have been saved.'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title=_('Edit Profile'),
                           form=form)
コード例 #33
0
ファイル: views.py プロジェクト: owen-hzy/scalable-album
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        try:
            db.session.add(current_user)
            db.session.commit()
        except:
            db.session.rollback()
        flash("Your profile has been updated")
        return redirect(url_for(".user", username=current_user.username))
    form.name.data = current_user.name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template("edit_profile.html", form=form)
コード例 #34
0
ファイル: views.py プロジェクト: Jeffiy/zblog
def edit_profile(username):
    user = User.query.filter_by(username=username).first()
    if not user:
        abort(404)
    form = EditProfileForm(user=user)
    if form.validate_on_submit():
        user.email = form.email.data
        user.username = form.username.data
        user.name = form.name.data
        user.location = form.location.data
        user.about_me = form.about_me.data
        db.session.add(user)
        flash('个人信息已更新.')
        return redirect(url_for('.user', username=user.username))
    form.email.data = user.email
    form.username.data = user.username
    form.name.data = user.name
    form.location.data = user.location
    form.about_me.data = user.about_me
    return render_template('edit_profile.html', form=form, user=user)
コード例 #35
0
ファイル: views.py プロジェクト: pureblue14/blog
from flask import render_template, abort, flash, redirect, url_for, request, current_app