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

Show words count when listing dictionary

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 8b81cfa4
......@@ -79,11 +79,11 @@
<div class="panel-heading"><h4 class="panel-title">{% trans "Glossaries" %}</h4></div>
<div class="panel-body">
{% if dicts %}
<ul>
<div class="list-group">
{% for dict in dicts %}
<li><a href="{% url 'show_dictionary' project=object.slug lang=dict.code %}">{{ dict }}</a></li>
<a class="list-group-item" href="{% url 'show_dictionary' project=object.slug lang=dict.language.code %}"><span class="badge">{{ dict.count }}</span>{{ dict.language }}</a>
{% endfor %}
</ul>
</div>
{% else %}
<p>{% trans "There are currently no glossaries defined for this project." %}</p>
{% endif %}
......
......@@ -207,12 +207,24 @@ def show_engage(request, project, lang=None):
def show_project(request, project):
obj = get_project(request, project)
dicts = Dictionary.objects.filter(
dict_langs = Dictionary.objects.filter(
project=obj
).values_list(
'language', flat=True
).distinct()
dicts = []
for language in Language.objects.filter(id__in=dict_langs):
dicts.append(
{
'language': language,
'count': Dictionary.objects.filter(
language=language,
project=obj
).count(),
}
)
last_changes = Change.objects.prefetch().filter(
Q(translation__subproject__project=obj) |
Q(dictionary__project=obj)
......@@ -223,7 +235,7 @@ def show_project(request, project):
'project.html',
{
'object': obj,
'dicts': Language.objects.filter(id__in=dicts),
'dicts': dicts,
'last_changes': last_changes,
'last_changes_rss': reverse(
'rss-project',
......
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