2008-08-19 10:50:38 +02:00
|
|
|
"""
|
2011-01-26 00:08:41 +01:00
|
|
|
django-helpdesk - A Django powered ticket tracker for small enterprise.
|
2008-08-19 10:50:38 +02:00
|
|
|
|
|
|
|
(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details.
|
|
|
|
|
|
|
|
views/feeds.py - A handful of staff-only RSS feeds to provide ticket details
|
|
|
|
to feed readers or similar software.
|
|
|
|
"""
|
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
from django.contrib.auth import get_user_model
|
2012-04-25 09:55:38 +02:00
|
|
|
from django.contrib.syndication.views import Feed
|
2017-12-28 15:11:34 +01:00
|
|
|
from django.urls import reverse
|
2008-02-08 06:29:51 +01:00
|
|
|
from django.db.models import Q
|
2022-03-17 03:29:09 +01:00
|
|
|
from django.utils.translation import gettext as _
|
2012-04-25 09:55:38 +02:00
|
|
|
from django.shortcuts import get_object_or_404
|
2008-02-08 06:29:51 +01:00
|
|
|
|
2008-05-21 23:16:44 +02:00
|
|
|
from helpdesk.models import Ticket, FollowUp, Queue
|
2008-02-08 06:29:51 +01:00
|
|
|
|
2016-10-21 17:14:12 +02:00
|
|
|
User = get_user_model()
|
|
|
|
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
class OpenTicketsByUser(Feed):
|
|
|
|
title_template = 'helpdesk/rss/ticket_title.html'
|
|
|
|
description_template = 'helpdesk/rss/ticket_description.html'
|
|
|
|
|
2012-04-25 09:55:38 +02:00
|
|
|
def get_object(self, request, user_name, queue_slug=None):
|
|
|
|
user = get_object_or_404(User, username=user_name)
|
|
|
|
if queue_slug:
|
|
|
|
queue = get_object_or_404(Queue, slug=queue_slug)
|
|
|
|
else:
|
|
|
|
queue = None
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
return {'user': user, 'queue': queue}
|
|
|
|
|
|
|
|
def title(self, obj):
|
|
|
|
if obj['queue']:
|
2008-08-19 10:50:38 +02:00
|
|
|
return _("Helpdesk: Open Tickets in queue %(queue)s for %(username)s") % {
|
|
|
|
'queue': obj['queue'].title,
|
2014-10-22 07:18:04 +02:00
|
|
|
'username': obj['user'].get_username(),
|
2016-10-23 22:02:02 +02:00
|
|
|
}
|
2008-02-08 06:29:51 +01:00
|
|
|
else:
|
2008-08-19 10:50:38 +02:00
|
|
|
return _("Helpdesk: Open Tickets for %(username)s") % {
|
2014-10-22 07:18:04 +02:00
|
|
|
'username': obj['user'].get_username(),
|
2016-10-23 22:02:02 +02:00
|
|
|
}
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def description(self, obj):
|
|
|
|
if obj['queue']:
|
2008-08-19 10:50:38 +02:00
|
|
|
return _("Open and Reopened Tickets in queue %(queue)s for %(username)s") % {
|
|
|
|
'queue': obj['queue'].title,
|
2014-10-22 07:18:04 +02:00
|
|
|
'username': obj['user'].get_username(),
|
2016-10-23 22:02:02 +02:00
|
|
|
}
|
2008-02-08 06:29:51 +01:00
|
|
|
else:
|
2008-08-19 10:50:38 +02:00
|
|
|
return _("Open and Reopened Tickets for %(username)s") % {
|
2014-10-22 07:18:04 +02:00
|
|
|
'username': obj['user'].get_username(),
|
2016-10-23 22:02:02 +02:00
|
|
|
}
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def link(self, obj):
|
|
|
|
if obj['queue']:
|
2008-08-19 10:50:38 +02:00
|
|
|
return u'%s?assigned_to=%s&queue=%s' % (
|
2015-12-22 10:10:00 +01:00
|
|
|
reverse('helpdesk:list'),
|
2008-08-19 10:50:38 +02:00
|
|
|
obj['user'].id,
|
|
|
|
obj['queue'].id,
|
2016-10-23 22:02:02 +02:00
|
|
|
)
|
2008-02-08 06:29:51 +01:00
|
|
|
else:
|
2008-08-19 10:50:38 +02:00
|
|
|
return u'%s?assigned_to=%s' % (
|
2015-12-22 10:10:00 +01:00
|
|
|
reverse('helpdesk:list'),
|
2008-08-19 10:50:38 +02:00
|
|
|
obj['user'].id,
|
2016-10-23 22:02:02 +02:00
|
|
|
)
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def items(self, obj):
|
|
|
|
if obj['queue']:
|
2008-08-19 10:50:38 +02:00
|
|
|
return Ticket.objects.filter(
|
2016-10-23 22:02:02 +02:00
|
|
|
assigned_to=obj['user']
|
|
|
|
).filter(
|
|
|
|
queue=obj['queue']
|
|
|
|
).filter(
|
|
|
|
Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)
|
|
|
|
)
|
2008-02-08 06:29:51 +01:00
|
|
|
else:
|
2008-08-19 10:50:38 +02:00
|
|
|
return Ticket.objects.filter(
|
2016-10-23 22:02:02 +02:00
|
|
|
assigned_to=obj['user']
|
|
|
|
).filter(
|
|
|
|
Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)
|
|
|
|
)
|
2008-08-19 10:50:38 +02:00
|
|
|
|
2008-02-08 06:29:51 +01:00
|
|
|
def item_pubdate(self, item):
|
|
|
|
return item.created
|
|
|
|
|
|
|
|
def item_author_name(self, item):
|
|
|
|
if item.assigned_to:
|
2014-10-22 07:18:04 +02:00
|
|
|
return item.assigned_to.get_username()
|
2008-02-08 06:29:51 +01:00
|
|
|
else:
|
2008-05-07 11:04:18 +02:00
|
|
|
return _('Unassigned')
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
class UnassignedTickets(Feed):
|
|
|
|
title_template = 'helpdesk/rss/ticket_title.html'
|
|
|
|
description_template = 'helpdesk/rss/ticket_description.html'
|
2008-08-19 10:50:38 +02:00
|
|
|
|
2008-05-07 11:04:18 +02:00
|
|
|
title = _('Helpdesk: Unassigned Tickets')
|
|
|
|
description = _('Unassigned Open and Reopened tickets')
|
2016-10-24 08:04:31 +02:00
|
|
|
link = '' # '%s?assigned_to=' % reverse('helpdesk:list')
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def items(self, obj):
|
2008-08-19 10:50:38 +02:00
|
|
|
return Ticket.objects.filter(
|
2016-10-23 22:02:02 +02:00
|
|
|
assigned_to__isnull=True
|
|
|
|
).filter(
|
|
|
|
Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)
|
|
|
|
)
|
2008-08-19 10:50:38 +02:00
|
|
|
|
2008-02-08 06:29:51 +01:00
|
|
|
def item_pubdate(self, item):
|
|
|
|
return item.created
|
2008-08-19 10:50:38 +02:00
|
|
|
|
2008-02-08 06:29:51 +01:00
|
|
|
def item_author_name(self, item):
|
|
|
|
if item.assigned_to:
|
2014-10-22 07:18:04 +02:00
|
|
|
return item.assigned_to.get_username()
|
2008-02-08 06:29:51 +01:00
|
|
|
else:
|
2008-05-07 11:04:18 +02:00
|
|
|
return _('Unassigned')
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
class RecentFollowUps(Feed):
|
|
|
|
title_template = 'helpdesk/rss/recent_activity_title.html'
|
|
|
|
description_template = 'helpdesk/rss/recent_activity_description.html'
|
|
|
|
|
2008-05-07 11:04:18 +02:00
|
|
|
title = _('Helpdesk: Recent Followups')
|
|
|
|
description = _('Recent FollowUps, such as e-mail replies, comments, attachments and resolutions')
|
2016-10-24 08:04:31 +02:00
|
|
|
link = '/tickets/' # reverse('helpdesk:list')
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def items(self):
|
|
|
|
return FollowUp.objects.order_by('-date')[:20]
|
|
|
|
|
|
|
|
|
|
|
|
class OpenTicketsByQueue(Feed):
|
|
|
|
title_template = 'helpdesk/rss/ticket_title.html'
|
|
|
|
description_template = 'helpdesk/rss/ticket_description.html'
|
|
|
|
|
2012-04-25 09:55:38 +02:00
|
|
|
def get_object(self, request, queue_slug):
|
|
|
|
return get_object_or_404(Queue, slug=queue_slug)
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def title(self, obj):
|
2008-08-19 10:50:38 +02:00
|
|
|
return _('Helpdesk: Open Tickets in queue %(queue)s') % {
|
|
|
|
'queue': obj.title,
|
2016-10-23 22:02:02 +02:00
|
|
|
}
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def description(self, obj):
|
2008-08-19 10:50:38 +02:00
|
|
|
return _('Open and Reopened Tickets in queue %(queue)s') % {
|
|
|
|
'queue': obj.title,
|
2016-10-23 22:02:02 +02:00
|
|
|
}
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def link(self, obj):
|
2008-08-19 10:50:38 +02:00
|
|
|
return '%s?queue=%s' % (
|
2015-12-22 10:10:00 +01:00
|
|
|
reverse('helpdesk:list'),
|
2008-08-19 10:50:38 +02:00
|
|
|
obj.id,
|
2016-10-23 22:02:02 +02:00
|
|
|
)
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def items(self, obj):
|
2008-08-19 10:50:38 +02:00
|
|
|
return Ticket.objects.filter(
|
2016-10-23 22:02:02 +02:00
|
|
|
queue=obj
|
|
|
|
).filter(
|
|
|
|
Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS)
|
|
|
|
)
|
2008-02-08 06:29:51 +01:00
|
|
|
|
|
|
|
def item_pubdate(self, item):
|
|
|
|
return item.created
|
2008-08-19 10:50:38 +02:00
|
|
|
|
2008-02-08 06:29:51 +01:00
|
|
|
def item_author_name(self, item):
|
|
|
|
if item.assigned_to:
|
2014-10-22 07:18:04 +02:00
|
|
|
return item.assigned_to.get_username()
|
2008-02-08 06:29:51 +01:00
|
|
|
else:
|
2008-05-07 11:04:18 +02:00
|
|
|
return _('Unassigned')
|