コード例 #1
0
def genvasc_collaborators_delegate_edit(id):
    practice = _genvasc_collaborator_get_session_practice()
    delegate = Delegate.query.get(id)

    if (practice != delegate.practice):
        flash("Permission denied.", "error")
        return redirect(url_for('genvasc_collaborators_delegates'))        

    (fullyBookedMeetings, availableMeetings) = _genvasc_collaborator_get_meetings(delegate.meetingId)

    form = DelegateEditForm(obj=delegate)
    form.meetingId.choices = [(m.id, m.name_with_spaces_remaining()) for m in availableMeetings]

    if form.validate_on_submit():
        form.populate_obj(delegate)
        db.session.add(delegate)
        db.session.commit()
        return redirect(url_for('genvasc_collaborators_delegates'))

    return render_template('genvasc_collaborators/delegate_form.html', form=form, fullyBookedMeetings=fullyBookedMeetings)
コード例 #2
0
def genvasc_collaborators_delegate_new():
    practice = _genvasc_collaborator_get_session_practice()

    if (not practice):
        return redirect(url_for('genvasc_collaborators_introduction'))

    if (practice.delegate_allocation_full()):
        flash("Cannot add delegate to practice as you have reached your allocation limit.", "error")
        return redirect(url_for('genvasc_collaborators_delegates'))

    (fullyBookedMeetings, availableMeetings) = _genvasc_collaborator_get_meetings()

    form = DelegateEditForm()
    form.meetingId.choices = [(m.id, m.name_with_spaces_remaining()) for m in availableMeetings]

    if form.validate_on_submit():
        delegate = Delegate(practiceId=practice.id)
        form.populate_obj(delegate)
        db.session.add(delegate)
        db.session.commit()

        return redirect(url_for('genvasc_collaborators_delegates'))

    return render_template('genvasc_collaborators/delegate_form.html', form=form, fullyBookedMeetings=fullyBookedMeetings)