* Added RSS Feed Functionality

* RSS Feed Index (/rss/)
   * Open tasks by User
   * Open tasks by User / Queue
   * Open tasks by Queue
   * All activity (based on FollowUps for now)
This commit is contained in:
Ross Poulton 2008-02-08 05:29:51 +00:00
parent d6196e540d
commit 47afa9b45b
11 changed files with 189 additions and 1 deletions

128
feeds.py Normal file
View File

@ -0,0 +1,128 @@
from django.contrib.auth.models import User
from django.contrib.syndication.feeds import Feed
from django.core.urlresolvers import reverse
from django.db.models import Q
from models import Ticket, FollowUp, Queue
class OpenTicketsByUser(Feed):
title_template = 'helpdesk/rss/ticket_title.html'
description_template = 'helpdesk/rss/ticket_description.html'
def get_object(self, bits):
if len(bits) < 1:
raise ObjectDoesNotExist
user = User.objects.get(username__exact=bits[0])
if len(bits) == 2:
queue = Queue.objects.get(slug__exact=bits[1])
else: queue = False
return {'user': user, 'queue': queue}
def title(self, obj):
if obj['queue']:
return "Helpdesk: Open Tickets in queue %s for %s" % (obj['queue'].title, obj['user'].username)
else:
return "Helpdesk: Open Tickets for %s" % obj['user'].username
def description(self, obj):
if obj['queue']:
return "Open and Reopened Tickets in queue %s for %s" % (obj['queue'].title, obj['user'].username)
else:
return "Open and Reopened Tickets for %s" % obj['user'].username
def link(self, obj):
if obj['queue']:
return '%s?assigned_to=%s&queue=%s' % (reverse('helpdesk_list'), obj['user'].id, obj['queue'].id)
else:
return '%s?assigned_to=%s' % (reverse('helpdesk_list'), obj['user'].id)
def items(self, obj):
if obj['queue']:
return Ticket.objects.filter(assigned_to=obj['user']).filter(queue=obj['queue']).filter(Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS))
else:
return Ticket.objects.filter(assigned_to=obj['user']).filter(Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS))
def item_pubdate(self, item):
return item.created
def item_author_name(self, item):
if item.assigned_to:
return item.assigned_to.username
else:
return "Unassigned"
class UnassignedTickets(Feed):
title_template = 'helpdesk/rss/ticket_title.html'
description_template = 'helpdesk/rss/ticket_description.html'
title = "Helpdesk: Unassigned Tickets"
description = "Unassigned Open and Reopened tickets"
link = ''#%s?assigned_to=' % reverse('helpdesk_list')
def items(self, obj):
return Ticket.objects.filter(assigned_to__isnull=True).filter(Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS))
def item_pubdate(self, item):
return item.created
def item_author_name(self, item):
if item.assigned_to:
return item.assigned_to.username
else:
return "Unassigned"
class RecentFollowUps(Feed):
title_template = 'helpdesk/rss/recent_activity_title.html'
description_template = 'helpdesk/rss/recent_activity_description.html'
title = "Helpdesk: Recent Followups"
description = "Recent FollowUps, such as e-mail replies, comments, attachments and resolutions"
link = '/tickets/' # reverse('helpdesk_list')
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'
def get_object(self, bits):
if len(bits) != 1:
raise ObjectDoesNotExist
return Queue.objects.get(slug__exact=bits[0])
def title(self, obj):
return "Helpdesk: Open Tickets in queue %s" % obj.title
def description(self, obj):
return "Open and Reopened Tickets in queue %s" % obj.title
def link(self, obj):
return '%s?queue=%s' % (reverse('helpdesk_list'), obj.id)
def items(self, obj):
return Ticket.objects.filter(queue=obj).filter(Q(status=Ticket.OPEN_STATUS) | Q(status=Ticket.REOPENED_STATUS))
def item_pubdate(self, item):
return item.created
def item_author_name(self, item):
if item.assigned_to:
return item.assigned_to.username
else:
return "Unassigned"
feed_setup = {
'user': OpenTicketsByUser,
'queue': OpenTicketsByQueue,
'recent_activity': RecentFollowUps,
'unassigned': UnassignedTickets,
}

BIN
htdocs/rss_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -232,6 +232,9 @@ class FollowUp(models.Model):
def __unicode__(self):
return u'%s' % self.title
def get_absolute_url(self):
return "%s#followup%s" % (self.ticket.get_absolute_url(), self.id)
def save(self):
t = self.ticket

View File

@ -21,7 +21,7 @@
{% block helpdesk_body %}{% endblock %}
</div>
<div id='footer'>
<p>Powered by <a href='http://www.jutda.com.au/'>Jutda HelpDesk</a></p>
<p>Powered by <a href='http://www.jutda.com.au/'>Jutda HelpDesk</a>. <a href='{% url helpdesk_rss_index %}'><img src='{{ MEDIA_URL }}/helpdesk/rss_icon.png' width='14' height='14' alt='RSS Icon' title='RSS Feeds' border='0' />RSS Feeds</a></p>
</div>
</div>{% include "helpdesk/debug.html" %}
</body>

View File

@ -0,0 +1 @@
{{ obj.comment }}

View File

@ -0,0 +1 @@
{{ obj.title }} by {{ obj.user }} (on {{ obj.ticket.ticket }} {{ obj.ticket.title }}, {{ obj.date }})

View File

@ -0,0 +1 @@
{{ obj.description }}{% if obj.submitter_email %} (Submitted by {{ obj.submitter_email }}){% endif %}

View File

@ -0,0 +1 @@
{{ obj.ticket }} {{ obj.title }} ({{ obj.created }})

View File

@ -0,0 +1,31 @@
{% extends "helpdesk/base.html" %}
{% block helpdesk_title %}RSS Feeds{% endblock %}
{% block helpdesk_body %}
<h2>RSS Feeds</h2>
<p>The following RSS feeds are available for you to monitor using your preferred RSS software. With the exception of the 'Latest Activity' feed, all feeds provide information only on Open and Reopened cases. This ensures your RSS reader isn't full of information about closed or historical tasks.</p>
<dl>
<dt><a href='{% url helpdesk_rss "user" %}{{ user.username }}/'><img src='{{ MEDIA_URL }}/helpdesk/rss_icon.png' width='14' height='14' alt='RSS Icon' title='My Open Tickets' border='0' />My Open Tickets</a></dt>
<dd>A summary of your open tickets - useful for getting alerted to new tickets opened for you</dd>
<dt><a href='{% url helpdesk_rss "recent_activity" %}'><img src='{{ MEDIA_URL }}/helpdesk/rss_icon.png' width='14' height='14' alt='RSS Icon' title='Latest Activity' border='0' />Latest Activity</a></dt>
<dd>A summary of all helpdesk activity - including comments, emails, attachments, and more</dd>
<dt><a href='{% url helpdesk_rss "unassigned" %}'><img src='{{ MEDIA_URL }}/helpdesk/rss_icon.png' width='14' height='14' alt='RSS Icon' title='Unassigned Tickets' border='0' />Unassigned Tickets</a></dt>
<dd>All unassigned tickets - useful for being alerted to new tickets opened by the public via the web or via e-mail</dd>
</dl>
<p>These RSS feeds allow you to view a summary of either your own tickets, or all tickets, for each of the queues in your helpdesk. For example, if you manage the staff who utilise a particular queue, this may be used to view new tickets coming into that queue.</p>
<table width='50%'>
<tr class='row_tablehead'><td colspan='4'>Per-Queue Feeds</td></tr>
<tr class='row_columnheads'><th>Queue</th><th align='center'>All Open Tickets</th><th align='center'>My Open Tickets</th></tr>
{% for queue in queues %}
<tr>
<td>{{ queue.title }}</td>
<td align='center'><a href='{% url helpdesk_rss "queue" %}{{ queue.slug }}/'><img src='{{ MEDIA_URL }}/helpdesk/rss_icon.png' width='14' height='14' alt='RSS Icon' title='Open Tickets' border='0' /></a></td>
<td align='center'><a href='{% url helpdesk_rss "user" %}{{ user.username }}/{{ queue.slug }}/'><img src='{{ MEDIA_URL }}/helpdesk/rss_icon.png' width='14' height='14' alt='RSS Icon' title='My Open Tickets' border='0' /></a></td>
{% endfor %}
</table>
{% endblock %}

16
urls.py
View File

@ -9,6 +9,12 @@ urls.py - Mapping of URL's to our various views. Note we always used NAMED
from django.conf.urls.defaults import *
from django.contrib.auth.decorators import login_required
from feeds import feed_setup
from django.contrib.syndication.views import feed as django_feed
urlpatterns = patterns('helpdesk.views',
url(r'^$',
'dashboard',
@ -49,8 +55,18 @@ urlpatterns = patterns('helpdesk.views',
url(r'^view/$',
'public_view',
name='helpdesk_public_view'),
url(r'^rss/$',
'rss_list',
name='helpdesk_rss_index'),
)
urlpatterns += patterns('',
url(r'^rss/(?P<url>.*)/$',
login_required(django_feed),
{'feed_dict': feed_setup},
name='helpdesk_rss'),
)
urlpatterns += patterns('',
url(r'^api/(?P<method>[a-z_-]+)/$',
'helpdesk.api.api',

View File

@ -357,3 +357,9 @@ def unhold_ticket(request, ticket_id):
return hold_ticket(request, ticket_id, unhold=True)
unhold_ticket = login_required(unhold_ticket)
def rss_list(request):
return render_to_response('helpdesk/rss_list.html',
RequestContext(request, {
'queues': Queue.objects.all(),
}))
rss_list = login_required(rss_list)