Skip to content
Snippets Groups Projects
dynamic_preferences_registry.py 1.31 KiB
Newer Older
  • Learn to ignore specific revisions
  • from dynamic_preferences import types
    from dynamic_preferences.registries import global_preferences_registry
    
    
    from funkwhale_api.common import preferences as common_preferences
    
    from . import models
    
    
    Eliot Berriot's avatar
    Eliot Berriot committed
    users = types.Section("users")
    
    
    
    @global_preferences_registry.register
    class RegistrationEnabled(types.BooleanPreference):
        show_in_api = True
        section = users
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        name = "registration_enabled"
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        verbose_name = "Open registrations to new users"
        help_text = "When enabled, new users will be able to register on this instance."
    
    
    
    @global_preferences_registry.register
    class DefaultPermissions(common_preferences.StringListPreference):
        show_in_api = True
        section = users
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        name = "default_permissions"
    
    Eliot Berriot's avatar
    Eliot Berriot committed
        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}
    
    
    
    @global_preferences_registry.register
    class UploadQuota(types.IntPreference):
        show_in_api = True
        section = users
        name = "upload_quota"
        default = 1000
        verbose_name = "Upload quota"
    
        help_text = "Default upload quota applied to each users, in MB. This can be overridden on a per-user basis."