def update_scholarship(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 = Scholarships() if form.is_submitted(): if form.validate() and request.form.get('submit'): Scholarships.update_unit(form) return redirect(url_for('web.display_scholarship', name=form.getName())) else: scholarship = Scholarships.read_unit(name) if scholarship: form.initialize(name=name, action='update', scholarship=scholarship) return display_content( form=form, title='Edit: ' + name, breadcrumbs=get_breadcrumbs('scholarships', name, 'edit') ) return redirect(url_for('web.display_admin_scholarships'))
def display_scholarship(name): '''This routine displays a given scholarship.''' scholarship = check_unit(Scholarships.read_unit(name)) # Add scholarship details in side bar if they exist. sideContent = create_scholarship_side(scholarship) sideTitle = None if sideContent: sideTitle = 'Details' return display_content( breadcrumbs=get_breadcrumbs('scholarships', name), title=scholarship.get('title'), primary=create_scholarship_content(scholarship), sideTitle=sideTitle, sideContent=sideContent, primaryListHr=False, editable=True, editableUrl=url_for('web.update_scholarship', name=name) )