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
b39a2ecc
Commit
b39a2ecc
authored
Apr 09, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move generating of search result title to search code
Now also properly labels review.
parent
fba2ce1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
25 deletions
+32
-25
trans/views/edit.py
trans/views/edit.py
+32
-5
trans/views/helper.py
trans/views/helper.py
+0
-20
No files found.
trans/views/edit.py
View file @
b39a2ecc
...
...
@@ -26,6 +26,7 @@ from django.contrib import messages
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.contrib.auth.models
import
AnonymousUser
from
django.db.models
import
Q
from
django.utils
import
formats
import
uuid
from
trans.models
import
SubProject
,
Unit
,
Suggestion
,
Change
,
Comment
...
...
@@ -34,14 +35,31 @@ from trans.forms import (
MergeForm
,
AutoForm
,
ReviewForm
,
AntispamForm
,
CommentForm
)
from
trans.views.helper
import
(
get_translation
,
get_filter_name
)
from
trans.views.helper
import
get_translation
from
trans.util
import
join_plural
from
accounts.models
import
Profile
,
send_notification_email
import
weblate
def
get_filter_name
(
rqtype
):
'''
Returns name of current filter.
'''
if
rqtype
==
'fuzzy'
:
return
_
(
'Fuzzy strings'
)
elif
rqtype
==
'untranslated'
:
return
_
(
'Untranslated strings'
)
elif
rqtype
==
'suggestions'
:
return
_
(
'Strings with suggestions'
)
elif
rqtype
==
'allchecks'
:
return
_
(
'Strings with any failing checks'
)
elif
rqtype
in
CHECKS
:
return
CHECKS
[
rqtype
].
name
else
:
return
None
def
search
(
translation
,
request
):
'''
Performs search or retuns cached search results.
...
...
@@ -68,11 +86,16 @@ def search(translation, request):
if
review_form
.
is_valid
():
# Review
# TODO: this search is missing name
allunits
=
translation
.
unit_set
.
review
(
review_form
.
cleaned_data
[
'date'
],
request
.
user
)
formatted_date
=
formats
.
date_format
(
review_form
.
cleaned_data
[
'date'
],
'SHORT_DATE_FORMAT'
)
name
=
_
(
'Review of translations since %s'
)
%
formatted_date
elif
search_form
.
is_valid
():
# Search query
search_query
=
search_form
.
cleaned_data
[
'q'
]
...
...
@@ -93,10 +116,14 @@ def search(translation, request):
search_context
,
search_target
)
name
=
_
(
'Search for "%s"'
)
%
search_query
else
:
# Filtering by type
allunits
=
translation
.
unit_set
.
filter_type
(
rqtype
,
translation
)
name
=
get_filter_name
(
rqtype
)
# Grab unit IDs
unit_ids
=
list
(
allunits
.
values_list
(
'id'
,
flat
=
True
))
...
...
@@ -108,7 +135,7 @@ def search(translation, request):
# Store in cache and return
search_id
=
str
(
uuid
.
uuid1
())
search_result
=
{
'name'
:
get_filter_name
(
rqtype
,
search_query
)
,
'name'
:
name
,
'ids'
:
unit_ids
,
'search_id'
:
search_id
,
}
...
...
trans/views/helper.py
View file @
b39a2ecc
...
...
@@ -96,26 +96,6 @@ def get_project_translation(request, project=None, subproject=None, lang=None):
return
project
,
subproject
,
translation
def
get_filter_name
(
rqtype
,
search_query
):
'''
Returns name of current filter.
'''
if
search_query
!=
''
:
return
_
(
'Search for "%s"'
)
%
search_query
elif
rqtype
==
'fuzzy'
:
return
_
(
'Fuzzy strings'
)
elif
rqtype
==
'untranslated'
:
return
_
(
'Untranslated strings'
)
elif
rqtype
==
'suggestions'
:
return
_
(
'Strings with suggestions'
)
elif
rqtype
==
'allchecks'
:
return
_
(
'Strings with any failing checks'
)
elif
rqtype
in
CHECKS
:
return
CHECKS
[
rqtype
].
name
else
:
return
None
def
try_set_language
(
lang
):
'''
Tries to activate language, returns matching Language object.
...
...
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