From 9c027902a16ac2f81a26be9acd3877c8889da7ef Mon Sep 17 00:00:00 2001 From: sanj Date: Sun, 18 Jul 2010 01:56:05 +0530 Subject: [PATCH] added load srt --- lists/views.py | 2 ++ static/js/translate.js | 8 ++++++++ templates/translate.html | 11 ++++++++++- translate/views.py | 10 ++++++++++ urls.py | 1 + 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lists/views.py b/lists/views.py index ffa2abf..805af1e 100644 --- a/lists/views.py +++ b/lists/views.py @@ -24,6 +24,8 @@ def fetchJson(request): def translate(request): return render_to_response("translate.html", {'padma_url': PADMA_URL}) + + def fetchSrt(request): if request.GET['id']: padmaId = request.GET['id'] diff --git a/static/js/translate.js b/static/js/translate.js index a635c64..0734821 100644 --- a/static/js/translate.js +++ b/static/js/translate.js @@ -51,6 +51,14 @@ $(document).ready(function() { alert(response); }); }); + $('#loadSrt').click(function() { + $.get("loadSrt", { + 'padmaId': $('#padmaId').val(), + 'language': $('#languageLoad').val() + }, function(srt) { + $('#newSrt').val(srt); + }); + }); }); function s2npt(s) { diff --git a/templates/translate.html b/templates/translate.html index 6f00cf3..7e43ceb 100644 --- a/templates/translate.html +++ b/templates/translate.html @@ -53,11 +53,20 @@ html, body {
-
+ + + +
diff --git a/translate/views.py b/translate/views.py index 6e3c2bc..4a0c8c0 100644 --- a/translate/views.py +++ b/translate/views.py @@ -9,3 +9,13 @@ def saveSrt(request): srt = Srt(txt=txt, language=lang, padmaId=padmaId) srt.save() return HttpResponse("saved") + +def loadSrt(request): + padmaId = request.GET['padmaId'] + lang = request.GET['language'] + srt = Srt.objects.filter(padmaId=padmaId).filter(language=lang) + if len(srt) > 0: + ret = srt[0].txt + else: + ret = "No Srt for this language found" + return HttpResponse(ret) diff --git a/urls.py b/urls.py index ec8b71f..ec09d2d 100644 --- a/urls.py +++ b/urls.py @@ -13,6 +13,7 @@ urlpatterns = patterns('', (r'^fetchSrt', 'lists.views.fetchSrt'), (r'^translate', 'lists.views.translate'), (r'^saveSrt', 'translate.views.saveSrt'), + (r'^loadSrt', 'translate.views.loadSrt'), (r'^$', 'lists.views.index'), # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: