<s> from django . shortcuts import render <EOL> from django . core import serializers <EOL> from landpage . models import LandpageTeamMember <EOL> from landpage . models import LandpageTopPickCourse <EOL> from landpage . models import LandpageCoursePreview <EOL> from landpage . models import CoursePreview <EOL> from landpage . models import LandpageContactMessage <EOL> from landpage . models import LandpagePartner <EOL> from registrar . models import Course <EOL> from landpage . form import ContactForm <EOL> import json <EOL> from django . http import HttpResponse <EOL> from django . conf import settings <EOL> def landpage_page ( request ) : <EOL> top_courses = LandpageTopPickCourse . objects . all ( ) <EOL> course_previews = LandpageCoursePreview . objects . all ( ) <EOL> team_members = LandpageTeamMember . objects . all ( ) . order_by ( '<STR_LIT:id>' ) <EOL> partners = LandpagePartner . objects . all ( ) <EOL> contact_form = ContactForm ( ) <EOL> return render ( request , '<STR_LIT>' , { <EOL> '<STR_LIT>' : top_courses , <EOL> '<STR_LIT>' : course_previews , <EOL> '<STR_LIT>' : team_members , <EOL> '<STR_LIT>' : partners , <EOL> '<STR_LIT>' : contact_form , <EOL> '<STR_LIT>' : settings . APPLICATION_HAS_ADVERTISMENT , <EOL> '<STR_LIT>' : settings . AGENCY_CSS_LIBRARY_URLS , <EOL> '<STR_LIT>' : settings . AGENCY_JS_LIBRARY_URLS <EOL> } ) <EOL> def course_preview_modal ( request ) : <EOL> course = None <EOL> if request . method == u'<STR_LIT:POST>' : <EOL> POST = request . POST <EOL> course_id = POST . get ( '<STR_LIT>' ) <EOL> if course_id is not None : <EOL> try : <EOL> course = Course . objects . get ( id = int ( course_id ) ) <EOL> except Course . DoesNotExist : <EOL> pass <EOL> return render ( request , '<STR_LIT>' , { <EOL> '<STR_LIT>' : course <EOL> } ) <EOL> def save_contact_us_message ( request ) : <EOL> response_data = { '<STR_LIT:status>' : '<STR_LIT>' , '<STR_LIT:message>' : '<STR_LIT>' } <EOL> if request . is_ajax ( ) : <EOL> if request . method == '<STR_LIT:POST>' : <EOL> try : <EOL> form = ContactForm ( request . POST ) <EOL> if form . is_valid ( ) : <EOL> name = request . POST [ '<STR_LIT:name>' ] <EOL> email = request . POST [ '<STR_LIT:email>' ] <EOL> phone = request . POST [ '<STR_LIT>' ] <EOL> message = request . POST [ '<STR_LIT:message>' ] <EOL> LandpageContactMessage . objects . create ( <EOL> name = name , <EOL> email = email , <EOL> phone = phone , <EOL> message = message , <EOL> ) . save ( ) <EOL> response_data = { '<STR_LIT:status>' : '<STR_LIT:success>' , '<STR_LIT:message>' : '<STR_LIT>' } <EOL> else : <EOL> response_data = { '<STR_LIT:status>' : '<STR_LIT>' , '<STR_LIT:message>' : json . dumps ( form . errors ) } <EOL> except : <EOL> response_data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT:message>' : '<STR_LIT>' + name + '<STR_LIT:U+0020>' + email + '<STR_LIT:U+0020>' + phone + '<STR_LIT:U+0020>' + message <EOL> } <EOL> return HttpResponse ( json . dumps ( response_data ) , content_type = "<STR_LIT:application/json>" ) </s>
