Commit 71d8f061 authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents 60167ef8 5c510c34
......@@ -14,6 +14,7 @@ Released on ? 2015.
* Documentation improvements.
* Added support for generating translator credits.
* Added support for generating contributor stats.
* Site wide search can search only in one language.
weblate 2.4
-----------
......
......@@ -555,6 +555,27 @@ class SearchForm(forms.Form):
return filter_name
class SiteSearchForm(SearchForm):
"""Site wide search form"""
lang = forms.ChoiceField(
label=_('Language'),
required=False,
choices=[('', _('All languages'))],
)
def __init__(self, *args, **kwargs):
'''
Dynamically generate choices for used languages
in project
'''
super(SiteSearchForm, self).__init__(*args, **kwargs)
self.fields['lang'].choices += [
(l.code, l.__unicode__())
for l in Language.objects.have_translation()
]
class MergeForm(ChecksumForm):
'''
Simple form for merging translation of two units.
......
......@@ -207,6 +207,9 @@ class UnitManager(models.Manager):
params['ignored']
)
if 'lang' in params and params['lang']:
base = base.filter(translation__language__code=params['lang'])
if not params['q']:
return base
......
......@@ -34,7 +34,7 @@ from weblate.trans.models import (
from weblate.requirements import get_versions, get_optional_versions
from weblate.lang.models import Language
from weblate.trans.forms import (
get_upload_form, SearchForm,
get_upload_form, SearchForm, SiteSearchForm,
AutoForm, ReviewForm, NewLanguageForm,
UserManageForm, ReportsForm,
)
......@@ -96,7 +96,7 @@ def home(request):
'top_suggestions': top_suggestions.select_related('user'),
'last_changes': last_changes,
'last_changes_url': '',
'search_form': SearchForm(),
'search_form': SiteSearchForm(),
'whiteboard_messages': wb_messages,
}
)
......@@ -106,7 +106,7 @@ def search(request):
"""
Performs site-wide search on units.
"""
search_form = SearchForm(request.GET)
search_form = SiteSearchForm(request.GET)
context = {
'search_form': search_form,
}
......
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