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
|
import uuid
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("passbook_flows", "0003_auto_20200509_1258"),
|
("passbook_flows", "0005_auto_20200512_1158"),
|
||||||
|
("passbook_policies", "0003_auto_20200508_1642"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
@ -42,6 +43,7 @@ class Migration(migrations.Migration):
|
||||||
("e-mail", "Email"),
|
("e-mail", "Email"),
|
||||||
("password", "Password"),
|
("password", "Password"),
|
||||||
("number", "Number"),
|
("number", "Number"),
|
||||||
|
("hidden", "Hidden"),
|
||||||
],
|
],
|
||||||
max_length=100,
|
max_length=100,
|
||||||
),
|
),
|
||||||
|
@ -49,20 +51,29 @@ class Migration(migrations.Migration):
|
||||||
("required", models.BooleanField(default=True)),
|
("required", models.BooleanField(default=True)),
|
||||||
("placeholder", models.TextField()),
|
("placeholder", models.TextField()),
|
||||||
],
|
],
|
||||||
options={"abstract": False,},
|
options={"verbose_name": "Prompt", "verbose_name_plural": "Prompts",},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="PromptStage",
|
name="PromptStage",
|
||||||
fields=[
|
fields=[
|
||||||
(
|
(
|
||||||
"stage_ptr",
|
"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(
|
models.OneToOneField(
|
||||||
auto_created=True,
|
auto_created=True,
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
parent_link=True,
|
parent_link=True,
|
||||||
primary_key=True,
|
primary_key=True,
|
||||||
serialize=False,
|
serialize=False,
|
||||||
to="passbook_flows.Stage",
|
to="passbook_policies.PolicyBindingModel",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
("fields", models.ManyToManyField(to="passbook_stages_prompt.Prompt")),
|
("fields", models.ManyToManyField(to="passbook_stages_prompt.Prompt")),
|
||||||
|
@ -71,6 +82,6 @@ class Migration(migrations.Migration):
|
||||||
"verbose_name": "Prompt Stage",
|
"verbose_name": "Prompt Stage",
|
||||||
"verbose_name_plural": "Prompt Stages",
|
"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.flows.models import Stage
|
||||||
from passbook.lib.models import UUIDModel
|
from passbook.lib.models import UUIDModel
|
||||||
|
from passbook.policies.models import PolicyBindingModel
|
||||||
|
|
||||||
|
|
||||||
class FieldTypes(models.TextChoices):
|
class FieldTypes(models.TextChoices):
|
||||||
|
@ -78,7 +79,7 @@ class Prompt(UUIDModel):
|
||||||
verbose_name_plural = _("Prompts")
|
verbose_name_plural = _("Prompts")
|
||||||
|
|
||||||
|
|
||||||
class PromptStage(Stage):
|
class PromptStage(PolicyBindingModel, Stage):
|
||||||
"""Prompt Stage, pointing to multiple prompts"""
|
"""Prompt Stage, pointing to multiple prompts"""
|
||||||
|
|
||||||
fields = models.ManyToManyField(Prompt)
|
fields = models.ManyToManyField(Prompt)
|
||||||
|
|
162
swagger.yaml
162
swagger.yaml
|
@ -821,6 +821,133 @@ paths:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
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/:
|
/policies/dummy/:
|
||||||
get:
|
get:
|
||||||
operationId: policies_dummy_list
|
operationId: policies_dummy_list
|
||||||
|
@ -4211,7 +4338,7 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- stages
|
- stages
|
||||||
parameters: []
|
parameters: []
|
||||||
/stages/prompt/stages/{uuid}/:
|
/stages/prompt/stages/{id}/:
|
||||||
get:
|
get:
|
||||||
operationId: stages_prompt_stages_read
|
operationId: stages_prompt_stages_read
|
||||||
description: PromptStage Viewset
|
description: PromptStage Viewset
|
||||||
|
@ -4265,12 +4392,11 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- stages
|
- stages
|
||||||
parameters:
|
parameters:
|
||||||
- name: uuid
|
- name: id
|
||||||
in: path
|
in: path
|
||||||
description: A UUID string identifying this Prompt Stage.
|
description: A unique integer value identifying this Prompt Stage.
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: integer
|
||||||
format: uuid
|
|
||||||
/stages/user_delete/:
|
/stages/user_delete/:
|
||||||
get:
|
get:
|
||||||
operationId: stages_user_delete_list
|
operationId: stages_user_delete_list
|
||||||
|
@ -5050,6 +5176,27 @@ definitions:
|
||||||
title: 'type '
|
title: 'type '
|
||||||
type: string
|
type: string
|
||||||
readOnly: true
|
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:
|
DummyPolicy:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -6101,9 +6248,8 @@ definitions:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
pk:
|
pk:
|
||||||
title: Uuid
|
title: ID
|
||||||
type: string
|
type: integer
|
||||||
format: uuid
|
|
||||||
readOnly: true
|
readOnly: true
|
||||||
name:
|
name:
|
||||||
title: Name
|
title: Name
|
||||||
|
|
Reference in a new issue