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
f642833f
Commit
f642833f
authored
Apr 17, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve and test error handling in search
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
2c6b2a23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
15 deletions
+29
-15
weblate/trans/tests/test_search.py
weblate/trans/tests/test_search.py
+10
-0
weblate/trans/views/edit.py
weblate/trans/views/edit.py
+19
-15
No files found.
weblate/trans/tests/test_search.py
View file @
f642833f
...
...
@@ -248,6 +248,16 @@ class SearchViewTest(ViewTestCase):
'1 / 4'
)
def
test_search_errors
(
self
):
self
.
do_search
(
{
'type'
:
'nonexisting-type'
},
'nonexisting-type is not one of the available choices'
)
self
.
do_search
(
{
'date'
:
'nonexisting'
},
'date: Enter a valid date.'
)
def
test_search_plural
(
self
):
response
=
self
.
do_search
(
{
'q'
:
'banana'
},
...
...
weblate/trans/views/edit.py
View file @
f642833f
...
...
@@ -100,18 +100,25 @@ def search(translation, request):
review_form
=
ReviewForm
(
request
.
GET
)
search_query
=
None
if
review_form
.
is_valid
():
# Review
allunits
=
translation
.
unit_set
.
review
(
review_form
.
cleaned_data
[
'date'
],
request
.
user
)
if
'date'
in
request
.
GET
:
if
review_form
.
is_valid
():
# Review
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
formatted_date
=
formats
.
date_format
(
review_form
.
cleaned_data
[
'date'
],
'SHORT_DATE_FORMAT'
)
name
=
_
(
'Review of translations since %s'
)
%
formatted_date
else
:
show_form_errors
(
request
,
review_form
)
# Filtering by type
allunits
=
translation
.
unit_set
.
all
()
name
=
_
(
'All strings'
)
elif
search_form
.
is_valid
():
# Apply search conditions
allunits
=
translation
.
unit_set
.
search
(
...
...
@@ -123,10 +130,7 @@ def search(translation, request):
name
=
search_form
.
get_name
()
else
:
# Error reporting
if
'date'
in
request
.
GET
:
show_form_errors
(
request
,
review_form
)
elif
'q'
in
request
.
GET
or
'type'
in
request
.
GET
:
show_form_errors
(
request
,
search_form
)
show_form_errors
(
request
,
search_form
)
# Filtering by type
allunits
=
translation
.
unit_set
.
all
()
...
...
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