2019-09-17 09:03:32 +00:00
|
|
|
from django.core.validators import FileExtensionValidator
|
2022-11-23 11:11:36 +00:00
|
|
|
from django.forms import widgets
|
2018-02-17 20:21:33 +00:00
|
|
|
from dynamic_preferences import types
|
|
|
|
from dynamic_preferences.registries import global_preferences_registry
|
|
|
|
|
2018-06-09 13:36:16 +00:00
|
|
|
instance = types.Section("instance")
|
2019-07-03 09:06:13 +00:00
|
|
|
ui = types.Section("ui")
|
2018-02-24 14:27:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceName(types.StringPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
2018-06-09 13:36:16 +00:00
|
|
|
name = "name"
|
|
|
|
default = ""
|
|
|
|
verbose_name = "Public name"
|
|
|
|
help_text = "The public name of your instance, displayed in the about page."
|
|
|
|
field_kwargs = {"required": False}
|
2018-02-24 14:27:51 +00:00
|
|
|
|
2018-02-17 20:21:33 +00:00
|
|
|
|
2018-02-24 14:27:51 +00:00
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceShortDescription(types.StringPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
2018-06-09 13:36:16 +00:00
|
|
|
name = "short_description"
|
|
|
|
default = ""
|
|
|
|
verbose_name = "Short description"
|
|
|
|
help_text = "Instance succinct description, displayed in the about page."
|
|
|
|
field_kwargs = {"required": False}
|
2018-02-24 14:27:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceLongDescription(types.StringPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
2018-06-09 13:36:16 +00:00
|
|
|
name = "long_description"
|
|
|
|
verbose_name = "Long description"
|
|
|
|
default = ""
|
2020-02-06 14:52:08 +00:00
|
|
|
help_text = "Instance long description, displayed in the about page."
|
2018-05-17 21:40:06 +00:00
|
|
|
widget = widgets.Textarea
|
2018-06-09 13:36:16 +00:00
|
|
|
field_kwargs = {"required": False}
|
2018-02-17 20:21:33 +00:00
|
|
|
|
2018-05-17 21:40:06 +00:00
|
|
|
|
2019-09-16 09:33:33 +00:00
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceTerms(types.StringPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
|
|
|
name = "terms"
|
|
|
|
verbose_name = "Terms of service"
|
|
|
|
default = ""
|
2020-02-06 14:52:08 +00:00
|
|
|
help_text = "Terms of service and privacy policy for your instance."
|
2019-09-16 09:33:33 +00:00
|
|
|
widget = widgets.Textarea
|
|
|
|
field_kwargs = {"required": False}
|
2019-09-19 09:14:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceRules(types.StringPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
|
|
|
name = "rules"
|
|
|
|
verbose_name = "Rules"
|
|
|
|
default = ""
|
2020-02-06 14:52:08 +00:00
|
|
|
help_text = "Rules/Code of Conduct."
|
2019-09-19 09:14:21 +00:00
|
|
|
widget = widgets.Textarea
|
|
|
|
field_kwargs = {"required": False}
|
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceContactEmail(types.StringPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
|
|
|
name = "contact_email"
|
|
|
|
verbose_name = "Contact email"
|
|
|
|
default = ""
|
2021-06-17 15:55:12 +00:00
|
|
|
help_text = "A contact e-mail address for visitors who need to contact an admin or moderator"
|
2019-09-19 09:14:21 +00:00
|
|
|
field_kwargs = {"required": False}
|
2019-09-16 09:33:33 +00:00
|
|
|
|
|
|
|
|
2019-09-23 09:30:25 +00:00
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceSupportMessage(types.StringPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
|
|
|
name = "support_message"
|
|
|
|
verbose_name = "Support message"
|
|
|
|
default = ""
|
|
|
|
help_text = (
|
|
|
|
"A short message that will be displayed periodically to local users. "
|
|
|
|
"Use it to ask for financial support or anything else you might need. "
|
|
|
|
"(markdown allowed)."
|
|
|
|
)
|
|
|
|
widget = widgets.Textarea
|
|
|
|
field_kwargs = {"required": False}
|
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceFunkwhaleSupportMessageEnabled(types.BooleanPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
|
|
|
name = "funkwhale_support_message_enabled"
|
|
|
|
verbose_name = "Funkwhale Support message"
|
|
|
|
default = True
|
|
|
|
help_text = (
|
|
|
|
"If this is enabled, we will periodically display a message to encourage "
|
|
|
|
"local users to support Funkwhale."
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-16 20:21:40 +00:00
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceNodeinfoPrivate(types.BooleanPreference):
|
|
|
|
show_in_api = False
|
|
|
|
section = instance
|
2018-06-09 13:36:16 +00:00
|
|
|
name = "nodeinfo_private"
|
2018-05-16 20:21:40 +00:00
|
|
|
default = False
|
2018-06-09 13:36:16 +00:00
|
|
|
verbose_name = "Private mode in nodeinfo"
|
2018-05-16 20:21:40 +00:00
|
|
|
help_text = (
|
2018-06-09 13:36:16 +00:00
|
|
|
"Indicate in the nodeinfo endpoint that you do not want your instance "
|
|
|
|
"to be tracked by third-party services. "
|
|
|
|
"There is no guarantee these tools will honor this setting though."
|
2018-05-16 20:21:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-07 20:09:03 +00:00
|
|
|
@global_preferences_registry.register
|
|
|
|
class InstanceNodeinfoStatsEnabled(types.BooleanPreference):
|
|
|
|
show_in_api = False
|
|
|
|
section = instance
|
2018-06-09 13:36:16 +00:00
|
|
|
name = "nodeinfo_stats_enabled"
|
2018-05-07 20:09:03 +00:00
|
|
|
default = True
|
2018-06-09 13:36:16 +00:00
|
|
|
verbose_name = "Enable usage and library stats in nodeinfo endpoint"
|
2018-05-07 20:09:03 +00:00
|
|
|
help_text = (
|
2018-06-09 13:36:16 +00:00
|
|
|
"Disable this if you don't want to share usage and library statistics "
|
|
|
|
"in the nodeinfo endpoint but don't want to disable it completely."
|
2018-05-07 20:09:03 +00:00
|
|
|
)
|
2019-07-03 09:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class CustomCSS(types.StringPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = ui
|
|
|
|
name = "custom_css"
|
|
|
|
verbose_name = "Custom CSS code"
|
|
|
|
default = ""
|
|
|
|
help_text = (
|
|
|
|
"Custom CSS code, to be included in a <style> tag on all pages. "
|
|
|
|
"Loading third-party resources such as fonts or images can affect the performance "
|
|
|
|
"of the app and the privacy of your users."
|
|
|
|
)
|
|
|
|
widget = widgets.Textarea
|
|
|
|
field_kwargs = {"required": False}
|
2019-09-17 09:03:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ImageWidget(widgets.ClearableFileInput):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ImagePreference(types.FilePreference):
|
|
|
|
widget = ImageWidget
|
|
|
|
field_kwargs = {
|
|
|
|
"validators": [
|
|
|
|
FileExtensionValidator(allowed_extensions=["png", "jpg", "jpeg", "webp"])
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class Banner(ImagePreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = instance
|
|
|
|
name = "banner"
|
|
|
|
verbose_name = "Banner image"
|
|
|
|
default = None
|
|
|
|
help_text = "This banner will be displayed on your pod's landing and about page. At least 600x100px recommended."
|
|
|
|
field_kwargs = {"required": False}
|