added load srt

This commit is contained in:
sanj 2010-07-18 01:56:05 +05:30
parent 6f54f42048
commit 9c027902a1
5 changed files with 31 additions and 1 deletions

View File

@ -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']

View File

@ -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) {

View File

@ -53,11 +53,20 @@ html, body {
</div>
<div id="rightCol" class="col">
<select id="language">
<option value="xx">Select</option>
<option value="tr">Turkish</option>
<option value="fr">French</option>
<option value="hi">Hindi</option>
</select>
<button id="saveSrt">Save</button><br />
<button id="saveSrt">Save</button>
<select id="languageLoad">
<option value="xx">Select</option>
<option value="tr">Turkish</option>
<option value="fr">French</option>
<option value="hi">Hindi</option>
</select>
<button id="loadSrt">Load</button><br />
<textarea id="newSrt"></textarea>
</div>
</div>

View File

@ -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)

View File

@ -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: