Skip to content

Commit

Permalink
Search: Add project and component slug search
Browse files Browse the repository at this point in the history
This is useful on higher level searches.
  • Loading branch information
nijel committed Aug 13, 2020
1 parent 0012f4d commit c2aa3cb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Not yet released.
* Added support for aliasing languages at project level.
* New addon to help with HTML or JavaScript localization, see :ref:`addon-weblate.cdn.cdnjs`.
* The Weblate domain is now configured in the settings, see :setting:`SITE_DOMAIN`.
* Add support for searching by component and project.

Weblate 4.1.1
-------------
Expand Down
4 changes: 4 additions & 0 deletions docs/user/search.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Fields
Search for string states (``pending``, ``translated``, ``untranslated``).
``language:TEXT``
String target language.
``component:TEXT``
Component slug, see :ref:`component-slug`.
``project:TEXT``
Project slug, see :ref:`project-slug`.
``changed_by:TEXT``
String was changed by author with given username.
``changed:DATETIME``
Expand Down
2 changes: 2 additions & 0 deletions weblate/utils/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def similarity(self, first, second):
"check": "check__check",
"dismissed_check": "check__check",
"language": "translation__language__code",
"component": "translation__component__slug",
"project": "translation__component__project__slug",
"changed_by": "change__author__username",
"suggestion_author": "suggestion__user__username",
"comment_author": "comment__user__username",
Expand Down
10 changes: 10 additions & 0 deletions weblate/utils/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ def test_language(self):
self.assert_query("language:cs", Q(translation__language__code__iexact="cs"))
self.assert_query('language:r".*"', Q(translation__language__code__regex=".*"))

def test_component(self):
self.assert_query(
"component:hello", Q(translation__component__slug__iexact="hello")
)

def test_project(self):
self.assert_query(
"project:hello", Q(translation__component__project__slug__iexact="hello")
)

def test_html(self):
self.assert_query(
"<b>bold</b>",
Expand Down

0 comments on commit c2aa3cb

Please sign in to comment.