def display_document(name): '''This routine displays a given document. It is not password protected because all documents are visible to all visitors. ''' document = check_unit(Documents.read_unit(name)) return display_content( breadcrumbs=get_breadcrumbs('documents', name), title=document.get('title'), primary=document.get('content'), primaryListHr=False, editable=True, editableUrl=url_for('web.update_document', name=name) )
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'))