mirror of https://github.com/jumpserver/jumpserver
perf: tickets notifications add default data migrate file (#13268)
Co-authored-by: feng <1304903146@qq.com>pull/13269/head
parent
714b4ef7f4
commit
82977f9023
|
@ -0,0 +1,22 @@
|
||||||
|
# Generated by Django 4.1.13 on 2024-05-21 11:04
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def init_user_msg_subscription(apps, schema_editor):
|
||||||
|
User = apps.get_model('users', 'User')
|
||||||
|
UserMsgSubscription = apps.get_model('notifications', 'UserMsgSubscription')
|
||||||
|
|
||||||
|
receive_backends = ['site_msg', 'email']
|
||||||
|
user = User.objects.get(username='admin')
|
||||||
|
UserMsgSubscription.objects.create(user=user, receive_backends=receive_backends)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
('notifications', '0002_auto_20210909_1946'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(init_user_msg_subscription),
|
||||||
|
]
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Generated by Django 4.1.13 on 2024-05-21 09:14
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def create_ticket_flow_and_approval_rule(apps, schema_editor):
|
||||||
|
org_id = '00000000-0000-0000-0000-000000000000'
|
||||||
|
|
||||||
|
User = apps.get_model("users", "User")
|
||||||
|
TicketFlow = apps.get_model("tickets", "TicketFlow")
|
||||||
|
ApprovalRule = apps.get_model("tickets", "ApprovalRule")
|
||||||
|
|
||||||
|
super_user = User.objects.get(username='admin')
|
||||||
|
flow = TicketFlow.objects.create(created_by='System', type='apply_asset', org_id=org_id)
|
||||||
|
rule_instance = ApprovalRule.objects.create(strategy='super_admin')
|
||||||
|
rule_instance.assignees.set([super_user])
|
||||||
|
flow.rules.set([rule_instance, ])
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
('tickets', '0002_auto_20200728_1146'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(create_ticket_flow_and_approval_rule),
|
||||||
|
]
|
Loading…
Reference in New Issue