def create_document(): '''This routine displays an editing page for creating an document.''' form = Documents() if form.is_submitted(): if form.validate() and request.form.get('submit'): Documents.create_unit(form) return redirect(url_for('web.display_document', name=form.getName())) else: return redirect(url_for('web.display_admin_documents')) else: form.initialize(action='create') return display_content( form=form, title='Create document', breadcrumbs=get_breadcrumbs('documents', 'create') )
def update_document(name): '''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 = Documents() if form.is_submitted(): if form.validate() and request.form.get('submit'): Documents.update_unit(form) return redirect(url_for('web.display_document', name=form.getName())) else: document = Documents.read_unit(name) if document: form.initialize(name=name, action='update', document=document) return display_content( form=form, title='Edit: ' + name, breadcrumbs=get_breadcrumbs('documents', name, 'edit') ) return redirect(url_for('web.display_admin_documents'))