def add_session(): form = AddSession() action = url_for('admin.add_session') choices_session = [(TALKS, 'Charlas'), (BARCAMPS, 'Mesas de trabajo'), (WORKSHOPS, 'Talleres')] form.session_type.choices = choices_session query_room = Room.query.all() choices_room = [(c.id, c.name) for c in query_room] form.room_id.choices = choices_room query_fas = Speaker.query.filter(Speaker.active == 1).all() choices_fas = [(c.fas, c.names) for c in query_fas] form.fas.choices = choices_fas if form.validate_on_submit(): session = Session(name=form.name.data, topic=form.topic.data, description=form.description.data, session_type=form.session_type.data, fas=form.fas.data, room_id=form.room_id.data, day=form.day.data, time_start=form.time_start.data, time_end=form.time_end.data, active=form.active.data) db.session.add(session) db.session.commit() flash(u'Sesión creada') return redirect(url_for('admin.sessions')) return render_template('backend/sessions_actions.html', form=form, title=u"Añadir sesión", action=action)
def edit_session(session_id): query_edit_session = Session.query.filter(Session.id == session_id).first() form = AddSession(obj=query_edit_session) action = url_for('admin.edit_session', session_id=session_id) if form.validate_on_submit(): form.populate_obj(query_edit_session) db.session.commit() flash('Sesion actualizada') return redirect(url_for('admin.sessions')) return render_template('backend/sessions_actions.html', title=u'Editar sesión', form=form, action=action)
def edit_session(session_id): query_edit_session = Session.query.filter(Session.id == session_id).first() form = AddSession(obj=query_edit_session) action = url_for('admin.edit_session', session_id=session_id) choices_session = [(TALKS, 'Charlas'), (BARCAMPS, 'Mesas de trabajo'), (WORKSHOPS, 'Talleres')] form.session_type.choices = choices_session query_fas = Speaker.query.filter(Speaker.active == 1).all() choices_fas = [(c.fas, c.names) for c in query_fas] form.fas.choices = choices_fas if form.validate_on_submit(): form.populate_obj(query_edit_session) db.session.commit() flash('Sesion actualizada') return redirect(url_for('admin.sessions')) return render_template('backend/sessions_actions.html', title=u'Editar sesión', form=form, action=action)
def add_session(): form = AddSession() action = url_for('admin.add_session') choices_session = [(TALKS, 'Charlas'), (BARCAMPS, 'Mesas de trabajo'), (WORKSHOPS, 'Talleres')] form.session_type.choices = choices_session query_fas = Speaker.query.filter(Speaker.active == 1).all() choices_fas = [(c.fas, c.names) for c in query_fas] form.fas.choices = choices_fas if form.validate_on_submit(): session = Session(name=form.name.data, topic=form.topic.data, description=form.description.data, session_type=form.session_type.data, fas=form.fas.data, active=form.active.data) db.session.add(session) db.session.commit() flash(u'Sesión creada') return redirect(url_for('admin.sessions')) return render_template('backend/sessions_actions.html', form=form, title=u"Añadir sesión", action=action)