<s> from django . contrib import messages <EOL> from django . core . mail import mail_admins <EOL> from django . core . urlresolvers import reverse <EOL> from django . shortcuts import render_to_response , HttpResponseRedirect <EOL> from django . template import RequestContext <EOL> from messaging . forms import ContactForm <EOL> from settings import ADMINS , DEBUG <EOL> def contact ( request ) : <EOL> admins_available = True if ADMINS else False <EOL> form = ContactForm ( ) <EOL> if request . method == '<STR_LIT:POST>' : <EOL> form = ContactForm ( request . POST ) <EOL> if form . is_valid ( ) : <EOL> msg = u'<STR_LIT>' . format ( form . cleaned_data [ '<STR_LIT:email>' ] , form . cleaned_data [ '<STR_LIT:message>' ] ) <EOL> mail_admins ( '<STR_LIT>' , msg , fail_silently = not DEBUG ) <EOL> messages . success ( request , '<STR_LIT>' ) <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> return render_to_response ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : form , <EOL> '<STR_LIT>' : admins_available , <EOL> } , context_instance = RequestContext ( request ) ) </s>
