コード例 #1
0
ファイル: views.py プロジェクト: Calvin-CS/csweb
def update_department(name):
    '''Configure the editing for the about page, which must edit the long
    description of the department. There is only one department, name==cs.

    For GET requests, this method allows the administrator to edit the named
    document. For POST requests, this method saves the edits made by the
    administrator and then reloads/redisplays the document administration page.
    Non-authenticated users are redirected to the login page. documents that
    don't exist can't be edited. Because we don't show individual documents,
    all redirects go to the documents administration page.
    '''
    form = Departments()
    if form.is_submitted():
        if form.validate() and request.form.get('submit'):
            Departments.update_unit(form)
    else:
        department = Departments.read_unit(name)
        if department:
            form.initialize(name=name, action='update', department=department)
            return display_content(
                form=form,
                title='Edit: ' + name,
                breadcrumbs=get_breadcrumbs('departments', name, 'edit')
            )
    return redirect(url_for('web.display_about'))