Add content flag support in the API

This commit is contained in:
rubenwardy 2019-02-03 12:59:33 +00:00
parent e40b247a97
commit 9c2c8c21f1
4 changed files with 30 additions and 13 deletions

@ -2,5 +2,5 @@ title: Help
* [Package Tags](package_tags)
* [Ranks and Permissions](ranks_permissions)
* [Content Ratings](content_ratings)
* [Content Ratings and Flags](content_flags)
* [Reporting Content](reporting)

@ -0,0 +1,26 @@
title: Content Flags
Content flags allow you to hide content based on your preferences.
The filtering is done server-side, which means that you don't need to update
your client to use new flags.
## Flags
* `nonfree` - can be used to hide packages which do not qualify as
'free software', as defined by the Free Software Foundation.
* A content rating, given below.
## Ratings
Content ratings aren't currently supported by ContentDB.
Instead, mature content isn't allowed at all for now.
In the future, more mature content will be allowed but labelled with
content ratings which may contain the following:
* android_default - meta-rating which includes gore and drugs.
* desktop_default - meta-rating which won't include anything for now.
* gore - more than just blood
* drugs
* swearing

@ -1,11 +0,0 @@
title: Content Ratings
Content ratings aren't currently supported by ContentDB.
Instead, mature content isn't allowed at all for now.
Possible future ratings:
* mature - meta-rating which includes gore and drugs
* gore - more than just blood
* drugs
* swearing

@ -19,12 +19,14 @@ class QueryBuilder:
if len(types) > 0:
title = ", ".join([type.value + "s" for type in types])
hide_flags = args.getlist("hide")
self.title = title
self.types = types
self.search = args.get("q")
self.random = "random" in args
self.lucky = self.random or "lucky" in args
self.hide_nonfree = isNo(args.get("nonfree"))
self.hide_nonfree = "nonfree" in hide_flags
self.limit = 1 if self.lucky else None
self.order_by = args.get("sort") or "score"
self.order_dir = args.get("order") or "desc"