示例#1
0
文件: views.py 项目: Calvin-CS/csweb
def update_program(name):
    '''Configure the editing for the program pages. Because all of the program
    data except the model schedule comes from CIT, this routine will only
    support updates to the model schedule. The administrator cannot edit
    the name of the program.
    '''
    form = Programs()
    if form.is_submitted():
        if form.validate() and request.form.get('submit'):
            Programs.update_unit(form)
    else:
        program = Programs.read_unit(name)
        if program:
            form.initialize(name=name, action='update', document=program)
            return display_content(
                form=form,
                title='Edit: ' + name,
                breadcrumbs=get_breadcrumbs('academics', name, 'edit')
            )
    return redirect(url_for('web.display_program', name=name))