flows: add title field
This commit is contained in:
parent
a977184577
commit
c39d136383
|
@ -11,7 +11,7 @@ class FlowSerializer(ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
model = Flow
|
model = Flow
|
||||||
fields = ["pk", "name", "slug", "designation", "stages", "policies"]
|
fields = ["pk", "name", "slug", "title", "designation", "stages", "policies"]
|
||||||
|
|
||||||
|
|
||||||
class FlowViewSet(ModelViewSet):
|
class FlowViewSet(ModelViewSet):
|
||||||
|
|
|
@ -17,11 +17,12 @@ class FlowForm(forms.ModelForm):
|
||||||
model = Flow
|
model = Flow
|
||||||
fields = [
|
fields = [
|
||||||
"name",
|
"name",
|
||||||
|
"title",
|
||||||
"slug",
|
"slug",
|
||||||
"designation",
|
"designation",
|
||||||
]
|
]
|
||||||
help_texts = {
|
help_texts = {
|
||||||
"name": _("Shown as the Title in Flow pages."),
|
"title": _("Shown as the Title in Flow pages."),
|
||||||
"slug": _("Visible in the URL."),
|
"slug": _("Visible in the URL."),
|
||||||
"designation": _(
|
"designation": _(
|
||||||
(
|
(
|
||||||
|
|
27
passbook/flows/migrations/0011_flow_title.py
Normal file
27
passbook/flows/migrations/0011_flow_title.py
Normal 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,
|
||||||
|
),
|
||||||
|
]
|
|
@ -93,6 +93,8 @@ class Flow(SerializerModel, PolicyBindingModel):
|
||||||
name = models.TextField()
|
name = models.TextField()
|
||||||
slug = models.SlugField(unique=True)
|
slug = models.SlugField(unique=True)
|
||||||
|
|
||||||
|
title = models.TextField(default="", blank=True)
|
||||||
|
|
||||||
designation = models.CharField(max_length=100, choices=FlowDesignation.choices)
|
designation = models.CharField(max_length=100, choices=FlowDesignation.choices)
|
||||||
|
|
||||||
stages = models.ManyToManyField(Stage, through="FlowStageBinding", blank=True)
|
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."""
|
"""Get a Flow by `**flow_filter` and check if the request from `request` can access it."""
|
||||||
from passbook.policies.engine import PolicyEngine
|
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:
|
for flow in flows:
|
||||||
engine = PolicyEngine(flow, request.user, request)
|
engine = PolicyEngine(flow, request.user, request)
|
||||||
engine.build()
|
engine.build()
|
||||||
|
|
|
@ -22,7 +22,7 @@ class StageView(TemplateView):
|
||||||
self.executor = executor
|
self.executor = executor
|
||||||
|
|
||||||
def get_context_data(self, **kwargs: Dict[str, Any]) -> Dict[str, Any]:
|
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:
|
if PLAN_CONTEXT_PENDING_USER in self.executor.plan.context:
|
||||||
kwargs["user"] = self.executor.plan.context[PLAN_CONTEXT_PENDING_USER]
|
kwargs["user"] = self.executor.plan.context[PLAN_CONTEXT_PENDING_USER]
|
||||||
kwargs["primary_action"] = _("Continue")
|
kwargs["primary_action"] = _("Continue")
|
||||||
|
|
16
passbook/stages/prompt/migrations/0006_auto_20200828_1314.py
Normal file
16
passbook/stages/prompt/migrations/0006_auto_20200828_1314.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -5678,6 +5678,9 @@ definitions:
|
||||||
pattern: ^[-a-zA-Z0-9_]+$
|
pattern: ^[-a-zA-Z0-9_]+$
|
||||||
maxLength: 50
|
maxLength: 50
|
||||||
minLength: 1
|
minLength: 1
|
||||||
|
title:
|
||||||
|
title: Title
|
||||||
|
type: string
|
||||||
designation:
|
designation:
|
||||||
title: Designation
|
title: Designation
|
||||||
type: string
|
type: string
|
||||||
|
|
Reference in a new issue