mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-03 17:09:19 +02:00
See #872: banner setting
This commit is contained in:
parent
756063fa09
commit
ff566b79dc
6 changed files with 86 additions and 2 deletions
|
@ -1,4 +1,6 @@
|
|||
from django.forms import widgets
|
||||
from django.core.validators import FileExtensionValidator
|
||||
|
||||
from dynamic_preferences import types
|
||||
from dynamic_preferences.registries import global_preferences_registry
|
||||
|
||||
|
@ -129,3 +131,27 @@ class CustomCSS(types.StringPreference):
|
|||
)
|
||||
widget = widgets.Textarea
|
||||
field_kwargs = {"required": False}
|
||||
|
||||
|
||||
class ImageWidget(widgets.ClearableFileInput):
|
||||
pass
|
||||
|
||||
|
||||
class ImagePreference(types.FilePreference):
|
||||
widget = ImageWidget
|
||||
field_kwargs = {
|
||||
"validators": [
|
||||
FileExtensionValidator(allowed_extensions=["png", "jpg", "jpeg", "webp"])
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@global_preferences_registry.register
|
||||
class Banner(ImagePreference):
|
||||
show_in_api = True
|
||||
section = instance
|
||||
name = "banner"
|
||||
verbose_name = "Banner image"
|
||||
default = None
|
||||
help_text = "This banner will be displayed on your pod's landing and about page. At least 600x100px recommended."
|
||||
field_kwargs = {"required": False}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue