Allow Tickets status choices customization

This commit is contained in:
Sam Splunks 2024-02-01 15:38:02 +01:00 committed by GitHub
parent 147151a271
commit ab2c2f79a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 49 additions and 31 deletions

View File

@ -186,10 +186,10 @@ class EditFollowUpForm(forms.ModelForm):
exclude = ('date', 'user',)
def __init__(self, *args, **kwargs):
"""Filter not openned tickets here."""
"""Filter not opened tickets here."""
super(EditFollowUpForm, self).__init__(*args, **kwargs)
self.fields["ticket"].queryset = Ticket.objects.filter(
status__in=(Ticket.OPEN_STATUS, Ticket.REOPENED_STATUS))
status__in=Ticket.OPEN_STATUSES)
class AbstractTicketForm(CustomFieldMixin, forms.Form):

View File

@ -83,9 +83,12 @@ def escalate_tickets(queues, verbose):
if verbose:
print("Processing: %s" % q)
Q_OPEN_STATUSES = Q()
for open_status in Ticket.OPEN_STATUSES:
q_open_statuses |= Q(status=open_status)
for t in q.ticket_set.filter(
Q(status=Ticket.OPEN_STATUS) |
Q(status=Ticket.REOPENED_STATUS)
Q_OPEN_STATUSES
).exclude(
priority=1
).filter(

View File

@ -463,19 +463,14 @@ class Ticket(models.Model):
the dashboard to prompt users to take ownership of them.
"""
OPEN_STATUS = 1
REOPENED_STATUS = 2
RESOLVED_STATUS = 3
CLOSED_STATUS = 4
DUPLICATE_STATUS = 5
OPEN_STATUS = helpdesk_settings.OPEN_STATUS
REOPENED_STATUS = helpdesk_settings.REOPENED_STATUS
RESOLVED_STATUS = helpdesk_settings.RESOLVED_STATUS
CLOSED_STATUS = helpdesk_settings.CLOSED_STATUS
DUPLICATE_STATUS = helpdesk_settings.DUPLICATE_STATUS
STATUS_CHOICES = (
(OPEN_STATUS, _('Open')),
(REOPENED_STATUS, _('Reopened')),
(RESOLVED_STATUS, _('Resolved')),
(CLOSED_STATUS, _('Closed')),
(DUPLICATE_STATUS, _('Duplicate')),
)
STATUS_CHOICES = helpdesk_settings.TICKET_STATUS_CHOICES
OPEN_STATUSES = helpdesk_settings.TICKET_OPEN_STATUSES
PRIORITY_CHOICES = helpdesk_settings.TICKET_PRIORITY_CHOICES
@ -771,9 +766,8 @@ class Ticket(models.Model):
True = any dependencies are resolved
False = There are non-resolved dependencies
"""
OPEN_STATUSES = (Ticket.OPEN_STATUS, Ticket.REOPENED_STATUS)
return TicketDependency.objects.filter(ticket=self).filter(
depends_on__status__in=OPEN_STATUSES).count() == 0
depends_on__status__in=Ticket.OPEN_STATUSES).count() == 0
can_be_resolved = property(_can_be_resolved)
def get_submitter_userprofile(self):

View File

@ -103,6 +103,29 @@ ALLOWED_URL_SCHEMES = getattr(settings, 'ALLOWED_URL_SCHEMES', (
'file', 'ftp', 'ftps', 'http', 'https', 'irc', 'mailto', 'sftp', 'ssh', 'tel', 'telnet', 'tftp', 'vnc', 'xmpp',
))
# Ticket status choices
OPEN_STATUS = getattr(settings, 'HELPDESK_TICKET_OPEN_STATUS', 1)
REOPENED_STATUS = getattr(settings, 'HELPDESK_TICKET_REOPENED_STATUS', 2)
RESOLVED_STATUS = getattr(settings, 'HELPDESK_TICKET_RESOLVED_STATUS', 3)
CLOSED_STATUS = getattr(settings, 'HELPDESK_TICKET_CLOSED_STATUS', 4)
DUPLICATE_STATUS = getattr(settings, 'HELPDESK_TICKET_DUPLICATE_STATUS', 5)
DEFAULT_TICKET_STATUS_CHOICES = (
(OPEN_STATUS, _('Open')),
(REOPENED_STATUS, _('Reopened')),
(RESOLVED_STATUS, _('Resolved')),
(CLOSED_STATUS, _('Closed')),
(DUPLICATE_STATUS, _('Duplicate')),
)
TICKET_STATUS_CHOICES = getattr(settings,
'HELPDESK_TICKET_STATUS_CHOICES',
DEFAULT_TICKET_STATUS_CHOICES)
DEFAULT_TICKET_OPEN_STATUSES = (OPEN_STATUS, REOPENED_STATUS)
TICKET_OPEN_STATUSES = getattr(settings,
'HELPDESK_TICKET_OPEN_STATUSES',
DEFAULT_TICKET_OPEN_STATUSES)
# Ticket priority choices
DEFAULT_TICKET_PRIORITY_CHOICES = (
(1, _('1. Critical')),
@ -112,8 +135,8 @@ DEFAULT_TICKET_PRIORITY_CHOICES = (
(5, _('5. Very Low')),
)
TICKET_PRIORITY_CHOICES = getattr(settings,
'HELPDESK_TICKET_PRIORITY_CHOICES',
DEFAULT_TICKET_PRIORITY_CHOICES)
'HELPDESK_TICKET_PRIORITY_CHOICES',
DEFAULT_TICKET_PRIORITY_CHOICES)
############################
# options for public pages #

View File

@ -19,6 +19,11 @@ from helpdesk.models import FollowUp, Queue, Ticket
User = get_user_model()
Q_OPEN_STATUSES = Q()
for open_status in Ticket.OPEN_STATUSES:
q_open_statuses |= Q(status=open_status)
class OpenTicketsByUser(Feed):
title_template = 'helpdesk/rss/ticket_title.html'
description_template = 'helpdesk/rss/ticket_description.html'
@ -73,15 +78,12 @@ class OpenTicketsByUser(Feed):
assigned_to=obj['user']
).filter(
queue=obj['queue']
).filter(
Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)
).filter(Q_OPEN_STATUSES)
)
else:
return Ticket.objects.filter(
assigned_to=obj['user']
).filter(
Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)
)
).filter(Q_OPEN_STATUSES)
def item_pubdate(self, item):
return item.created
@ -104,9 +106,7 @@ class UnassignedTickets(Feed):
def items(self, obj):
return Ticket.objects.filter(
assigned_to__isnull=True
).filter(
Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)
)
).filter(Q_OPEN_STATUSES)
def item_pubdate(self, item):
return item.created
@ -157,9 +157,7 @@ class OpenTicketsByQueue(Feed):
def items(self, obj):
return Ticket.objects.filter(
queue=obj
).filter(
Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)
)
).filter(Q_OPEN_STATUSES)
def item_pubdate(self, item):
return item.created