flows: add title field

This commit is contained in:
Jens Langhammer 2020-08-28 15:23:03 +02:00
parent a977184577
commit c39d136383
7 changed files with 53 additions and 4 deletions

View File

@ -11,7 +11,7 @@ class FlowSerializer(ModelSerializer):
class Meta:
model = Flow
fields = ["pk", "name", "slug", "designation", "stages", "policies"]
fields = ["pk", "name", "slug", "title", "designation", "stages", "policies"]
class FlowViewSet(ModelViewSet):

View File

@ -17,11 +17,12 @@ class FlowForm(forms.ModelForm):
model = Flow
fields = [
"name",
"title",
"slug",
"designation",
]
help_texts = {
"name": _("Shown as the Title in Flow pages."),
"title": _("Shown as the Title in Flow pages."),
"slug": _("Visible in the URL."),
"designation": _(
(

View File

@ -0,0 +1,27 @@
# Generated by Django 3.1 on 2020-08-28 13:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_flows", "0010_provider_flows"),
]
operations = [
migrations.AlterModelOptions(
name="flow",
options={
"permissions": [("export_flow", "Can export a Flow")],
"verbose_name": "Flow",
"verbose_name_plural": "Flows",
},
),
migrations.AddField(
model_name="flow",
name="title",
field=models.TextField(default="", blank=True),
preserve_default=False,
),
]

View File

@ -93,6 +93,8 @@ class Flow(SerializerModel, PolicyBindingModel):
name = models.TextField()
slug = models.SlugField(unique=True)
title = models.TextField(default="", blank=True)
designation = models.CharField(max_length=100, choices=FlowDesignation.choices)
stages = models.ManyToManyField(Stage, through="FlowStageBinding", blank=True)
@ -108,7 +110,7 @@ class Flow(SerializerModel, PolicyBindingModel):
"""Get a Flow by `**flow_filter` and check if the request from `request` can access it."""
from passbook.policies.engine import PolicyEngine
flows = Flow.objects.filter(**flow_filter)
flows = Flow.objects.filter(**flow_filter).order_by("slug")
for flow in flows:
engine = PolicyEngine(flow, request.user, request)
engine.build()

View File

@ -22,7 +22,7 @@ class StageView(TemplateView):
self.executor = executor
def get_context_data(self, **kwargs: Dict[str, Any]) -> Dict[str, Any]:
kwargs["title"] = self.executor.flow.name
kwargs["title"] = self.executor.flow.title
if PLAN_CONTEXT_PENDING_USER in self.executor.plan.context:
kwargs["user"] = self.executor.plan.context[PLAN_CONTEXT_PENDING_USER]
kwargs["primary_action"] = _("Continue")

View File

@ -0,0 +1,16 @@
# Generated by Django 3.1 on 2020-08-28 13:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_prompt", "0005_auto_20200709_1608"),
]
operations = [
migrations.AlterField(
model_name="prompt", name="placeholder", field=models.TextField(blank=True),
),
]

View File

@ -5678,6 +5678,9 @@ definitions:
pattern: ^[-a-zA-Z0-9_]+$
maxLength: 50
minLength: 1
title:
title: Title
type: string
designation:
title: Designation
type: string