<s> from django . core . mail . message import EmailMessage <EOL> from django . core . urlresolvers import reverse <EOL> from django . http import HttpResponseRedirect <EOL> from django . shortcuts import render_to_response <EOL> from django . template . context import RequestContext <EOL> from dnd . menu import menu_item , submenu_item , MenuItem <EOL> from dnd . forms import ContactForm <EOL> from dnd . models import StaticPage <EOL> @ menu_item ( MenuItem . CONTACTS ) <EOL> @ submenu_item ( MenuItem . Contacts . CONTACT_US ) <EOL> def contact ( request ) : <EOL> if request . method == '<STR_LIT:POST>' : <EOL> form = ContactForm ( request . POST , <EOL> initial = { <EOL> '<STR_LIT>' : request . META [ '<STR_LIT>' ] } ) <EOL> if form . is_valid ( ) : <EOL> if form . cleaned_data [ '<STR_LIT>' ] : <EOL> headers = { <EOL> '<STR_LIT>' : form . cleaned_data [ '<STR_LIT>' ] } <EOL> else : <EOL> headers = { } <EOL> email = EmailMessage ( <EOL> subject = form . cleaned_data [ '<STR_LIT>' ] , <EOL> body = "<STR_LIT>" % ( form . cleaned_data [ '<STR_LIT:message>' ] , <EOL> form . cleaned_data [ '<STR_LIT>' ] ) , <EOL> from_email = '<STR_LIT>' , <EOL> to = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> headers = headers , <EOL> ) <EOL> email . send ( ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> else : <EOL> form = ContactForm ( ) <EOL> return render_to_response ( '<STR_LIT>' , <EOL> { <EOL> '<STR_LIT>' : request , <EOL> '<STR_LIT>' : form , } , context_instance = RequestContext ( request ) , ) <EOL> @ menu_item ( MenuItem . CONTACTS ) <EOL> @ submenu_item ( MenuItem . Contacts . CONTACT_US ) <EOL> def contact_sent ( request ) : <EOL> return render_to_response ( '<STR_LIT>' , <EOL> { <EOL> '<STR_LIT>' : request , <EOL> } , context_instance = RequestContext ( request ) , ) <EOL> @ menu_item ( MenuItem . CONTACTS ) <EOL> @ submenu_item ( MenuItem . Contacts . STAFF ) <EOL> def staff ( request ) : <EOL> page_body = StaticPage . objects . filter ( name = '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> return render_to_response ( '<STR_LIT>' , <EOL> { <EOL> '<STR_LIT>' : request , <EOL> '<STR_LIT>' : page_body , <EOL> } , context_instance = RequestContext ( request ) , ) <EOL> @ menu_item ( MenuItem . ANDROID ) <EOL> def android ( request ) : <EOL> page_body = StaticPage . objects . get ( name = '<STR_LIT>' ) <EOL> return render_to_response ( '<STR_LIT>' , <EOL> { <EOL> '<STR_LIT>' : request , <EOL> '<STR_LIT>' : page_body , <EOL> } , context_instance = RequestContext ( request ) , ) </s>
