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

Show current filter (issue #30)

parent 7827e982
......@@ -23,9 +23,13 @@
</span>
</p>
{% if filter_name %}
<p>{% blocktrans %}Current filter: {{ filter_name }}{% endblocktrans %}</p>
{% else %}
{% if search_query %}
<p>{% blocktrans %}Searching for "{{ search_query }}".{% endblocktrans %}</p>
{% endif %}
{% endif %}
<form action="{{ unit.translation.get_translate_url }}" method="post">
{% csrf_token %}
......
......@@ -120,24 +120,6 @@ class UnitManager(models.Manager):
dbunit.update_from_unit(unit, pos, force)
return dbunit
def filter_name(self, rqtype):
'''
Returns name of current filter.
'''
import trans.checks
if rqtype == 'all':
return None
elif rqtype == 'fuzzy':
return _('Fuzzy strings')
elif rqtype == 'untranslated':
return _('Not translated strings')
elif rqtype == 'suggestions':
return _('Strings with suggestions')
elif rqtype in trans.checks.CHECKS:
return trans.checks.CHECKS[rqtype].name
else:
return None
def filter_type(self, rqtype):
'''
Basic filtering based on unit state or failed checks.
......
......@@ -520,6 +520,23 @@ def parse_search_url(request):
search_url
)
def get_filter_name(rqtype):
'''
Returns name of current filter.
'''
if rqtype == 'all':
return None
elif rqtype == 'fuzzy':
return _('Fuzzy strings')
elif rqtype == 'untranslated':
return _('Not translated strings')
elif rqtype == 'suggestions':
return _('Strings with suggestions')
elif rqtype in trans.checks.CHECKS:
return trans.checks.CHECKS[rqtype].name
else:
return None
def translate(request, project, subproject, lang):
obj = get_object_or_404(Translation, language__code = lang, subproject__slug = subproject, subproject__project__slug = project)
......@@ -789,6 +806,7 @@ def translate(request, project, subproject, lang):
'changes': unit.change_set.all()[:10],
'total': total,
'type': rqtype,
'filter_name': get_filter_name(rqtype),
'form': form,
'target_language': obj.language.code,
'secondary': secondary,
......
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