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'))
def contact(): '''Configure and display the contact us page, with its input form and email feature. ''' form = Contacts() if form.is_submitted(): if request.form.get('cancel'): return redirect(url_for('web.display_index')) if form.validate(): Contacts.send_email(mail, form) return redirect(url_for('web.display_index')) flash('All fields are required.') department = Departments.read_unit('cs') return display_content( form=form, title='Contact Us', primary=department.get('contact'), sideTitle='Admissions at Calvin', sideContent='''<p>Interested in what Calvin has to offer?<br> <a href="http://www.calvin.edu/admissions/visit/">Schedule a visit</a> or <br><a href="http://www.calvin.edu/admissions/contact/request/">request more information</a>.</p>''', breadcrumbs=get_breadcrumbs('contact'), editable=True, editableUrl=url_for('web.update_department', name='cs') )
def display_research(): '''Configure and display the research overview page.''' department = check_unit(Departments.read_unit('cs')) return display_content( breadcrumbs=get_breadcrumbs('research'), image=Images.read_tagged_unit('research'), title='Research', primary=department.get('research'), editable=True, editableUrl=url_for('web.update_department', name='cs') )
def display_honors(): '''Display information on the honors program.''' department = check_unit(Departments.read_unit('cs')) return display_content( breadcrumbs=get_breadcrumbs('academics', 'honors'), image=Images.read_tagged_unit('academics.honors'), title='Graduating with Honors', primary=department.get('honors'), editable=True, editableUrl=url_for('web.update_department', name='cs') )
def display_courses(): '''Configure and display the courses list page.''' department = check_unit(Departments.read_unit('cs')) courses = check_unit(Courses.read_units()) return display_content( breadcrumbs=get_breadcrumbs('academics', 'courses'), image=Images.read_tagged_unit('courses'), title='Courses & Materials', tabList=create_course_tab_list(courses, department), editable=True, editableUrl=url_for('web.update_department', name='cs') )
def display_about(): '''Configure and display the about page, with an appropriate image and the department long description. ''' department = check_unit(Departments.read_unit('cs')) return display_content( breadcrumbs=get_breadcrumbs('about'), image=Images.read_tagged_unit('about'), title='About Us', primary=department.get('longDescription'), editable=True, editableUrl=url_for('web.update_department', name='cs') )
def display_index(): '''Configure and display the main index page, with an appropriate image, the department short description and a list of current news articles. ''' department = check_unit(Departments.read_unit('cs')) return display_content( image=Images.read_tagged_unit('departments.cs'), title=department.get('title'), subtitle=department.get('tagline'), primary=department.get('shortDescription'), sideTitle='Computing News', sideList=create_brief_news_list(News.read_units(limit=2 + TechNews.TECH_NEWS_LIMIT)), editable=True, editableUrl=url_for('web.update_department', name='cs') )