2018-02-24 11:20:42 +00:00
|
|
|
from dynamic_preferences import types
|
|
|
|
from dynamic_preferences.registries import global_preferences_registry
|
|
|
|
|
2018-05-26 10:45:55 +00:00
|
|
|
from funkwhale_api.common import preferences as common_preferences
|
|
|
|
|
|
|
|
from . import models
|
|
|
|
|
2018-06-09 13:36:16 +00:00
|
|
|
users = types.Section("users")
|
2018-02-24 11:20:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class RegistrationEnabled(types.BooleanPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = users
|
2018-06-09 13:36:16 +00:00
|
|
|
name = "registration_enabled"
|
2018-02-24 11:20:42 +00:00
|
|
|
default = False
|
2018-06-09 13:36:16 +00:00
|
|
|
verbose_name = "Open registrations to new users"
|
|
|
|
help_text = "When enabled, new users will be able to register on this instance."
|
2018-05-26 10:45:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class DefaultPermissions(common_preferences.StringListPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = users
|
2018-06-09 13:36:16 +00:00
|
|
|
name = "default_permissions"
|
2018-05-26 10:45:55 +00:00
|
|
|
default = []
|
2018-06-09 13:36:16 +00:00
|
|
|
verbose_name = "Default permissions"
|
|
|
|
help_text = "A list of default preferences to give to all registered users."
|
|
|
|
choices = [(k, c["label"]) for k, c in models.PERMISSIONS_CONFIGURATION.items()]
|
|
|
|
field_kwargs = {"choices": choices, "required": False}
|
2018-09-06 18:35:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
@global_preferences_registry.register
|
|
|
|
class UploadQuota(types.IntPreference):
|
|
|
|
show_in_api = True
|
|
|
|
section = users
|
|
|
|
name = "upload_quota"
|
|
|
|
default = 1000
|
|
|
|
verbose_name = "Upload quota"
|
2019-08-27 06:21:21 +00:00
|
|
|
help_text = "Default upload quota applied to each users, in MB. This can be overridden on a per-user basis."
|