Commit 2491f129 authored by Michal Čihař's avatar Michal Čihař

Make source checks work in checks browsing

parent c2deb8e7
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
{% blocktrans with check.get_doc_url as link %}More information about this check is available in the <a href="{{ link }}">documentation</a>.{% endblocktrans %} {% blocktrans with check.get_doc_url as link %}More information about this check is available in the <a href="{{ link }}">documentation</a>.{% endblocktrans %}
</p> </p>
{% if checks %} {% if anychecks %}
<table class="sort simple"> <table class="sort simple">
<thead> <thead>
<tr> <tr>
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
<td><a href="{% url 'weblate.trans.views.translate' project=subproject.project.slug subproject=subproject.slug lang=obj.translation__language__code %}?type={{ check.check_id }}">{{ obj.count }}</a></td> <td><a href="{% url 'weblate.trans.views.translate' project=subproject.project.slug subproject=subproject.slug lang=obj.translation__language__code %}?type={{ check.check_id }}">{{ obj.count }}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% for count in source_checks %}
<tr>
<th><a href="{% url 'weblate.trans.views.show_source' project=subproject.project.slug subproject=subproject.slug %}">{% trans "Source" %}</a></th>
<td><a href="{% url 'weblate.trans.views.review_source' project=subproject.project.slug subproject=subproject.slug %}?type={{ check.check_id }}">{{ count }}</a></td>
</tr>
{% endfor %}
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
......
...@@ -125,12 +125,20 @@ def show_check_project(request, name, project): ...@@ -125,12 +125,20 @@ def show_check_project(request, name, project):
check = CHECKS[name] check = CHECKS[name]
except KeyError: except KeyError:
raise Http404('No check matches the given query.') raise Http404('No check matches the given query.')
langs = Check.objects.filter(check = name, project = prj, ignore = False).values_list('language', flat = True).distinct()
units = Unit.objects.none() units = Unit.objects.none()
for lang in langs: if check.target:
checks = Check.objects.filter(check = name, project = prj, language = lang, ignore = False).values_list('checksum', flat = True) langs = Check.objects.filter(check = name, project = prj, ignore = False).values_list('language', flat = True).distinct()
res = Unit.objects.filter(checksum__in = checks, translation__language = lang, translation__subproject__project = prj, translated = True).values('translation__subproject__slug', 'translation__subproject__project__slug').annotate(count = Count('id')) for lang in langs:
units |= res checks = Check.objects.filter(check = name, project = prj, language = lang, ignore = False).values_list('checksum', flat = True)
res = Unit.objects.filter(checksum__in = checks, translation__language = lang, translation__subproject__project = prj, translated = True).values('translation__subproject__slug', 'translation__subproject__project__slug').annotate(count = Count('id'))
units |= res
if check.source:
checks = Check.objects.filter(check = name, project = prj, language = None, ignore = False).values_list('checksum', flat = True)
for sp in prj.subproject_set.all():
lang = sp.translation_set.all()[0].language
res = Unit.objects.filter(checksum__in = checks, translation__language = lang, translation__subproject = sp).values('translation__subproject__slug', 'translation__subproject__project__slug').annotate(count = Count('id'))
units |= res
return render_to_response('check_project.html', RequestContext(request, { return render_to_response('check_project.html', RequestContext(request, {
'checks': units, 'checks': units,
'title': '%s/%s' % (prj.__unicode__(), check.name), 'title': '%s/%s' % (prj.__unicode__(), check.name),
...@@ -147,14 +155,24 @@ def show_check_subproject(request, name, project, subproject): ...@@ -147,14 +155,24 @@ def show_check_subproject(request, name, project, subproject):
check = CHECKS[name] check = CHECKS[name]
except KeyError: except KeyError:
raise Http404('No check matches the given query.') raise Http404('No check matches the given query.')
langs = Check.objects.filter(check = name, project = subprj.project, ignore = False).values_list('language', flat = True).distinct()
units = Unit.objects.none() units = Unit.objects.none()
for lang in langs: if check.target:
checks = Check.objects.filter(check = name, project = subprj.project, language = lang, ignore = False).values_list('checksum', flat = True) langs = Check.objects.filter(check = name, project = subprj.project, ignore = False).values_list('language', flat = True).distinct()
res = Unit.objects.filter(translation__subproject = subprj, checksum__in = checks, translation__language = lang, translated = True).values('translation__language__code').annotate(count = Count('id')) for lang in langs:
units |= res checks = Check.objects.filter(check = name, project = subprj.project, language = lang, ignore = False).values_list('checksum', flat = True)
res = Unit.objects.filter(translation__subproject = subprj, checksum__in = checks, translation__language = lang, translated = True).values('translation__language__code').annotate(count = Count('id'))
units |= res
source_checks = []
if check.source:
checks = Check.objects.filter(check = name, project = subprj.project, language = None, ignore = False).values_list('checksum', flat = True)
lang = subprj.translation_set.all()[0].language
res = Unit.objects.filter(translation__subproject = subprj, checksum__in = checks, translation__language = lang).count()
if res > 0:
source_checks.append(res)
return render_to_response('check_subproject.html', RequestContext(request, { return render_to_response('check_subproject.html', RequestContext(request, {
'checks': units, 'checks': units,
'source_checks': source_checks,
'anychecks': len(units) + len(source_checks) > 0,
'title': '%s/%s' % (subprj.__unicode__(), check.name), 'title': '%s/%s' % (subprj.__unicode__(), check.name),
'check': check, 'check': check,
'subproject': subprj, 'subproject': subprj,
......
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