Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arthur Brugière
funkwhale
Commits
cdabb269
Verified
Commit
cdabb269
authored
7 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Fix #30: added instance preferences for name and descriptions
parent
b4ace3c9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/instance/dynamic_preferences_registry.py
+33
-0
33 additions, 0 deletions
api/funkwhale_api/instance/dynamic_preferences_registry.py
api/tests/instance/test_preferences.py
+13
-0
13 additions, 0 deletions
api/tests/instance/test_preferences.py
with
46 additions
and
0 deletions
api/funkwhale_api/instance/dynamic_preferences_registry.py
+
33
−
0
View file @
cdabb269
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
):
...
...
This diff is collapsed.
Click to expand it.
api/tests/instance/test_preferences.py
+
13
−
0
View file @
cdabb269
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment