From 3e77f7c5caedad57f85c52ef1bd9d791b94c20e5 Mon Sep 17 00:00:00 2001 From: sanj Date: Mon, 20 Sep 2010 05:33:41 +0530 Subject: [PATCH] email experiences and we're done --- vurbanism/flyovers/views.py | 26 +++++++++- vurbanism/static/css/vurbanism.css | 12 +++-- vurbanism/static/js/vurbanism.js | 16 +++++- vurbanism/templates/flyovers.html | 83 +++++++++++++++++++----------- vurbanism/urls.py | 1 + 5 files changed, 103 insertions(+), 35 deletions(-) diff --git a/vurbanism/flyovers/views.py b/vurbanism/flyovers/views.py index 05dbcf8..9a10e4a 100644 --- a/vurbanism/flyovers/views.py +++ b/vurbanism/flyovers/views.py @@ -1,9 +1,17 @@ # Create your views here. from django.shortcuts import render_to_response +from django.http import HttpResponse from django.shortcuts import get_object_or_404 from oxdjango.shortcuts import render_to_json_response +from django.core.mail import send_mail from models import * +QUESTIONS = { + '1problems': 'What problems do flyover and skywalk projects create?', + '2like': 'What do you like about these projects?', + '3stories': 'Do you have any stories about flyovers or skywalks in Mumbai or elsewhere?' +} + def geojson(request): features = [] for f in Flyover.objects.all(): @@ -15,7 +23,8 @@ def geojson(request): return render_to_json_response(d) def index(request): - return render_to_response('flyovers.html', {}) + + return render_to_response('flyovers.html', {'questions': QUESTIONS}) def flyover(request): i = request.GET['id'] @@ -26,6 +35,21 @@ def flyover(request): } return render_to_json_response(d) +def email_experiences(request): + if not request.POST: + return HttpResponse("0") + if request.is_ajax(): + a = request.POST + eml_txt = "Name: %s\n Email: %s\n\n" % (a['name'], a['email'],) + for key, val in QUESTIONS.items(): + eml_txt += "%s %s" % (val, a[key],) + eml_txt += "\n\n" + send_mail("Vertical Urbanism Questions", eml_txt, "do-not-reply@verticalurbanism.com", ['sanjaybhangar@gmail.com', 'andrew.harris@ucl.ac.uk']) + return HttpResponse("1") + else: + return HttpResponse("0") + + def category(request): cat_id = request.GET['id'] cat_type = request.GET['type'] diff --git a/vurbanism/static/css/vurbanism.css b/vurbanism/static/css/vurbanism.css index 7b5cead..14fb6b3 100644 --- a/vurbanism/static/css/vurbanism.css +++ b/vurbanism/static/css/vurbanism.css @@ -153,9 +153,6 @@ a img { } -.navContent { - display: none; -} .contentWrapper { height: 96%; @@ -167,3 +164,12 @@ a img { margin-right: auto; font-family: Arial, Verdana, Georgia, sans-serif; } + +.questionWrapper { + margin-bottom: 8px; +} + +.answer textarea { + width: 80%; + height: 100px; +} diff --git a/vurbanism/static/js/vurbanism.js b/vurbanism/static/js/vurbanism.js index bc08148..ff98473 100644 --- a/vurbanism/static/js/vurbanism.js +++ b/vurbanism/static/js/vurbanism.js @@ -200,7 +200,8 @@ $(function() { $('.selected').removeClass('selected'); $('.navSelected').removeClass('navSelected'); $(this).addClass('navSelected'); - var html = $('#' + $(this).attr("data-target")).html(); +// var html = $('#' + $(this).attr("data-target")).html(); + var html = tmpl('tmpl_' + $(this).attr('data-target'), {}); $('#media').html(html); }); @@ -230,3 +231,16 @@ $('.flyoverImage').live("mouseout", function() { mapControl.unselect(currentlySelectedFeature); }); +$('#submitQuestions').live("click", function() { + $(this).attr("disabled", "disabled"); + $(this).text("Thanks!"); + $.post("/email_experiences", { + '1problems': $('#1problems').val(), + '2like': $('#2like').val(), + '3stories': $('#3stories').val(), + 'name': $('#name').val(), + 'email': $('#email').val() + }, function(response) { + $('#media').html("Thanks! Your response has been emailed to andrew dot harris at ucl.ac.uk"); + }); +}); diff --git a/vurbanism/templates/flyovers.html b/vurbanism/templates/flyovers.html index 1b8533e..3dffd2c 100644 --- a/vurbanism/templates/flyovers.html +++ b/vurbanism/templates/flyovers.html @@ -54,6 +54,58 @@ + + + +
@@ -100,43 +152,14 @@
- - diff --git a/vurbanism/urls.py b/vurbanism/urls.py index f1b2a94..4196c95 100644 --- a/vurbanism/urls.py +++ b/vurbanism/urls.py @@ -16,6 +16,7 @@ urlpatterns = patterns('', (r'^geojson$', 'flyovers.views.geojson'), (r'^flyover$', 'flyovers.views.flyover'), (r'^category$', 'flyovers.views.category'), + (r'^email_experiences$', 'flyovers.views.email_experiences'), # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), )