flows/*: Initial flows stage1 implementation
This commit is contained in:
10
passbook/policies/apps.py
Normal file
10
passbook/policies/apps.py
Normal file
@ -0,0 +1,10 @@
|
||||
"""passbook policies app config"""
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PassbookPoliciesConfig(AppConfig):
|
||||
"""passbook policies app config"""
|
||||
|
||||
name = "passbook.policies"
|
||||
label = "passbook_policies"
|
||||
verbose_name = "passbook Policies"
|
||||
77
passbook/policies/migrations/0001_initial.py
Normal file
77
passbook/policies/migrations/0001_initial.py
Normal file
@ -0,0 +1,77 @@
|
||||
# Generated by Django 3.0.3 on 2020-05-07 18:35
|
||||
|
||||
import uuid
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("passbook_core", "0011_auto_20200222_1822"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="PolicyBinding",
|
||||
fields=[
|
||||
(
|
||||
"uuid",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
("enabled", models.BooleanField(default=True)),
|
||||
("order", models.IntegerField(default=0)),
|
||||
(
|
||||
"policy",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="+",
|
||||
to="passbook_core.Policy",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Policy Binding",
|
||||
"verbose_name_plural": "Policy Bindings",
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="PolicyBindingModel",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"policies",
|
||||
models.ManyToManyField(
|
||||
related_name="_policybindingmodel_policies_+",
|
||||
through="passbook_policies.PolicyBinding",
|
||||
to="passbook_core.Policy",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="policybinding",
|
||||
name="target",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="+",
|
||||
to="passbook_policies.PolicyBindingModel",
|
||||
),
|
||||
),
|
||||
]
|
||||
0
passbook/policies/migrations/__init__.py
Normal file
0
passbook/policies/migrations/__init__.py
Normal file
31
passbook/policies/models.py
Normal file
31
passbook/policies/models.py
Normal file
@ -0,0 +1,31 @@
|
||||
"""Policy base models"""
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from passbook.core.models import Policy
|
||||
from passbook.lib.models import UUIDModel
|
||||
|
||||
|
||||
class PolicyBindingModel(models.Model):
|
||||
"""Base Model for objects which have Policies applied to them"""
|
||||
|
||||
policies = models.ManyToManyField(Policy, through="PolicyBinding", related_name="+")
|
||||
|
||||
|
||||
class PolicyBinding(UUIDModel):
|
||||
"""Relationship between a Policy and a PolicyBindingModel."""
|
||||
|
||||
enabled = models.BooleanField(default=True)
|
||||
|
||||
policy = models.ForeignKey(Policy, on_delete=models.CASCADE, related_name="+")
|
||||
target = models.ForeignKey(
|
||||
PolicyBindingModel, on_delete=models.CASCADE, related_name="+"
|
||||
)
|
||||
|
||||
# default value and non-unique for compatibility
|
||||
order = models.IntegerField(default=0)
|
||||
|
||||
class Meta:
|
||||
|
||||
verbose_name = _("Policy Binding")
|
||||
verbose_name_plural = _("Policy Bindings")
|
||||
Reference in New Issue
Block a user