mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 19:57:29 +01:00
Add query argument to filter by language support
This commit is contained in:
parent
3e6d6864b3
commit
40d572d645
@ -189,6 +189,7 @@ Supported query parameters:
|
|||||||
* `tag`: Filter by tags.
|
* `tag`: Filter by tags.
|
||||||
* `flag`: Filter to show packages with [Content Flags](/help/content_flags/).
|
* `flag`: Filter to show packages with [Content Flags](/help/content_flags/).
|
||||||
* `game`: Filter by [Game Support](/help/game_support/), ex: `Wuzzy/mineclone2`. (experimental, doesn't show items that support every game currently).
|
* `game`: Filter by [Game Support](/help/game_support/), ex: `Wuzzy/mineclone2`. (experimental, doesn't show items that support every game currently).
|
||||||
|
* `lang`: Filter by translation support, eg: `en`/`de`/`ja`/`zh_TW`.
|
||||||
* `random`: When present, enable random ordering and ignore `sort`.
|
* `random`: When present, enable random ordering and ignore `sort`.
|
||||||
* `limit`: Return at most `limit` packages.
|
* `limit`: Return at most `limit` packages.
|
||||||
* `hide`: Hide content based on [Content Flags](/help/content_flags/).
|
* `hide`: Hide content based on [Content Flags](/help/content_flags/).
|
||||||
|
@ -52,7 +52,8 @@ class QueryBuilder:
|
|||||||
ret = f"{self.search} - {ret}"
|
ret = f"{self.search} - {ret}"
|
||||||
|
|
||||||
if self.game:
|
if self.game:
|
||||||
ret = gettext("%(package_type)s for %(game_name)s", package_type=ret, game_name=self.game.title)
|
meta = self.game.get_translated(load_desc=False)
|
||||||
|
ret = gettext("%(package_type)s for %(game_name)s", package_type=ret, game_name=meta["title"])
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -132,6 +133,8 @@ class QueryBuilder:
|
|||||||
if self.game:
|
if self.game:
|
||||||
self.game = Package.get_by_key(self.game)
|
self.game = Package.get_by_key(self.game)
|
||||||
|
|
||||||
|
self.has_lang = args.get("lang")
|
||||||
|
|
||||||
if cookies and request.cookies.get("hide_nonfree") == "1":
|
if cookies and request.cookies.get("hide_nonfree") == "1":
|
||||||
self.hide_nonfree = True
|
self.hide_nonfree = True
|
||||||
|
|
||||||
@ -197,6 +200,9 @@ class QueryBuilder:
|
|||||||
if self.game:
|
if self.game:
|
||||||
query = query.filter(Package.supported_games.any(game=self.game, supports=True))
|
query = query.filter(Package.supported_games.any(game=self.game, supports=True))
|
||||||
|
|
||||||
|
if self.has_lang:
|
||||||
|
query = query.filter(Package.translations.any(language_id=self.has_lang))
|
||||||
|
|
||||||
for tag in self.tags:
|
for tag in self.tags:
|
||||||
query = query.filter(Package.tags.any(Tag.id == tag.id))
|
query = query.filter(Package.tags.any(Tag.id == tag.id))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user