strip string

This commit is contained in:
Sanj 2012-03-12 12:02:58 +05:30
parent 9c19cee904
commit 91e246b965

View File

@ -10,6 +10,7 @@ from ox.django.shortcuts import render_to_json_response
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.core.paginator import Paginator, InvalidPage, EmptyPage
import pdb
@login_required @login_required
def googletranslate(request, model, field): def googletranslate(request, model, field):
@ -138,7 +139,7 @@ def stringtranslate(request):
model = request.POST.get("model", "") model = request.POST.get("model", "")
field = request.POST.get("field", "") field = request.POST.get("field", "")
id = request.POST.get("id", 0) id = request.POST.get("id", 0)
string = request.POST.get("string", "") string = request.POST.get("string", "").strip()
translation = request.POST.get("translation", "") translation = request.POST.get("translation", "")
if model == 'Translation': if model == 'Translation':
obj = Translation.objects.get(pk=id) obj = Translation.objects.get(pk=id)
@ -154,6 +155,7 @@ def stringtranslate(request):
trans_field = field + "_trans" trans_field = field + "_trans"
matches = m.objects.filter(q) matches = m.objects.filter(q)
savedObjects = 0 savedObjects = 0
pdb.set_trace()
for match in matches: for match in matches:
match.__setattr__(trans_field, translation) match.__setattr__(trans_field, translation)
match.save() match.save()