From b4ace3c9dd29972440a974a16514a06e0b046a62 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Sat, 24 Feb 2018 15:10:47 +0100 Subject: [PATCH 1/4] Typo --- front/src/store/instance.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/store/instance.js b/front/src/store/instance.js index 80003db0d..ed7d653fc 100644 --- a/front/src/store/instance.js +++ b/front/src/store/instance.js @@ -40,7 +40,7 @@ export default { }) commit('settings', sections) if (payload && payload.callback) { - callback() + payload.callback() } }, response => { logger.default.error('Error while fetching settings', response.data) From cdabb26989ebc233520051dab816220942649922 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Sat, 24 Feb 2018 15:27:51 +0100 Subject: [PATCH 2/4] Fix #30: added instance preferences for name and descriptions --- .../instance/dynamic_preferences_registry.py | 33 +++++++++++++++++++ api/tests/instance/test_preferences.py | 13 ++++++++ 2 files changed, 46 insertions(+) diff --git a/api/funkwhale_api/instance/dynamic_preferences_registry.py b/api/funkwhale_api/instance/dynamic_preferences_registry.py index 1d93c383e..1d11a2988 100644 --- a/api/funkwhale_api/instance/dynamic_preferences_registry.py +++ b/api/funkwhale_api/instance/dynamic_preferences_registry.py @@ -1,9 +1,42 @@ +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 = '' + help_text = 'Instance public name' + verbose_name = 'The public name of your instance' + + +@global_preferences_registry.register +class InstanceShortDescription(types.StringPreference): + show_in_api = True + section = instance + name = 'short_description' + default = '' + verbose_name = 'Instance succinct description' + + +@global_preferences_registry.register +class InstanceLongDescription(types.StringPreference): + show_in_api = True + section = instance + name = 'long_description' + default = '' + help_text = 'Instance long description (markdown allowed)' + field_kwargs = { + 'widget': widgets.Textarea + } + @global_preferences_registry.register class RavenDSN(types.StringPreference): show_in_api = True diff --git a/api/tests/instance/test_preferences.py b/api/tests/instance/test_preferences.py index c89bfa349..beb8e6d33 100644 --- a/api/tests/instance/test_preferences.py +++ b/api/tests/instance/test_preferences.py @@ -1,3 +1,5 @@ +import pytest + from django.urls import reverse from dynamic_preferences.api import serializers @@ -20,3 +22,14 @@ def test_can_list_settings_via_api(preferences, api_client): for p in response.data: i = '__'.join([p['section'], p['name']]) assert i in expected_preferences + + +@pytest.mark.parametrize('pref,value', [ + ('instance__name', 'My instance'), + ('instance__short_description', 'For music lovers'), + ('instance__long_description', 'For real music lovers'), +]) +def test_instance_settings(pref, value, preferences): + preferences[pref] = value + + assert preferences[pref] == value From ab2af7a548dd5cfdb89ca9dae142fa4470e236ea Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Sat, 24 Feb 2018 15:28:09 +0100 Subject: [PATCH 3/4] About page for instance based on instance descriptions --- front/src/App.vue | 3 +++ front/src/components/About.vue | 45 ++++++++++++++++++++++++++++++++++ front/src/components/Home.vue | 4 +++ front/src/router/index.js | 6 +++++ front/src/store/instance.js | 11 +++++++++ 5 files changed, 69 insertions(+) create mode 100644 front/src/components/About.vue diff --git a/front/src/App.vue b/front/src/App.vue index 98ad48d3f..8453aa339 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -9,6 +9,9 @@

Links