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)
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)
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)
def new_preferences(id): form = NewPreferenceForm() form.set_choices() return render_template('preferences/new.html', form=form)