mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Add support for filtering content warnings
This commit is contained in:
parent
6a674c3c79
commit
b067fd2e77
@ -8,19 +8,18 @@ your client to use new 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.
|
||||
* A content warning, given below.
|
||||
* `android_default` - meta-flag that filters out any content with a content warning.
|
||||
* `desktop_default` - meta-flag that doesn't filter anything out for now.
|
||||
|
||||
## Warnings
|
||||
|
||||
## Ratings
|
||||
Packages with mature content will be tagged with a content warning based
|
||||
on the content type.
|
||||
|
||||
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
|
||||
* `bad_language` - swearing.
|
||||
* `drugs` - drugs or alcohol.
|
||||
* `gambling`
|
||||
* `gore` - blood, etc.
|
||||
* `horror` - shocking and scary content.
|
||||
* `violence` - non-cartoon violence.
|
||||
|
@ -1,4 +1,4 @@
|
||||
from .models import db, PackageType, Package, ForumTopic, License, MinetestRelease, PackageRelease, User, Tag, Tags
|
||||
from .models import db, PackageType, Package, ForumTopic, License, MinetestRelease, PackageRelease, User, Tag, Tags, ContentWarning
|
||||
from .utils import isNo, isYes, get_int_or_abort
|
||||
from sqlalchemy.sql.expression import func
|
||||
from flask import abort
|
||||
@ -27,17 +27,21 @@ class QueryBuilder:
|
||||
# Hide
|
||||
hide_flags = args.getlist("hide")
|
||||
|
||||
|
||||
self.title = title
|
||||
self.types = types
|
||||
self.tags = tags
|
||||
|
||||
self.random = "random" in args
|
||||
self.lucky = "lucky" in args
|
||||
self.hide_nonfree = "nonfree" in hide_flags
|
||||
self.limit = 1 if self.lucky else None
|
||||
self.order_by = args.get("sort")
|
||||
self.order_dir = args.get("order") or "desc"
|
||||
|
||||
self.hide_nonfree = "nonfree" in hide_flags
|
||||
self.hide_flags = set(hide_flags)
|
||||
self.hide_flags.discard("nonfree")
|
||||
|
||||
# Filters
|
||||
|
||||
self.search = args.get("q")
|
||||
@ -112,6 +116,14 @@ class QueryBuilder:
|
||||
for tag in self.tags:
|
||||
query = query.filter(Package.tags.any(Tag.id == tag.id))
|
||||
|
||||
if "android_default" in self.hide_flags:
|
||||
query = query.filter(~ Package.content_warnings.any())
|
||||
else:
|
||||
for flag in self.hide_flags:
|
||||
warning = ContentWarning.query.filter_by(name=flag).first()
|
||||
if warning:
|
||||
query = query.filter(~ Package.content_warnings.any(ContentWarning.id == warning.id))
|
||||
|
||||
if self.hide_nonfree:
|
||||
query = query.filter(Package.license.has(License.is_foss == True))
|
||||
query = query.filter(Package.media_license.has(License.is_foss == True))
|
||||
|
Loading…
Reference in New Issue
Block a user