flows: allow uploading of custom flow backgrounds, update default flow background
This commit is contained in:
parent
821458373d
commit
cc5a0c23aa
|
@ -1,6 +0,0 @@
|
||||||
[settings]
|
|
||||||
multi_line_output=3
|
|
||||||
include_trailing_comma=True
|
|
||||||
force_grid_wrap=0
|
|
||||||
use_parentheses=True
|
|
||||||
line_length=88
|
|
|
@ -25,6 +25,7 @@ class FlowSerializer(ModelSerializer):
|
||||||
"slug",
|
"slug",
|
||||||
"title",
|
"title",
|
||||||
"designation",
|
"designation",
|
||||||
|
"background",
|
||||||
"stages",
|
"stages",
|
||||||
"policies",
|
"policies",
|
||||||
"cache_count",
|
"cache_count",
|
||||||
|
|
|
@ -21,20 +21,12 @@ class FlowForm(forms.ModelForm):
|
||||||
"title",
|
"title",
|
||||||
"slug",
|
"slug",
|
||||||
"designation",
|
"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 = {
|
widgets = {
|
||||||
"name": forms.TextInput(),
|
"name": forms.TextInput(),
|
||||||
"title": forms.TextInput(),
|
"title": forms.TextInput(),
|
||||||
|
"background": forms.FileInput(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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."),
|
||||||
|
),
|
||||||
|
]
|
|
@ -92,11 +92,27 @@ class Flow(SerializerModel, PolicyBindingModel):
|
||||||
flow_uuid = models.UUIDField(primary_key=True, editable=False, default=uuid4)
|
flow_uuid = models.UUIDField(primary_key=True, editable=False, default=uuid4)
|
||||||
|
|
||||||
name = models.TextField()
|
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)
|
stages = models.ManyToManyField(Stage, through="FlowStageBinding", blank=True)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
.pb-hidden {
|
.pb-hidden {
|
||||||
display: none
|
display: none
|
||||||
}
|
}
|
||||||
|
.pf-c-background-image::before {
|
||||||
|
background-image: url("{{ background_url }}");
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from passbook.lib.sentry import SentryIgnoredException
|
||||||
def get_attrs(obj: SerializerModel) -> Dict[str, Any]:
|
def get_attrs(obj: SerializerModel) -> Dict[str, Any]:
|
||||||
"""Get object's attributes via their serializer, and covert it to a normal dict"""
|
"""Get object's attributes via their serializer, and covert it to a normal dict"""
|
||||||
data = dict(obj.serializer(obj).data)
|
data = dict(obj.serializer(obj).data)
|
||||||
to_remove = ("policies", "stages", "pk")
|
to_remove = ("policies", "stages", "pk", "background")
|
||||||
for to_remove_name in to_remove:
|
for to_remove_name in to_remove:
|
||||||
if to_remove_name in data:
|
if to_remove_name in data:
|
||||||
data.pop(to_remove_name)
|
data.pop(to_remove_name)
|
||||||
|
|
|
@ -235,6 +235,8 @@ class FlowExecutorShellView(TemplateView):
|
||||||
template_name = "flows/shell.html"
|
template_name = "flows/shell.html"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs) -> Dict[str, Any]:
|
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)
|
kwargs["exec_url"] = reverse("passbook_flows:flow-executor", kwargs=self.kwargs)
|
||||||
self.request.session[SESSION_KEY_GET] = self.request.GET
|
self.request.session[SESSION_KEY_GET] = self.request.GET
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
[tool.black]
|
[tool.black]
|
||||||
target-version = ['py38']
|
target-version = ['py38']
|
||||||
exclude = 'node_modules'
|
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"]
|
||||||
|
|
10
swagger.yaml
10
swagger.yaml
|
@ -6811,6 +6811,7 @@ definitions:
|
||||||
minLength: 1
|
minLength: 1
|
||||||
slug:
|
slug:
|
||||||
title: Slug
|
title: Slug
|
||||||
|
description: Visible in the URL.
|
||||||
type: string
|
type: string
|
||||||
format: slug
|
format: slug
|
||||||
pattern: ^[-a-zA-Z0-9_]+$
|
pattern: ^[-a-zA-Z0-9_]+$
|
||||||
|
@ -6818,10 +6819,13 @@ definitions:
|
||||||
minLength: 1
|
minLength: 1
|
||||||
title:
|
title:
|
||||||
title: Title
|
title: Title
|
||||||
|
description: Shown as the Title in Flow pages.
|
||||||
type: string
|
type: string
|
||||||
minLength: 1
|
minLength: 1
|
||||||
designation:
|
designation:
|
||||||
title: 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
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- authentication
|
- authentication
|
||||||
|
@ -6831,6 +6835,12 @@ definitions:
|
||||||
- unenrollment
|
- unenrollment
|
||||||
- recovery
|
- recovery
|
||||||
- stage_configuration
|
- stage_configuration
|
||||||
|
background:
|
||||||
|
title: Background
|
||||||
|
description: Background shown during execution
|
||||||
|
type: string
|
||||||
|
readOnly: true
|
||||||
|
format: uri
|
||||||
stages:
|
stages:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 670 KiB After Width: | Height: | Size: 1.1 MiB |
|
@ -33,11 +33,6 @@ html {
|
||||||
margin-right: 0.5em;
|
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 */
|
/* Fix patternfly sidebar and header with open Modal */
|
||||||
.pf-c-page__sidebar {
|
.pf-c-page__sidebar {
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
|
|
Reference in New Issue