Source code for helpdesk.managers

__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"


from django.db import models

from .constants import (
    TICKET_STATUS_UNASSIGNED,
    TICKET_STATUS_ASSIGNED,
    TICKET_STATUS_PICKEDUP,
    TICKET_STATUS_PASSED_ON,
    TICKET_STATUS_AWAITING_RESPONSE_ASSIGNEE,
    TICKET_STATUS_AWAITING_RESPONSE_USER,
    TICKET_STATUS_RESOLVED,
    TICKET_STATUS_CLOSED,
)


[docs]class QueueQuerySet(models.QuerySet):
[docs] def anchors(self): """Return only Queues which have no parent Queue.""" return self.filter(parent_queue__isnull=True)
[docs]class TicketQuerySet(models.QuerySet):
[docs] def unassigned(self): return self.filter(status=TICKET_STATUS_UNASSIGNED)
[docs] def assigned(self): return self.filter(status=TICKET_STATUS_ASSIGNED)
[docs] def resolved(self): return self.filter(status=TICKET_STATUS_RESOLVED)
[docs] def closed(self): return self.filter(status=TICKET_STATUS_CLOSED)
[docs] def awaiting_handling(self): return self.filter(status__in=[TICKET_STATUS_ASSIGNED, TICKET_STATUS_PASSED_ON])
[docs] def in_handling(self): return self.filter( status__in=[ TICKET_STATUS_PICKEDUP, TICKET_STATUS_AWAITING_RESPONSE_ASSIGNEE, TICKET_STATUS_AWAITING_RESPONSE_USER, ] )
[docs] def assigned_to_others(self, user): return self.exclude(assigned_to=user)
[docs] def handled(self): return self.filter(status__in=[TICKET_STATUS_RESOLVED, TICKET_STATUS_CLOSED])