-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data Models of PolicyTemplate and its Components (#594)
* Allow more types of PolicyVariables, such as float and timestamp, and a list of basic data types; Allow specification of the entity of a policy variable * Add functions in PolicyVariable to enforce the value of a policy variable to be the specified data types * 1. Enforce policy variables to be the expected data type when building evaluation context; 2. Allow users to use policy variables in the attribute style * Add Json-style CustomAction data model * Create new permissions for custom actions with a community name * Add FilterModule class * Add Transformer (CheckModule) class * Change the name of CheckModule to Transformer * Add Procedure class * Add PolicyTemplate class * helper functions that help put all components into a policy template instance * Implement to_json function of the PoicyTemplate class * Tentatively remove codes about is_template policy * Specify all filterable parameters for each Slack GovernableAction * Specify schemas for execution parameters of each Slack GovernableAction * Add a few community functions to support the need of new filters * Add a few comments about parts of the data models that are temporary * Adjust the Platform List from procedure to filter module as the latter is first defined * Makemigrations according to updates of data models
- Loading branch information
1 parent
cf451e3
commit eba41df
Showing
4 changed files
with
898 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
policykit/policyengine/migrations/0018_auto_20230521_1821.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# Generated by Django 3.2.2 on 2023-05-21 18:21 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('policyengine', '0017_alter_policy_community'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CustomAction', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('is_trigger', models.BooleanField(default=False)), | ||
('filter', models.TextField(blank=True, default='[]')), | ||
('community_name', models.TextField(null=True, unique=True)), | ||
('action_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='policyengine.actiontype')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Transformer', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.TextField(blank=True, default='', unique=True)), | ||
('description', models.TextField(blank=True, default='')), | ||
('codes', models.TextField(blank=True, default='')), | ||
('variables', models.TextField(blank=True, default='[]')), | ||
('data', models.TextField(blank=True, default='[]')), | ||
], | ||
), | ||
migrations.RemoveField( | ||
model_name='policy', | ||
name='is_template', | ||
), | ||
migrations.AddField( | ||
model_name='policyvariable', | ||
name='entity', | ||
field=models.CharField(blank=True, max_length=100, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='policyvariable', | ||
name='is_list', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AlterField( | ||
model_name='policyvariable', | ||
name='type', | ||
field=models.CharField(choices=[('number', 'number'), ('string', 'string'), ('float', 'float'), ('timestamp', 'timestamp')], default='string', max_length=30), | ||
), | ||
migrations.CreateModel( | ||
name='Procedure', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.TextField(blank=True, default='')), | ||
('description', models.TextField(blank=True, default='')), | ||
('platform', models.TextField(blank=True, choices=[('Slack', 'Slack'), ('Discord', 'Discord'), ('Discourse', 'Discourse'), ('Github', 'Github'), ('Opencollective', 'OpenCollective'), ('Reddit', 'Reddit'), ('All', 'All')], default='')), | ||
('initialize', models.TextField(blank=True, default='[]')), | ||
('check', models.TextField(blank=True, default='\\{\\}')), | ||
('notify', models.TextField(blank=True, default='[]')), | ||
('success', models.TextField(blank=True, default='[]')), | ||
('fail', models.TextField(blank=True, default='[]')), | ||
('variables', models.TextField(blank=True, default='[]')), | ||
('data', models.TextField(blank=True, default='[]')), | ||
], | ||
options={ | ||
'unique_together': {('name', 'platform')}, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='PolicyTemplate', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=100)), | ||
('description', models.TextField(blank=True, null=True)), | ||
('kind', models.CharField(choices=[('platform', 'platform'), ('constitution', 'constitution'), ('trigger', 'trigger')], max_length=30)), | ||
('is_trigger', models.BooleanField(default=False)), | ||
('extra_executions', models.TextField(blank=True, default='{}')), | ||
('variables', models.TextField(blank=True, default='[]')), | ||
('data', models.TextField(blank=True, default='[]')), | ||
('action_types', models.ManyToManyField(to='policyengine.ActionType')), | ||
('custom_actions', models.ManyToManyField(to='policyengine.CustomAction')), | ||
('procedure', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='policyengine.procedure')), | ||
('transformers', models.ManyToManyField(to='policyengine.Transformer')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='FilterModule', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('kind', models.TextField(blank=True, default='')), | ||
('name', models.TextField(blank=True, default='')), | ||
('description', models.TextField(blank=True, default='')), | ||
('platform', models.TextField(blank=True, choices=[('Slack', 'Slack'), ('Discord', 'Discord'), ('Discourse', 'Discourse'), ('Github', 'Github'), ('Opencollective', 'OpenCollective'), ('Reddit', 'Reddit'), ('All', 'All')], default='All')), | ||
('variables', models.TextField(blank=True, default='[]')), | ||
('codes', models.TextField(blank=True, default='')), | ||
], | ||
options={ | ||
'unique_together': {('kind', 'name')}, | ||
}, | ||
), | ||
] |
Oops, something went wrong.