Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
5f1be10e
Commit
5f1be10e
authored
Jul 08, 2013
by
Ilya Zhuravlev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic global search
parent
8928d936
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
2 deletions
+67
-2
trans/forms.py
trans/forms.py
+1
-1
trans/views/basic.py
trans/views/basic.py
+22
-1
weblate/html/index.html
weblate/html/index.html
+8
-0
weblate/html/search.html
weblate/html/search.html
+30
-0
weblate/urls.py
weblate/urls.py
+6
-0
No files found.
trans/forms.py
View file @
5f1be10e
...
...
@@ -218,7 +218,7 @@ class SearchForm(forms.Form):
'''
Text searching form.
'''
q
=
forms
.
CharField
(
label
=
_
(
'Query'
))
q
=
forms
.
CharField
(
label
=
_
(
'Query'
)
,
min_length
=
3
)
search
=
forms
.
ChoiceField
(
label
=
_
(
'Search type'
),
required
=
False
,
...
...
trans/views/basic.py
View file @
5f1be10e
...
...
@@ -30,7 +30,7 @@ from django.utils.safestring import mark_safe
from
trans.models
import
(
Project
,
SubProject
,
Translation
,
Check
,
Dictionary
,
Change
,
Dictionary
,
Change
,
Unit
)
from
trans.requirements
import
get_versions
,
get_optional_versions
from
lang.models
import
Language
...
...
@@ -95,9 +95,30 @@ def home(request):
'last_changes_rss'
:
reverse
(
'rss'
),
'last_changes_url'
:
''
,
'usertranslations'
:
usertranslations
,
'search_form'
:
SearchForm
(),
}))
def
search
(
request
):
search_form
=
SearchForm
(
request
.
GET
)
context
=
{}
if
search_form
.
is_valid
():
units
=
Unit
.
objects
.
search
(
search_form
.
cleaned_data
[
'search'
],
search_form
.
cleaned_data
[
'q'
],
search_form
.
cleaned_data
[
'src'
],
search_form
.
cleaned_data
[
'ctx'
],
search_form
.
cleaned_data
[
'tgt'
],
).
filter
(
translation__language__code
=
"en"
).
order_by
(
"translation"
)[:
1000
]
context
=
{
'units'
:
units
,
'search_query'
:
search_form
.
cleaned_data
[
'q'
]
}
else
:
messages
.
error
(
request
,
_
(
'Invalid search query!'
))
return
render_to_response
(
'search.html'
,
RequestContext
(
request
,
context
))
def
show_languages
(
request
):
return
render_to_response
(
'languages.html'
,
RequestContext
(
request
,
{
'languages'
:
Language
.
objects
.
have_translation
(),
...
...
weblate/html/index.html
View file @
5f1be10e
...
...
@@ -63,6 +63,7 @@
<ul>
<li><a
href=
"#changes"
>
{% trans "History" %}
</a></li>
<li><a
href=
"#search"
>
{% trans "Search" %}
</a></li>
<li><a
href=
"#translators"
>
{% trans "Most active translators" %}
</a></li>
<li><a
href=
"#suggesters"
>
{% trans "Most active suggesters" %}
</a></li>
<li><a
href=
"{% url 'view_activity' %}"
>
{% trans "Activity" %}
</a></li>
...
...
@@ -73,6 +74,13 @@
{% include "last-changes.html" %}
</div>
<div
id=
"search"
>
<form
action=
"{% url 'search' %}"
method=
"GET"
>
{{ search_form.as_p }}
<input
type=
"submit"
value=
"{% trans "
Search
"
%}"
class=
"button"
/>
</form>
</div>
<div
id=
"translators"
>
<table>
<thead>
...
...
weblate/html/search.html
0 → 100644
View file @
5f1be10e
{% extends "base.html" %}
{% load i18n %}
{% load url from future %}
{% load translations %}
{% block breadcrumbs %}
<li><a
href=
"{% url 'search' %}"
>
{% trans "Search" %}
</a></li>
{% endblock %}
{% block content %}
{% regroup units by translation as translation_units %}
{% for translation_unit in translation_units %}
<h2>
{{ translation_unit.grouper }}
</h2>
<table
class=
"ui-widget-content"
>
{% for unit in translation_unit.list %}
<tr>
<th
class=
"source"
>
{% trans "Source" %}
</th>
<td
class=
"translatetext"
><a
href=
"{{ unit.get_absolute_url }}"
>
{{ unit.source|fmtsearchmatch:search_query }}
</a></td>
</tr>
<tr>
<th
class=
"source"
>
{{ unit.translation.language }}
</th>
<td
class=
"translatetext"
><a
href=
"{{ unit.get_absolute_url }}"
>
{{ unit.target|fmtsearchmatch:search_query }}
</a></td>
</tr>
{% if not forloop.last %}
<tr><td
colspan=
"2"
>
</td></tr>
{% endif %}
{% endfor %}
</table>
{% endfor %}
{% endblock %}
\ No newline at end of file
weblate/urls.py
View file @
5f1be10e
...
...
@@ -619,4 +619,10 @@ urlpatterns = patterns(
'
django
.
views
.
static
.
serve
',
{'
document_root
': settings.MEDIA_ROOT}
),
url(
r'
^
search
/
$
',
'
trans
.
views
.
basic
.
search
',
name="search"
),
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment