fix: 公告按页、身份标签权限与菜单种子
This commit is contained in:
27
config/migrations/0009_gonggao_copy_pages.py
Normal file
27
config/migrations/0009_gonggao_copy_pages.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def copy_gonggao_to_other_pages(apps, schema_editor):
|
||||
"""将 order_pool 公告复制到 accept_order / merchant_home(仅当目标页尚无记录)。"""
|
||||
Gonggao = apps.get_model('config', 'Gonggao')
|
||||
for pk in ('accept_order', 'merchant_home'):
|
||||
for row in Gonggao.objects.filter(page_key='order_pool'):
|
||||
if Gonggao.objects.filter(club_id=row.club_id, page_key=pk).exists():
|
||||
continue
|
||||
Gonggao.objects.create(
|
||||
club_id=row.club_id,
|
||||
page_key=pk,
|
||||
NoticeType=row.NoticeType,
|
||||
Content=row.Content or '',
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('config', '0008_gonggao_page_key'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(copy_gonggao_to_other_pages, migrations.RunPython.noop),
|
||||
]
|
||||
Reference in New Issue
Block a user