Fix make_light_agent method while tickets.count is 0.

This commit is contained in:
Andrew Smirnov 2021-04-29 19:52:03 +03:00
parent 96e5865d3b
commit 73e9c9fd34
No known key found for this signature in database
GPG Key ID: 0EFE318E5BB2A82A
2 changed files with 4 additions and 4 deletions

View File

@ -9,6 +9,7 @@ from django.utils import timezone
from zenpy import Zenpy
from zenpy.lib.exception import APIException
from zenpy.lib.api_objects import User as ZenpyUser, Ticket as ZenpyTicket
from zenpy.lib.generator import SearchResultGenerator
from access_controller.settings import ZENDESK_ROLES as ROLES, ONE_DAY, ACTRL_ZENDESK_SUBDOMAIN
from main.models import UserProfile, RoleChangeLogs, UnassignedTicket, UnassignedTicketStatus
@ -48,7 +49,7 @@ def make_light_agent(user_profile: UserProfile, who_changes: User) -> None:
:param user_profile: Профиль пользователя
:return: Вызов функции **update_role** с параметрами: профиль пользователя, роль "light_agent"
"""
tickets = get_tickets_list(user_profile.user.email)
tickets: SearchResultGenerator = get_tickets_list(user_profile.user.email)
ticket: ZenpyTicket
for ticket in tickets:
UnassignedTicket.objects.create(
@ -62,7 +63,8 @@ def make_light_agent(user_profile: UserProfile, who_changes: User) -> None:
ticket.assignee = None
ticket.group_id = zenpy.buffer_group_id
zenpy.admin.tickets.update(tickets.values)
if tickets.count:
zenpy.admin.tickets.update(tickets.values)
attempts, success = 5, False
while not success and attempts != 0:

View File

@ -1,6 +1,4 @@
"use strict";
import React from "react";
import ReactDOM from "react-dom";
function head_checkbox() {
let head_checkbox = document.getElementById("head-checkbox");