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

Use full names for search parameters

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 564d5c67
......@@ -410,27 +410,27 @@ class SearchForm(forms.Form):
),
initial=False
)
src = forms.BooleanField(
source = forms.BooleanField(
label=_('Search in source strings'),
required=False,
initial=True
)
tgt = forms.BooleanField(
target = forms.BooleanField(
label=_('Search in target strings'),
required=False,
initial=True
)
ctx = forms.BooleanField(
context = forms.BooleanField(
label=_('Search in context strings'),
required=False,
initial=False
)
loc = forms.BooleanField(
location = forms.BooleanField(
label=_('Search in location strings'),
required=False,
initial=False
)
cmt = forms.BooleanField(
comment = forms.BooleanField(
label=_('Search in comment strings'),
required=False,
initial=False
......@@ -471,13 +471,13 @@ class SearchForm(forms.Form):
cleaned_data['type'] = 'all'
# Default to source and target search
if (not cleaned_data['src']
and not cleaned_data['tgt']
and not cleaned_data['loc']
and not cleaned_data['cmt']
and not cleaned_data['ctx']):
cleaned_data['src'] = True
cleaned_data['tgt'] = True
if (not cleaned_data['source']
and not cleaned_data['target']
and not cleaned_data['location']
and not cleaned_data['comment']
and not cleaned_data['context']):
cleaned_data['source'] = True
cleaned_data['target'] = True
return cleaned_data
......@@ -490,7 +490,7 @@ class SearchForm(forms.Form):
if self.cleaned_data['q']:
query['q'] = self.cleaned_data['q'].encode('utf-8')
query['search'] = self.cleaned_data['search']
for param in ('src', 'tgt', 'ctx', 'cmt', 'loc'):
for param in ('source', 'target', 'context', 'comment', 'location'):
if self.cleaned_data[param]:
query[param] = 'on'
......
......@@ -208,15 +208,15 @@ class UnitManager(models.Manager):
else:
modifier = '__icontains'
if params['src']:
if params['source']:
queries.append('source')
if params['tgt']:
if params['target']:
queries.append('target')
if params['ctx']:
if params['context']:
queries.append('context')
if params['loc']:
if params['location']:
queries.append('location')
if params['cmt']:
if params['comment']:
queries.append('comment')
query = reduce(
......@@ -244,7 +244,7 @@ class UnitManager(models.Manager):
checksums = fulltext_search(
unit.get_source_plurals()[0],
unit.translation.language.code,
{'src': True}
{'source': True}
)
return self.filter(
......@@ -264,7 +264,7 @@ class UnitManager(models.Manager):
same_results = fulltext_search(
unit.get_source_plurals()[0],
unit.translation.language.code,
{'src': True}
{'source': True}
)
checksums = more_results - same_results
......
......@@ -220,38 +220,38 @@ def fulltext_search(query, lang, params):
checksums = set()
search = {
'src': False,
'ctx': False,
'tgt': False,
'cmt': False,
'loc': False,
'source': False,
'context': False,
'target': False,
'comment': False,
'location': False,
}
search.update(params)
if search['src'] or search['ctx'] or search['loc']:
if search['source'] or search['context'] or search['location']:
index = get_source_index()
with index.searcher() as searcher:
if search['src']:
if search['source']:
checksums.update(
base_search(searcher, 'source', SourceSchema(), query)
)
if search['ctx']:
if search['context']:
checksums.update(
base_search(searcher, 'context', SourceSchema(), query)
)
if search['loc']:
if search['location']:
checksums.update(
base_search(searcher, 'location', SourceSchema(), query)
)
if search['tgt'] or search['cmt']:
if search['target'] or search['comment']:
index = get_target_index(lang)
with index.searcher() as searcher:
if search['tgt']:
if search['target']:
checksums.update(
base_search(searcher, 'target', TargetSchema(), query)
)
if search['cmt']:
if search['comment']:
checksums.update(
base_search(searcher, 'comment', TargetSchema(), query)
)
......
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