Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 更新celery #1046

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions arkid/core/tasks/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,27 @@
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')

app.user_options['worker'].add(Option(('--is-init-permission',), is_flag=False, help='init permission option.'))
# app.user_options['worker'].add(Option(('--is-init-permission',), is_flag=False, help='init permission option.'))

class MyBootstep(bootsteps.Step):

def __init__(self, parent, is_init_permission=False, **options):
def __init__(self, parent, **options):
super().__init__(parent, **options)
if is_init_permission:
from arkid.core.tasks.tasks import update_system_permission
update_system_permission.delay()
# 预置
from arkid.core import preset_approve_action
from arkid.core.tasks.tasks import init_core_code
init_core_code.delay()

class BindTenantBootstep(bootsteps.Step):
# class BindTenantBootstep(bootsteps.Step):

def __init__(self, parent, **options):
super().__init__(parent, **options)
from django.conf import settings
if not settings.IS_CENTRAL_ARKID:
from arkid.core.tasks.tasks import bind_arkid_saas_all_tenants
bind_arkid_saas_all_tenants.delay()
# def __init__(self, parent, **options):
# super().__init__(parent, **options)
# from django.conf import settings
# if not settings.IS_CENTRAL_ARKID:
# from arkid.core.tasks.tasks import bind_arkid_saas_all_tenants
# bind_arkid_saas_all_tenants.delay()
# pass

app.steps['worker'].add(MyBootstep)
app.steps['worker'].add(BindTenantBootstep)
# app.steps['worker'].add(BindTenantBootstep)

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
Expand Down
26 changes: 26 additions & 0 deletions arkid/core/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,32 @@ def update_system_permission():
permissiondata.update_system_permission()


@app.task
def init_core_code():
# 初始化租户和用户信息
from arkid.core.models import Tenant, User
tenant, _ = Tenant.objects.get_or_create(
slug='',
name="平台租户",
)
user, _ = User.objects.get_or_create(
username="admin",
tenant=tenant,
)
tenant.create_tenant_user_admin_permission(user)
tenant.users.add(user)
tenant.save()
# 初始化基础审批
from arkid.core import preset_approve_action
# 初始化系统权限
update_system_permission()
# 初始化saas
from django.conf import settings
if not settings.IS_CENTRAL_ARKID:
bind_arkid_saas_all_tenants()



@app.task
def update_open_system_permission_admin():
'''
Expand Down