translation pages for captain, ship_names / error message for invalid page
This commit is contained in:
parent
5835d99c7b
commit
8e8b356524
|
@ -102,8 +102,9 @@ def translate(request, model, field, page_no=1):
|
||||||
try:
|
try:
|
||||||
results = paginator.page(page_no)
|
results = paginator.page(page_no)
|
||||||
except (EmptyPage, InvalidPage):
|
except (EmptyPage, InvalidPage):
|
||||||
results = paginator.page(paginator.num_pages)
|
return HttpResponse("invalid page no / end of list")
|
||||||
page_no = paginator.num_pages
|
# results = paginator.page(paginator.num_pages)
|
||||||
|
# page_no = paginator.num_pages
|
||||||
|
|
||||||
|
|
||||||
# if limit:
|
# if limit:
|
||||||
|
@ -139,13 +140,26 @@ def stringtranslate(request):
|
||||||
id = request.POST.get("id", 0)
|
id = request.POST.get("id", 0)
|
||||||
string = request.POST.get("string", "")
|
string = request.POST.get("string", "")
|
||||||
translation = request.POST.get("translation", "")
|
translation = request.POST.get("translation", "")
|
||||||
if not model == 'Translation':
|
if model == 'Translation':
|
||||||
return render_to_json_response({'error': 'this only works for the translation model'})
|
obj = Translation.objects.get(pk=id)
|
||||||
obj = Translation.objects.get(pk=id)
|
obj.string_trans = translation
|
||||||
obj.string_trans = translation
|
obj.looked_at = True
|
||||||
obj.looked_at = True
|
obj.save()
|
||||||
obj.save()
|
return render_to_json_response({'ok': 'ok'})
|
||||||
return render_to_json_response({'ok': 'ok'})
|
try:
|
||||||
|
m = models.__getattribute__(model)
|
||||||
|
except AttributeError:
|
||||||
|
return HttpResponse("no such model")
|
||||||
|
q = Q(**{"%s__exact" % field: string})
|
||||||
|
trans_field = field + "_trans"
|
||||||
|
matches = m.objects.filter(q)
|
||||||
|
savedObjects = 0
|
||||||
|
for match in matches:
|
||||||
|
match.__setattr__(trans_field, translation)
|
||||||
|
match.save()
|
||||||
|
savedObjects += 1
|
||||||
|
return render_to_json_response({'ok': savedObjects})
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
def dotrans(request, model, field):
|
def dotrans(request, model, field):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user