diff --git a/passbook/flows/api.py b/passbook/flows/api.py index e270628f5..36f134314 100644 --- a/passbook/flows/api.py +++ b/passbook/flows/api.py @@ -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): diff --git a/passbook/flows/forms.py b/passbook/flows/forms.py index 46b90b05b..8345a6987 100644 --- a/passbook/flows/forms.py +++ b/passbook/flows/forms.py @@ -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": _( ( diff --git a/passbook/flows/migrations/0011_flow_title.py b/passbook/flows/migrations/0011_flow_title.py new file mode 100644 index 000000000..dfb20804b --- /dev/null +++ b/passbook/flows/migrations/0011_flow_title.py @@ -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, + ), + ] diff --git a/passbook/flows/models.py b/passbook/flows/models.py index aec61cadf..8120adc31 100644 --- a/passbook/flows/models.py +++ b/passbook/flows/models.py @@ -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() diff --git a/passbook/flows/stage.py b/passbook/flows/stage.py index f77ffcb4a..5b1107426 100644 --- a/passbook/flows/stage.py +++ b/passbook/flows/stage.py @@ -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") diff --git a/passbook/stages/prompt/migrations/0006_auto_20200828_1314.py b/passbook/stages/prompt/migrations/0006_auto_20200828_1314.py new file mode 100644 index 000000000..213e2d148 --- /dev/null +++ b/passbook/stages/prompt/migrations/0006_auto_20200828_1314.py @@ -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), + ), + ] diff --git a/swagger.yaml b/swagger.yaml index 92456170c..20f4f592d 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -5678,6 +5678,9 @@ definitions: pattern: ^[-a-zA-Z0-9_]+$ maxLength: 50 minLength: 1 + title: + title: Title + type: string designation: title: Designation type: string