예제 #1
0
def edit_preferences(id):
    user = User.query.get(id)
    form = NewPreferenceForm(obj=user)
    form.set_choices()
    return render_template('users/edit_preferences.html',
                           form=form,
                           id=current_user.id)
예제 #2
0
def preferences(id):
    form = NewPreferenceForm(request.form)
    form.set_choices()
    if request.method == 'POST':
        for preference in form.preference.data:
            current_user.preferences.append(Preference.query.get(preference))
        db.session.add(current_user)
        db.session.commit()
        return redirect(url_for('users.request_data', id=current_user.id))
    return render_template('users/show.html', form=form)
예제 #3
0
def show_preferences(id):
    form = NewPreferenceForm()
    form.set_choices()
    if request.method == b'PATCH':

        for preference in form.preference.data:
            current_user.preferences.append(Preference.query.get(preference))

        db.session.add(current_user)
        db.session.commit()

        # current_user.preferences = request.form['preferences']
        # db.session.add(current_user)
        # db.session.commit()
        return redirect(url_for('users.request_data', id=current_user.id))
    return render_template('preferences/show.html', id=current_user.id)
예제 #4
0
def new_preferences(id):
    form = NewPreferenceForm()
    form.set_choices()
    return render_template('preferences/new.html', form=form)