* `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.
-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
# 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")
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))