mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 10:19:25 +02:00
See #236: backend for users default permissions
This commit is contained in:
parent
2ef36928c6
commit
a9799e66d7
3 changed files with 70 additions and 13 deletions
|
@ -1,6 +1,10 @@
|
|||
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
|
||||
|
||||
users = types.Section('users')
|
||||
|
||||
|
||||
|
@ -14,3 +18,23 @@ class RegistrationEnabled(types.BooleanPreference):
|
|||
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
|
||||
name = 'default_permissions'
|
||||
default = []
|
||||
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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue