Commit e3195835 authored by Michal Čihař's avatar Michal Čihař

Share code for getting source strings

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent f99d0bd8
......@@ -31,19 +31,24 @@ from weblate.trans.models import Translation, Source
from weblate.trans.forms import PriorityForm
def review_source(request, project, subproject):
def get_source(request, project, subproject):
"""
Listing of source strings to review.
Returns first translation in subproject
(this assumes all have same source strings).
"""
obj = get_subproject(request, project, subproject)
# Grab first translation in subproject
# (this assumes all have same source strings)
try:
source = obj.translation_set.all()[0]
return obj, obj.translation_set.all()[0]
except Translation.DoesNotExist:
raise Http404('No translation exists in this component.')
def review_source(request, project, subproject):
"""
Listing of source strings to review.
"""
obj, source = get_source(request, project, subproject)
# Grab search type and page number
rqtype = request.GET.get('type', 'all')
limit = request.GET.get('limit', 50)
......@@ -89,14 +94,7 @@ def show_source(request, project, subproject):
"""
Show source strings summary and checks.
"""
obj = get_subproject(request, project, subproject)
# Grab first translation in subproject
# (this assumes all have same source strings)
try:
source = obj.translation_set.all()[0]
except Translation.DoesNotExist:
raise Http404('No translation exists in this component.')
obj, source = get_source(request, project, subproject)
return render(
request,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment