mirror of https://github.com/jumpserver/jumpserver
perf: remove notification migrations
parent
c56ab9bc1e
commit
75fa96b29c
|
@ -1551,7 +1551,7 @@ msgstr "未知"
|
||||||
|
|
||||||
#: assets/const/automation.py:7
|
#: assets/const/automation.py:7
|
||||||
msgid "OK"
|
msgid "OK"
|
||||||
msgstr ""
|
msgstr "成功"
|
||||||
|
|
||||||
#: assets/const/automation.py:12
|
#: assets/const/automation.py:12
|
||||||
msgid "Ping"
|
msgid "Ping"
|
||||||
|
|
|
@ -6,6 +6,20 @@ from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
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.filter(username='admin').first()
|
||||||
|
if not user:
|
||||||
|
return
|
||||||
|
UserMsgSubscription.objects.update_or_create(
|
||||||
|
defaults={'receive_backends': receive_backends}, user=user
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
initial = True
|
initial = True
|
||||||
|
@ -57,4 +71,5 @@ class Migration(migrations.Migration):
|
||||||
name='users',
|
name='users',
|
||||||
field=models.ManyToManyField(related_name='recv_site_messages', through='notifications.SiteMessage', to=settings.AUTH_USER_MODEL),
|
field=models.ManyToManyField(related_name='recv_site_messages', through='notifications.SiteMessage', to=settings.AUTH_USER_MODEL),
|
||||||
),
|
),
|
||||||
|
migrations.RunPython(init_user_msg_subscription)
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
# 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.update_or_create(
|
|
||||||
defaults={'receive_backends': receive_backends}, user=user
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
('notifications', '0002_auto_20210909_1946'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RunPython(init_user_msg_subscription),
|
|
||||||
]
|
|
Loading…
Reference in New Issue