diff --git a/apps/assets/tasks/push_account.py b/apps/assets/tasks/push_account.py index c2c7156e8..7c596c8f2 100644 --- a/apps/assets/tasks/push_account.py +++ b/apps/assets/tasks/push_account.py @@ -12,11 +12,14 @@ __all__ = [ @org_aware_func("assets") -def push_accounts_to_assets_util(accounts, assets): +def push_accounts_to_assets_util(accounts, assets, username=None): from assets.models import PushAccountAutomation task_name = gettext_noop("Push accounts to assets") task_name = PushAccountAutomation.generate_unique_name(task_name) - account_usernames = list(accounts.values_list('username', flat=True)) + if username is None: + account_usernames = list(accounts.values_list('username', flat=True)) + else: + account_usernames = [username] data = { 'name': task_name, @@ -29,10 +32,10 @@ def push_accounts_to_assets_util(accounts, assets): @shared_task(queue="ansible", verbose_name=_('Push accounts to assets')) -def push_accounts_to_assets(account_ids, asset_ids): +def push_accounts_to_assets(account_ids, asset_ids, username=None): from assets.models import Asset, Account with tmp_to_root_org(): assets = Asset.objects.filter(id__in=asset_ids) accounts = Account.objects.filter(id__in=account_ids) - return push_accounts_to_assets_util(accounts, assets) + return push_accounts_to_assets_util(accounts, assets, username)