flows: set default background in code not model

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-05 19:38:13 +02:00
parent cefe3fa6dd
commit 0b90cfcec4
3 changed files with 27 additions and 5 deletions

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.3 on 2021-06-05 17:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("authentik_flows", "0018_oob_flows"),
]
operations = [
migrations.AlterField(
model_name="flow",
name="background",
field=models.FileField(
default=None,
help_text="Background shown during execution",
null=True,
upload_to="flow-backgrounds/",
),
),
]

View File

@ -110,17 +110,17 @@ class Flow(SerializerModel, PolicyBindingModel):
background = models.FileField(
upload_to="flow-backgrounds/",
default="../static/dist/assets/images/flow_background.jpg",
blank=True,
default=None,
null=True,
help_text=_("Background shown during execution"),
)
@property
def background_url(self) -> Optional[str]:
def background_url(self) -> str:
"""Get the URL to the background image. If the name is /static or starts with http
it is returned as-is"""
if not self.background:
return None
return "/static/dist/assets/images/flow_background.jpg"
if self.background.name.startswith("http") or self.background.name.startswith(
"/static"
):

View File

@ -17276,7 +17276,6 @@ components:
flow is redirect to when an un-authenticated user visits authentik.
background:
type: string
nullable: true
readOnly: true
stages:
type: array