From 0b90cfcec41a9ab818ff238591c5b348b51dff5b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 5 Jun 2021 19:38:13 +0200 Subject: [PATCH] flows: set default background in code not model Signed-off-by: Jens Langhammer --- .../migrations/0019_alter_flow_background.py | 23 +++++++++++++++++++ authentik/flows/models.py | 8 +++---- schema.yml | 1 - 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 authentik/flows/migrations/0019_alter_flow_background.py diff --git a/authentik/flows/migrations/0019_alter_flow_background.py b/authentik/flows/migrations/0019_alter_flow_background.py new file mode 100644 index 000000000..fd8dab59a --- /dev/null +++ b/authentik/flows/migrations/0019_alter_flow_background.py @@ -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/", + ), + ), + ] diff --git a/authentik/flows/models.py b/authentik/flows/models.py index 8e1be9cb2..6e8f40bd1 100644 --- a/authentik/flows/models.py +++ b/authentik/flows/models.py @@ -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" ): diff --git a/schema.yml b/schema.yml index ca6512e91..7cea3098c 100644 --- a/schema.yml +++ b/schema.yml @@ -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