Exemplo n.º 1
0
def operator_my_opened_ticket(request, structure_slug,
                              structure, office_employee):
    """
    Returns all assigned and not closed tickets taken by operator

    :type structure_slug: String
    :type structure: OrganizationalStructure (from @is_operator)
    :type office_employee: OrganizationalStructureOfficeEmployee (from @is_operator)

    :param structure_slug: operator structure slug
    :param structure: operator structure (from @is_operator)
    :param office_employee: queryset with operator and his offices (from @is_operator)

    :return: JsonResponse
    """
    tickets = visible_tickets_to_user(request.user,
                                      structure,
                                      office_employee)
    ticket_list = Ticket.objects.filter(code__in=tickets,
                                        is_closed=False)
    result_list = copy.deepcopy(ticket_list)
    for ticket in ticket_list:
        if not ticket.has_been_taken(structure=structure,
                                     user=request.user):
            result_list = result_list.exclude(pk=ticket.pk)
    dtd = TicketDTD( request, result_list, _ticket_columns )
    return JsonResponse(dtd.get_dict())
Exemplo n.º 2
0
def dashboard(request, structure_slug, structure, office_employee):
    """
    Operator Dashboard

    :type structure_slug: String
    :type structure: OrganizationalStructure (from @is_operator)
    :type office_employee: OrganizationalStructureOfficeEmployee (from @is_operator)

    :param structure_slug: structure slug
    :param structure: structure object (from @is_operator)
    :param office_employee: employe offices queryset (from @is_operator)

    :return: render
    """
    title = _("Pannello di Controllo")
    sub_title = _("Gestisci le richieste in modalità {}").format(settings.OPERATOR_PREFIX)
    template = "operator/dashboard.html"
    offices = user_offices_list(office_employee)
    user_tickets = visible_tickets_to_user(user=request.user,
                                           structure=structure,
                                           office_employee=office_employee)
    tickets = Ticket.objects.filter(code__in=user_tickets)
    not_closed = tickets.filter(is_closed=False)
    # unassigned = []
    # opened = []
    # my_opened = []
    unassigned = 0
    opened = 0
    my_opened = 0
    for nc in not_closed:
        if nc.has_been_taken():
            # opened.append(nc)
            opened += 1
            if nc.has_been_taken_by_user(structure=structure,
                                         user=request.user):
                # my_opened.append(nc)
                my_opened += 1
        else:
            # unassigned.append(nc)
            unassigned += 1
    # chiusi = tickets.filter(is_closed=True)
    chiusi = tickets.filter(is_closed=True).count()

    messages = TicketReply.get_unread_messages_count(tickets=tickets)

    d = {'offices': offices,
         'structure': structure,
         'sub_title': sub_title,
         'title': title,
         'ticket_aperti': opened,
         'ticket_assegnati_a_me': my_opened,
         'ticket_chiusi': chiusi,
         'ticket_messages': messages,
         'ticket_non_gestiti': unassigned,}
    return render(request, template, d)
Exemplo n.º 3
0
def operator_closed_ticket(request, structure_slug, structure,
                           office_employee):
    """
    Returns all closed tickets managed by operator

    :type structure_slug: String
    :type structure: OrganizationalStructure (from @is_operator)
    :type office_employee: OrganizationalStructureOfficeEmployee (from @is_operator)

    :param structure_slug: operator structure slug
    :param structure: operator structure (from @is_operator)
    :param office_employee: queryset with operator and his offices (from @is_operator)

    :return: JsonResponse
    """
    tickets = visible_tickets_to_user(request.user, structure, office_employee)
    ticket_list = Ticket.objects.filter(code__in=tickets, is_closed=True)
    dtd = TicketDTD(request, ticket_list, _ticket_columns)
    return JsonResponse(dtd.get_dict())
Exemplo n.º 4
0
def dashboard(request, structure_slug, structure, office_employee):
    """
    Operator Dashboard

    :type structure_slug: String
    :type structure: OrganizationalStructure (from @is_operator)
    :type office_employee: OrganizationalStructureOfficeEmployee (from @is_operator)

    :param structure_slug: structure slug
    :param structure: structure object (from @is_operator)
    :param office_employee: employe offices queryset (from @is_operator)

    :return: render
    """
    title = _("Dashboard")
    sub_title = OPERATOR_PREFIX
    template = "operator/dashboard.html"
    offices = user_offices_list(office_employee)
    user_tickets = visible_tickets_to_user(user=request.user,
                                           structure=structure,
                                           office_employee=office_employee)
    tickets = Ticket.objects.filter(pk__in=user_tickets)
    non_gestiti = tickets.filter(is_taken=False,
                                 is_closed=False)
    aperti = tickets.filter(is_taken=True, is_closed=False)
    chiusi = tickets.filter(is_closed=True)

    messages = 0
    for ticket in tickets:
        if not ticket.is_followed_by_one_of_offices(offices):
            continue
        messages += ticket.get_unread_replies()

    d = {'ticket_messages': messages,
         'offices': offices,
         'structure': structure,
         'sub_title': sub_title,
         'title': title,
         'ticket_aperti': aperti,
         'ticket_chiusi': chiusi,
         'ticket_non_gestiti': non_gestiti,}
    return render(request, template, d)