Ejemplo n.º 1
0
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

playlists = types.Section("playlists")


@global_preferences_registry.register
class MaxTracks(types.IntegerPreference):
    show_in_api = True
    section = playlists
    name = "max_tracks"
    default = 250
    verbose_name = "Max tracks per playlist"
    field_kwargs = {"required": False}
from django.forms import widgets
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

raven = types.Section("raven")
instance = types.Section("instance")


@global_preferences_registry.register
class InstanceName(types.StringPreference):
    show_in_api = True
    section = instance
    name = "name"
    default = ""
    verbose_name = "Public name"
    help_text = "The public name of your instance, displayed in the about page."
    field_kwargs = {"required": False}


@global_preferences_registry.register
class InstanceShortDescription(types.StringPreference):
    show_in_api = True
    section = instance
    name = "short_description"
    default = ""
    verbose_name = "Short description"
    help_text = "Instance succinct description, displayed in the about page."
    field_kwargs = {"required": False}


@global_preferences_registry.register
Ejemplo n.º 3
0
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

from funkwhale_api.common import preferences

common = types.Section("common")


@global_preferences_registry.register
class APIAutenticationRequired(preferences.DefaultFromSettingMixin,
                               types.BooleanPreference):
    section = common
    name = "api_authentication_required"
    verbose_name = "API Requires authentication"
    setting = "API_AUTHENTICATION_REQUIRED"
    help_text = (
        "If disabled, anonymous users will be able to query the API"
        "and access music data (as well as other data exposed in the API "
        "without specific permissions).")
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

NON_INCENT = 'non_incent'
INCENT = 'incent'

MIN_CR = 'min_cr'
MAX_CR = 'max_cr'
PACC = 'pacc'
CLICKS_IF_ZERO_CONV = 'clicks_if_zero_conv'
CAP_FILL = 'cap_fill'
MIN_CLICKS = 'min_clicks'
STATUS = 'status'

non_incent = types.Section(NON_INCENT, verbose_name='Non Incent')
incent = types.Section(INCENT, verbose_name='Incent')


@global_preferences_registry.register
class Min_CR_NonIncent(types.FloatPreference):
    section = non_incent
    name = MIN_CR
    verbose_name = 'Min CR'
    default = .0


@global_preferences_registry.register
class Max_CR_NonIncent(types.FloatPreference):
    section = non_incent
    name = MAX_CR
    verbose_name = 'Max CR'
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

audio = types.Section("audio")


@global_preferences_registry.register
class ChannelsEnabled(types.BooleanPreference):
    section = audio
    name = "channels_enabled"
    default = True
    verbose_name = "Enable channels"
    help_text = (
        "If disabled, the channels feature will be completely switched off, "
        "and users won't be able to create channels or subscribe to them.")


@global_preferences_registry.register
class MaxChannels(types.IntegerPreference):
    show_in_api = True
    section = audio
    default = 20
    name = "max_channels"
    verbose_name = "Max channels allowed per user"
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

from rest_framework import serializers

from funkwhale_api.common import preferences as common_preferences
from funkwhale_api.common import serializers as common_serializers
from funkwhale_api.common import utils as common_utils

from . import models

moderation = types.Section("moderation")


@global_preferences_registry.register
class AllowListEnabled(types.BooleanPreference):
    section = moderation
    name = "allow_list_enabled"
    verbose_name = "Enable allow-listing"
    help_text = "If enabled, only interactions with explicitely allowed domains will be authorized."
    default = False


@global_preferences_registry.register
class AllowListPublic(types.BooleanPreference):
    section = moderation
    name = "allow_list_public"
    verbose_name = "Publish your allowed-domains list"
    help_text = (
        "If enabled, everyone will be able to retrieve the list of domains you allowed. "
        "This is useful on open setups, to help people decide if they want to join your pod, or to "
Ejemplo n.º 7
0
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

from funkwhale_api.common import preferences

federation = types.Section("federation")


@global_preferences_registry.register
class MusicCacheDuration(types.IntPreference):
    show_in_api = True
    section = federation
    name = "music_cache_duration"
    default = 60 * 24 * 2
    verbose_name = "Music cache duration"
    help_text = (
        "How many minutes do you want to keep a copy of federated tracks "
        "locally? Federated files that were not listened in this interval "
        "will be erased and refetched from the remote on the next listening.")
    field_kwargs = {"required": False}


@global_preferences_registry.register
class Enabled(preferences.DefaultFromSettingMixin, types.BooleanPreference):
    section = federation
    name = "enabled"
    setting = "FEDERATION_ENABLED"
    verbose_name = "Federation enabled"
    help_text = (
        "Use this setting to enable or disable federation logic and API"
        " globally.")
Ejemplo n.º 8
0
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

subsonic = types.Section("subsonic")


@global_preferences_registry.register
class APIAutenticationRequired(types.BooleanPreference):
    section = subsonic
    show_in_api = True
    name = "enabled"
    default = True
    verbose_name = "Enabled Subsonic API"
    help_text = (
        "Funkwhale supports a subset of the Subsonic API, that makes "
        "it compatible with existing clients such as DSub for Android "
        "or Clementine for desktop. However, Subsonic protocol is less "
        "than ideal in terms of security and you can disable this feature "
        "completely using this flag.")
Ejemplo n.º 9
0
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")


@global_preferences_registry.register
class RegistrationEnabled(types.BooleanPreference):
    show_in_api = True
    section = users
    name = "registration_enabled"
    default = False
    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
    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}
Ejemplo n.º 10
0
 class TestSerialized(common_preferences.SerializedPreference):
     section = types.Section("test")
     name = "serialized"
     data_serializer_class = PreferenceDataSerializer
     default = None
     required = False
Ejemplo n.º 11
0
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

music = types.Section("music")


@global_preferences_registry.register
class MaxTracks(types.BooleanPreference):
    show_in_api = True
    section = music
    name = "transcoding_enabled"
    verbose_name = "Transcoding enabled"
    help_text = (
        "Enable transcoding of audio files in formats requested by the client. "
        "This is especially useful for devices that do not support formats "
        "such as Flac or Ogg, but the transcoding process will increase the "
        "load on the server.")
    default = True


@global_preferences_registry.register
class MusicCacheDuration(types.IntPreference):
    show_in_api = True
    section = music
    name = "transcoding_cache_duration"
    default = 60 * 24 * 7
    verbose_name = "Transcoding cache duration"
    help_text = (
        "How much minutes do you want to keep a copy of transcoded tracks "
        "on the server? Transcoded files that were not listened in this interval "
        "will be erased and retranscoded on the next listening.")