stages/prompt: promptstage based on PolicyBindingModel
This commit is contained in:
parent
9859c5db0a
commit
a7a839a29c
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 3.0.5 on 2020-05-10 14:03
|
||||
# Generated by Django 3.0.5 on 2020-05-14 11:46
|
||||
|
||||
import uuid
|
||||
|
||||
|
@ -11,7 +11,8 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("passbook_flows", "0003_auto_20200509_1258"),
|
||||
("passbook_flows", "0005_auto_20200512_1158"),
|
||||
("passbook_policies", "0003_auto_20200508_1642"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
@ -42,6 +43,7 @@ class Migration(migrations.Migration):
|
|||
("e-mail", "Email"),
|
||||
("password", "Password"),
|
||||
("number", "Number"),
|
||||
("hidden", "Hidden"),
|
||||
],
|
||||
max_length=100,
|
||||
),
|
||||
|
@ -49,20 +51,29 @@ class Migration(migrations.Migration):
|
|||
("required", models.BooleanField(default=True)),
|
||||
("placeholder", models.TextField()),
|
||||
],
|
||||
options={"abstract": False,},
|
||||
options={"verbose_name": "Prompt", "verbose_name_plural": "Prompts",},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="PromptStage",
|
||||
fields=[
|
||||
(
|
||||
"stage_ptr",
|
||||
models.OneToOneField(
|
||||
auto_created=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
parent_link=True,
|
||||
to="passbook_flows.Stage",
|
||||
),
|
||||
),
|
||||
(
|
||||
"policybindingmodel_ptr",
|
||||
models.OneToOneField(
|
||||
auto_created=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
parent_link=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
to="passbook_flows.Stage",
|
||||
to="passbook_policies.PolicyBindingModel",
|
||||
),
|
||||
),
|
||||
("fields", models.ManyToManyField(to="passbook_stages_prompt.Prompt")),
|
||||
|
@ -71,6 +82,6 @@ class Migration(migrations.Migration):
|
|||
"verbose_name": "Prompt Stage",
|
||||
"verbose_name_plural": "Prompt Stages",
|
||||
},
|
||||
bases=("passbook_flows.stage",),
|
||||
bases=("passbook_policies.policybindingmodel", "passbook_flows.stage"),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
# Generated by Django 3.0.5 on 2020-05-10 16:48
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("passbook_stages_prompt", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="prompt",
|
||||
options={"verbose_name": "Prompt", "verbose_name_plural": "Prompts"},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="prompt",
|
||||
name="type",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("text", "Text"),
|
||||
("e-mail", "Email"),
|
||||
("password", "Password"),
|
||||
("number", "Number"),
|
||||
("hidden", "Hidden"),
|
||||
],
|
||||
max_length=100,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -5,6 +5,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
|
||||
from passbook.flows.models import Stage
|
||||
from passbook.lib.models import UUIDModel
|
||||
from passbook.policies.models import PolicyBindingModel
|
||||
|
||||
|
||||
class FieldTypes(models.TextChoices):
|
||||
|
@ -78,7 +79,7 @@ class Prompt(UUIDModel):
|
|||
verbose_name_plural = _("Prompts")
|
||||
|
||||
|
||||
class PromptStage(Stage):
|
||||
class PromptStage(PolicyBindingModel, Stage):
|
||||
"""Prompt Stage, pointing to multiple prompts"""
|
||||
|
||||
fields = models.ManyToManyField(Prompt)
|
||||
|
|
162
swagger.yaml
162
swagger.yaml
|
@ -821,6 +821,133 @@ paths:
|
|||
required: true
|
||||
type: string
|
||||
format: uuid
|
||||
/policies/bindings/:
|
||||
get:
|
||||
operationId: policies_bindings_list
|
||||
description: PolicyBinding Viewset
|
||||
parameters:
|
||||
- name: ordering
|
||||
in: query
|
||||
description: Which field to use when ordering the results.
|
||||
required: false
|
||||
type: string
|
||||
- name: search
|
||||
in: query
|
||||
description: A search term.
|
||||
required: false
|
||||
type: string
|
||||
- name: limit
|
||||
in: query
|
||||
description: Number of results to return per page.
|
||||
required: false
|
||||
type: integer
|
||||
- name: offset
|
||||
in: query
|
||||
description: The initial index from which to return the results.
|
||||
required: false
|
||||
type: integer
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
schema:
|
||||
required:
|
||||
- count
|
||||
- results
|
||||
type: object
|
||||
properties:
|
||||
count:
|
||||
type: integer
|
||||
next:
|
||||
type: string
|
||||
format: uri
|
||||
x-nullable: true
|
||||
previous:
|
||||
type: string
|
||||
format: uri
|
||||
x-nullable: true
|
||||
results:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/PolicyBinding'
|
||||
tags:
|
||||
- policies
|
||||
post:
|
||||
operationId: policies_bindings_create
|
||||
description: PolicyBinding Viewset
|
||||
parameters:
|
||||
- name: data
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/PolicyBinding'
|
||||
responses:
|
||||
'201':
|
||||
description: ''
|
||||
schema:
|
||||
$ref: '#/definitions/PolicyBinding'
|
||||
tags:
|
||||
- policies
|
||||
parameters: []
|
||||
/policies/bindings/{uuid}/:
|
||||
get:
|
||||
operationId: policies_bindings_read
|
||||
description: PolicyBinding Viewset
|
||||
parameters: []
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
schema:
|
||||
$ref: '#/definitions/PolicyBinding'
|
||||
tags:
|
||||
- policies
|
||||
put:
|
||||
operationId: policies_bindings_update
|
||||
description: PolicyBinding Viewset
|
||||
parameters:
|
||||
- name: data
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/PolicyBinding'
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
schema:
|
||||
$ref: '#/definitions/PolicyBinding'
|
||||
tags:
|
||||
- policies
|
||||
patch:
|
||||
operationId: policies_bindings_partial_update
|
||||
description: PolicyBinding Viewset
|
||||
parameters:
|
||||
- name: data
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/PolicyBinding'
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
schema:
|
||||
$ref: '#/definitions/PolicyBinding'
|
||||
tags:
|
||||
- policies
|
||||
delete:
|
||||
operationId: policies_bindings_delete
|
||||
description: PolicyBinding Viewset
|
||||
parameters: []
|
||||
responses:
|
||||
'204':
|
||||
description: ''
|
||||
tags:
|
||||
- policies
|
||||
parameters:
|
||||
- name: uuid
|
||||
in: path
|
||||
description: A UUID string identifying this Policy Binding.
|
||||
required: true
|
||||
type: string
|
||||
format: uuid
|
||||
/policies/dummy/:
|
||||
get:
|
||||
operationId: policies_dummy_list
|
||||
|
@ -4211,7 +4338,7 @@ paths:
|
|||
tags:
|
||||
- stages
|
||||
parameters: []
|
||||
/stages/prompt/stages/{uuid}/:
|
||||
/stages/prompt/stages/{id}/:
|
||||
get:
|
||||
operationId: stages_prompt_stages_read
|
||||
description: PromptStage Viewset
|
||||
|
@ -4265,12 +4392,11 @@ paths:
|
|||
tags:
|
||||
- stages
|
||||
parameters:
|
||||
- name: uuid
|
||||
- name: id
|
||||
in: path
|
||||
description: A UUID string identifying this Prompt Stage.
|
||||
description: A unique integer value identifying this Prompt Stage.
|
||||
required: true
|
||||
type: string
|
||||
format: uuid
|
||||
type: integer
|
||||
/stages/user_delete/:
|
||||
get:
|
||||
operationId: stages_user_delete_list
|
||||
|
@ -5050,6 +5176,27 @@ definitions:
|
|||
title: 'type '
|
||||
type: string
|
||||
readOnly: true
|
||||
PolicyBinding:
|
||||
required:
|
||||
- policy
|
||||
- target
|
||||
type: object
|
||||
properties:
|
||||
policy:
|
||||
title: Policy
|
||||
type: string
|
||||
format: uuid
|
||||
target:
|
||||
title: Target
|
||||
type: integer
|
||||
enabled:
|
||||
title: Enabled
|
||||
type: boolean
|
||||
order:
|
||||
title: Order
|
||||
type: integer
|
||||
maximum: 2147483647
|
||||
minimum: -2147483648
|
||||
DummyPolicy:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -6101,9 +6248,8 @@ definitions:
|
|||
type: object
|
||||
properties:
|
||||
pk:
|
||||
title: Uuid
|
||||
type: string
|
||||
format: uuid
|
||||
title: ID
|
||||
type: integer
|
||||
readOnly: true
|
||||
name:
|
||||
title: Name
|
||||
|
|
Reference in a new issue