Merge branch '872-term' into 'develop'
See #872: new "terms of service" settings See merge request funkwhale/funkwhale!894
This commit is contained in:
commit
756063fa09
|
@ -14,6 +14,11 @@ def get(pref):
|
||||||
return manager[pref]
|
return manager[pref]
|
||||||
|
|
||||||
|
|
||||||
|
def all():
|
||||||
|
manager = global_preferences_registry.manager()
|
||||||
|
return manager.all()
|
||||||
|
|
||||||
|
|
||||||
def set(pref, value):
|
def set(pref, value):
|
||||||
manager = global_preferences_registry.manager()
|
manager = global_preferences_registry.manager()
|
||||||
manager[pref] = value
|
manager[pref] = value
|
||||||
|
|
|
@ -43,6 +43,20 @@ class InstanceLongDescription(types.StringPreference):
|
||||||
field_kwargs = {"required": False}
|
field_kwargs = {"required": False}
|
||||||
|
|
||||||
|
|
||||||
|
@global_preferences_registry.register
|
||||||
|
class InstanceTerms(types.StringPreference):
|
||||||
|
show_in_api = True
|
||||||
|
section = instance
|
||||||
|
name = "terms"
|
||||||
|
verbose_name = "Terms of service"
|
||||||
|
default = ""
|
||||||
|
help_text = (
|
||||||
|
"Terms of service and privacy policy for your instance (markdown allowed)."
|
||||||
|
)
|
||||||
|
widget = widgets.Textarea
|
||||||
|
field_kwargs = {"required": False}
|
||||||
|
|
||||||
|
|
||||||
@global_preferences_registry.register
|
@global_preferences_registry.register
|
||||||
class RavenDSN(types.StringPreference):
|
class RavenDSN(types.StringPreference):
|
||||||
show_in_api = True
|
show_in_api = True
|
||||||
|
|
|
@ -13,10 +13,11 @@ memo = memoize.Memoizer(store, namespace="instance:stats")
|
||||||
|
|
||||||
|
|
||||||
def get():
|
def get():
|
||||||
share_stats = preferences.get("instance__nodeinfo_stats_enabled")
|
all_preferences = preferences.all()
|
||||||
allow_list_enabled = preferences.get("moderation__allow_list_enabled")
|
share_stats = all_preferences.get("instance__nodeinfo_stats_enabled")
|
||||||
allow_list_public = preferences.get("moderation__allow_list_public")
|
allow_list_enabled = all_preferences.get("moderation__allow_list_enabled")
|
||||||
unauthenticated_report_types = preferences.get(
|
allow_list_public = all_preferences.get("moderation__allow_list_public")
|
||||||
|
unauthenticated_report_types = all_preferences.get(
|
||||||
"moderation__unauthenticated_report_types"
|
"moderation__unauthenticated_report_types"
|
||||||
)
|
)
|
||||||
if allow_list_enabled and allow_list_public:
|
if allow_list_enabled and allow_list_public:
|
||||||
|
@ -32,20 +33,21 @@ def get():
|
||||||
"software": {"name": "funkwhale", "version": funkwhale_api.__version__},
|
"software": {"name": "funkwhale", "version": funkwhale_api.__version__},
|
||||||
"protocols": ["activitypub"],
|
"protocols": ["activitypub"],
|
||||||
"services": {"inbound": [], "outbound": []},
|
"services": {"inbound": [], "outbound": []},
|
||||||
"openRegistrations": preferences.get("users__registration_enabled"),
|
"openRegistrations": all_preferences.get("users__registration_enabled"),
|
||||||
"usage": {"users": {"total": 0, "activeHalfyear": 0, "activeMonth": 0}},
|
"usage": {"users": {"total": 0, "activeHalfyear": 0, "activeMonth": 0}},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"actorId": actors.get_service_actor().fid,
|
"actorId": actors.get_service_actor().fid,
|
||||||
"private": preferences.get("instance__nodeinfo_private"),
|
"private": all_preferences.get("instance__nodeinfo_private"),
|
||||||
"shortDescription": preferences.get("instance__short_description"),
|
"shortDescription": all_preferences.get("instance__short_description"),
|
||||||
"longDescription": preferences.get("instance__long_description"),
|
"longDescription": all_preferences.get("instance__long_description"),
|
||||||
"nodeName": preferences.get("instance__name"),
|
"terms": all_preferences.get("instance__terms"),
|
||||||
|
"nodeName": all_preferences.get("instance__name"),
|
||||||
"library": {
|
"library": {
|
||||||
"federationEnabled": preferences.get("federation__enabled"),
|
"federationEnabled": all_preferences.get("federation__enabled"),
|
||||||
"federationNeedsApproval": preferences.get(
|
"federationNeedsApproval": all_preferences.get(
|
||||||
"federation__music_needs_approval"
|
"federation__music_needs_approval"
|
||||||
),
|
),
|
||||||
"anonymousCanListen": not preferences.get(
|
"anonymousCanListen": not all_preferences.get(
|
||||||
"common__api_authentication_required"
|
"common__api_authentication_required"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
@ -38,6 +38,7 @@ def test_nodeinfo_dump(preferences, mocker):
|
||||||
"shortDescription": preferences["instance__short_description"],
|
"shortDescription": preferences["instance__short_description"],
|
||||||
"longDescription": preferences["instance__long_description"],
|
"longDescription": preferences["instance__long_description"],
|
||||||
"nodeName": preferences["instance__name"],
|
"nodeName": preferences["instance__name"],
|
||||||
|
"terms": preferences["instance__terms"],
|
||||||
"library": {
|
"library": {
|
||||||
"federationEnabled": preferences["federation__enabled"],
|
"federationEnabled": preferences["federation__enabled"],
|
||||||
"federationNeedsApproval": preferences[
|
"federationNeedsApproval": preferences[
|
||||||
|
@ -105,6 +106,7 @@ def test_nodeinfo_dump_stats_disabled(preferences, mocker):
|
||||||
"shortDescription": preferences["instance__short_description"],
|
"shortDescription": preferences["instance__short_description"],
|
||||||
"longDescription": preferences["instance__long_description"],
|
"longDescription": preferences["instance__long_description"],
|
||||||
"nodeName": preferences["instance__name"],
|
"nodeName": preferences["instance__name"],
|
||||||
|
"terms": preferences["instance__terms"],
|
||||||
"library": {
|
"library": {
|
||||||
"federationEnabled": preferences["federation__enabled"],
|
"federationEnabled": preferences["federation__enabled"],
|
||||||
"federationNeedsApproval": preferences[
|
"federationNeedsApproval": preferences[
|
||||||
|
|
|
@ -94,7 +94,8 @@ export default {
|
||||||
settings: [
|
settings: [
|
||||||
"instance__name",
|
"instance__name",
|
||||||
"instance__short_description",
|
"instance__short_description",
|
||||||
"instance__long_description"
|
"instance__long_description",
|
||||||
|
"instance__terms",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue