Browse Source

Merge pull request #9710 from jumpserver/pr@dev@fix_task_activity_error

fix: 创建用户和验证账号任务的Activity日志保存失败
pull/9721/head
老广 2 years ago committed by GitHub
parent
commit
4a36e54030
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/accounts/tasks/verify_account.py
  2. 4
      apps/audits/signal_handlers/activity_log.py
  3. 4
      apps/common/tasks.py

2
apps/accounts/tasks/verify_account.py

@ -47,7 +47,7 @@ def verify_accounts_connectivity_util(accounts, task_name):
@shared_task(
queue="ansible", verbose_name=_('Verify asset account availability'),
activity_callback=lambda self, account_ids, asset_ids: (account_ids, None)
activity_callback=lambda self, account_ids, *args, **kwargs: (account_ids, None)
)
def verify_accounts_connectivity_task(account_ids):
from accounts.models import Account, VerifyAccountAutomation

4
apps/audits/signal_handlers/activity_log.py

@ -57,8 +57,8 @@ class ActivityLogHandler:
resource_ids, org_id, user = data + ('',) * (3 - len(data))
if not user:
user = str(current_request.user) if current_request else 'System'
if org_id is None:
org_id = current_org.org_id
if not org_id:
org_id = current_org.id
task_display = getattr(task, 'verbose_name', _('Unknown'))
detail = i18n_fmt(
gettext_noop('User %s perform a task for this resource: %s'),

4
apps/common/tasks.py

@ -10,11 +10,11 @@ from .utils import get_logger
logger = get_logger(__file__)
def task_activity_callback(self, subject, message, from_email, recipient_list, **kwargs):
def task_activity_callback(self, subject, message, recipient_list, **kwargs):
from users.models import User
email_list = recipient_list
resource_ids = list(User.objects.filter(email__in=email_list).values_list('id', flat=True))
return resource_ids
return resource_ids,
@shared_task(verbose_name=_("Send email"), activity_callback=task_activity_callback)

Loading…
Cancel
Save