diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index ba2778dc8..000000000 --- a/.isort.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[settings] -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -use_parentheses=True -line_length=88 diff --git a/passbook/flows/api.py b/passbook/flows/api.py index bbdd58d05..c8e0493c5 100644 --- a/passbook/flows/api.py +++ b/passbook/flows/api.py @@ -25,6 +25,7 @@ class FlowSerializer(ModelSerializer): "slug", "title", "designation", + "background", "stages", "policies", "cache_count", diff --git a/passbook/flows/forms.py b/passbook/flows/forms.py index c0ac69749..9562e05c5 100644 --- a/passbook/flows/forms.py +++ b/passbook/flows/forms.py @@ -21,20 +21,12 @@ class FlowForm(forms.ModelForm): "title", "slug", "designation", + "background", ] - help_texts = { - "title": _("Shown as the Title in Flow pages."), - "slug": _("Visible in the URL."), - "designation": _( - ( - "Decides what this Flow is used for. For example, the Authentication flow " - "is redirect to when an un-authenticated user visits passbook." - ) - ), - } widgets = { "name": forms.TextInput(), "title": forms.TextInput(), + "background": forms.FileInput(), } diff --git a/passbook/flows/migrations/0016_auto_20201202_1307.py b/passbook/flows/migrations/0016_auto_20201202_1307.py new file mode 100644 index 000000000..49d72e283 --- /dev/null +++ b/passbook/flows/migrations/0016_auto_20201202_1307.py @@ -0,0 +1,50 @@ +# Generated by Django 3.1.3 on 2020-12-02 13:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("passbook_flows", "0015_flowstagebinding_evaluate_on_plan"), + ] + + operations = [ + migrations.AddField( + model_name="flow", + name="background", + field=models.FileField( + blank=True, + default="../static/dist/assets/images/flow_background.jpg", + help_text="Background shown during execution", + upload_to="flow-backgrounds/", + ), + ), + migrations.AlterField( + model_name="flow", + name="designation", + field=models.CharField( + choices=[ + ("authentication", "Authentication"), + ("authorization", "Authorization"), + ("invalidation", "Invalidation"), + ("enrollment", "Enrollment"), + ("unenrollment", "Unrenollment"), + ("recovery", "Recovery"), + ("stage_configuration", "Stage Configuration"), + ], + help_text="Decides what this Flow is used for. For example, the Authentication flow is redirect to when an un-authenticated user visits passbook.", + max_length=100, + ), + ), + migrations.AlterField( + model_name="flow", + name="slug", + field=models.SlugField(help_text="Visible in the URL.", unique=True), + ), + migrations.AlterField( + model_name="flow", + name="title", + field=models.TextField(help_text="Shown as the Title in Flow pages."), + ), + ] diff --git a/passbook/flows/models.py b/passbook/flows/models.py index b5f0995e9..ee92f1e85 100644 --- a/passbook/flows/models.py +++ b/passbook/flows/models.py @@ -92,11 +92,27 @@ class Flow(SerializerModel, PolicyBindingModel): flow_uuid = models.UUIDField(primary_key=True, editable=False, default=uuid4) name = models.TextField() - slug = models.SlugField(unique=True) + slug = models.SlugField(unique=True, help_text=_("Visible in the URL.")) - title = models.TextField() + title = models.TextField(help_text=_("Shown as the Title in Flow pages.")) - designation = models.CharField(max_length=100, choices=FlowDesignation.choices) + designation = models.CharField( + max_length=100, + choices=FlowDesignation.choices, + help_text=_( + ( + "Decides what this Flow is used for. For example, the Authentication flow " + "is redirect to when an un-authenticated user visits passbook." + ) + ), + ) + + background = models.FileField( + upload_to="flow-backgrounds/", + default="../static/dist/assets/images/flow_background.jpg", + blank=True, + help_text=_("Background shown during execution"), + ) stages = models.ManyToManyField(Stage, through="FlowStageBinding", blank=True) diff --git a/passbook/flows/templates/flows/shell.html b/passbook/flows/templates/flows/shell.html index 99fe36e13..ed4950463 100644 --- a/passbook/flows/templates/flows/shell.html +++ b/passbook/flows/templates/flows/shell.html @@ -17,6 +17,10 @@ .pb-hidden { display: none } + .pf-c-background-image::before { + background-image: url("{{ background_url }}"); + background-position: center; + } {% endblock %} diff --git a/passbook/flows/transfer/common.py b/passbook/flows/transfer/common.py index f0288b582..8d8af49b7 100644 --- a/passbook/flows/transfer/common.py +++ b/passbook/flows/transfer/common.py @@ -11,7 +11,7 @@ from passbook.lib.sentry import SentryIgnoredException def get_attrs(obj: SerializerModel) -> Dict[str, Any]: """Get object's attributes via their serializer, and covert it to a normal dict""" data = dict(obj.serializer(obj).data) - to_remove = ("policies", "stages", "pk") + to_remove = ("policies", "stages", "pk", "background") for to_remove_name in to_remove: if to_remove_name in data: data.pop(to_remove_name) diff --git a/passbook/flows/views.py b/passbook/flows/views.py index 0faa01aaf..c4439101e 100644 --- a/passbook/flows/views.py +++ b/passbook/flows/views.py @@ -235,6 +235,8 @@ class FlowExecutorShellView(TemplateView): template_name = "flows/shell.html" def get_context_data(self, **kwargs) -> Dict[str, Any]: + flow: Flow = get_object_or_404(Flow, slug=self.kwargs.get("flow_slug")) + kwargs["background_url"] = flow.background.url kwargs["exec_url"] = reverse("passbook_flows:flow-executor", kwargs=self.kwargs) self.request.session[SESSION_KEY_GET] = self.request.GET return kwargs diff --git a/pyproject.toml b/pyproject.toml index 03e86e477..ced2eb090 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,11 @@ [tool.black] target-version = ['py38'] exclude = 'node_modules' + +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +line_length = 88 +src_paths = ["passbook", "tests", "lifecycle"] diff --git a/swagger.yaml b/swagger.yaml index 7671c9ffe..c503bd299 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -6811,6 +6811,7 @@ definitions: minLength: 1 slug: title: Slug + description: Visible in the URL. type: string format: slug pattern: ^[-a-zA-Z0-9_]+$ @@ -6818,10 +6819,13 @@ definitions: minLength: 1 title: title: Title + description: Shown as the Title in Flow pages. type: string minLength: 1 designation: title: Designation + description: Decides what this Flow is used for. For example, the Authentication + flow is redirect to when an un-authenticated user visits passbook. type: string enum: - authentication @@ -6831,6 +6835,12 @@ definitions: - unenrollment - recovery - stage_configuration + background: + title: Background + description: Background shown during execution + type: string + readOnly: true + format: uri stages: type: array items: diff --git a/web/src/assets/images/flow_background.jpg b/web/src/assets/images/flow_background.jpg index 36a6cbfa4..75d3a60f3 100644 Binary files a/web/src/assets/images/flow_background.jpg and b/web/src/assets/images/flow_background.jpg differ diff --git a/web/src/passbook.css b/web/src/passbook.css index 7d441a94f..80eb6d757 100644 --- a/web/src/passbook.css +++ b/web/src/passbook.css @@ -33,11 +33,6 @@ html { margin-right: 0.5em; } -.pf-c-background-image::before { - background-image: url("assets/images/flow_background.jpg"); - background-position: center; -} - /* Fix patternfly sidebar and header with open Modal */ .pf-c-page__sidebar { z-index: 0;