bulk request for tickets to buffer group

This commit is contained in:
Iurii Tatishchev 2021-04-20 13:30:15 -07:00
parent 750371e595
commit 045d2cfb2b
Signed by: CaZzzer
GPG Key ID: 926BE949E29DCD03

View File

@ -48,6 +48,8 @@ def make_light_agent(user_profile: UserProfile, who_changes: User) -> None:
:return: Вызов функции **update_role** с параметрами: профиль пользователя, роль "light_agent" :return: Вызов функции **update_role** с параметрами: профиль пользователя, роль "light_agent"
""" """
tickets = get_tickets_list(user_profile.user.email) tickets = get_tickets_list(user_profile.user.email)
tickets_to_update = []
buffer_group = zenpy.get_group(ZENDESK_GROUPS['buffer'])
for ticket in tickets: for ticket in tickets:
UnassignedTicket.objects.create( UnassignedTicket.objects.create(
assignee=user_profile.user, assignee=user_profile.user,
@ -58,8 +60,11 @@ def make_light_agent(user_profile: UserProfile, who_changes: User) -> None:
ticket.assignee = zenpy.get_user(SOLVED_TICKETS_EMAIL) ticket.assignee = zenpy.get_user(SOLVED_TICKETS_EMAIL)
else: else:
ticket.assignee = None ticket.assignee = None
ticket.group = zenpy.get_group(ZENDESK_GROUPS['buffer']) ticket.group = buffer_group
zenpy.admin.tickets.update(ticket) tickets_to_update.append(ticket)
print(tickets_to_update)
zenpy.admin.tickets.update(tickets.values)
update_role(user_profile, ROLES['light_agent']) update_role(user_profile, ROLES['light_agent'])