Assign Job Hiring Perms

PHOTO EMBED

Fri Jul 30 2021 11:22:00 GMT+0000 (UTC)

Saved by @phuongtmr #shell #mysql

from ai_jobs.models import Job
from ai_jobs.services import HiringTeamService
from ai_jobs.services.job_management import JobManagementService
from ai_jobs.constants.constants import JobRoleType
for job in jobs:
    try:
        hiring_manage_job_perms = HiringTeamService.get_hiring_manage_job_perms(job)
        hiring_manage_user_job_perms = hiring_manage_job_perms.get(JobRoleType.USER_ID, {})
        hiring_manage_user_job_perms.update({uid: True for uid in user_ids})
        hiring_manage_job_perms.update({JobRoleType.USER_ID: hiring_manage_user_job_perms})
        JobManagementService.update_hiring_team(
            job, users=hiring_manage_user_job_perms.keys(), hiring_manage_job_perms=hiring_manage_job_perms
        )

                             
for job in company_jobs:
    hiring_manage_job_perms = HiringTeamService.get_hiring_manage_job_perms(job)
    hiring_manage_role_job_perms = hiring_manage_job_perms.get(JobRoleType.ROLE_ID, {})
    hiring_manage_role_job_perms.update({uid: True for uid in user_ids})
    hiring_manage_job_perms.update({JobRoleType.ROLE_ID: hiring_manage_role_job_perms})
    JobManagementService.update_hiring_team(
        job, roles=hiring_manage_role_job_perms.keys(), hiring_manage_job_perms=hiring_manage_job_perms
    )
content_copyCOPY