From 2895891fb032f3aecdc5e0c8c4c46b297665118c Mon Sep 17 00:00:00 2001 From: Ross Poulton Date: Wed, 6 Feb 2008 04:36:07 +0000 Subject: [PATCH] * Removed horrid license - moved to BSD. * Removed horrid file headers * Added API - Mostly untested at this stage. Works via HTTP POST. * Added API documentation --- LICENSE | 66 ++---- README | 27 +-- api.py | 303 ++++++++++++++++++++++++ forms.py | 28 +-- lib.py | 32 +-- models.py | 37 +-- scripts/create_escalation_exclusions.py | 32 +-- scripts/escalate_tickets.py | 31 +-- scripts/get_email.py | 35 +-- templates/helpdesk/api_help.html | 292 +++++++++++++++++++++++ templatetags/in_list.py | 41 ++-- templatetags/ticket_to_link.py | 37 +-- urls.py | 42 ++-- views.py | 43 +--- 14 files changed, 711 insertions(+), 335 deletions(-) create mode 100644 api.py create mode 100644 templates/helpdesk/api_help.html diff --git a/LICENSE b/LICENSE index bd94a864..4be731a0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,52 +1,30 @@ -Jutda Helpdesk -End User License Agreement (Last Updated January 15th 2007) +Copyright (c) 2008, Ross Poulton (Trading as Jutda) +All rights reserved. -SUMMARY +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: -You should not have paid for this software. + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. -This software is not Free Software. You may freely download this software from it's manufacturer (Jutda, www.jutda.com.au) and use it within your organisation. You may not distribute this software or give it to others. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. -You may install this software for other users, for example for a client or customer, however you must download the software yourself prior to installation, leaving the client with a working installation of the software. + 3. Neither the name of Ross Poulton, Jutda, nor the names of any + of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. -LICENSE AGREEMENT - -This license agreement is between you and Jutda and governs your use of this software, including related components and documentation (herein referred to in whole as the "software"). - -Jutda grants you a non-exclusive license to use the software subject to the provisions in all sections of this Agreement. - -By downloading, installing, or using the software, yo uagree to be bound by this agreement. If you do not agree to all of the terms of this agreement, do not download, install, or use the software. - -YOU MAY - -* Modify and customise the software to your personal liking, within the extent detailed in this agreement -* Create and distribute documentation, templates, or modifications to the software -* Create external software or internal modules that interact with the software -* Install this software for a client or third party and charge that client or third party for your services - -YOU MAY NOT - -* Permit other individuals or organisations to use the software except when udner the use of this license agreement -* Charge for the software, in currency or in kind (excluding charges for installation or modification) -* Use the software in a way or within an organisation that condones or encourages terrorism, pirated software, or any other form of illegal activity -* Modify or remove any copyright notices or labels, license details, or other such material from the software. This includes any links containing manufacturer or copyright information. -* Distribute any of the files or any part of the files contained in the software (excluding documentation, templates or modifications which you have created in whole, which do not contain any part of the files contained in the software) - -DISCLAIMER OF WARRANTY - -The software is provided on an "AS IS" basis, without warranty of any kind, including without limitation the warranties of merchantability, fitness for a particular purpose, and non-infringement. The entire risk as to the quality and performance of the software is borne by you. Should the software prove defective, you and not Jutda assume the entire cost of any service and repair. In addition, any security mechanisms implemented by the software may have inherent limitations, and you must determine that the software sufficiently meets your requirements. This disclaimer of warranty constitutes an essential part of the agreement. - -TITLE - -Title, ownership rights, and intellectual property rights in the software shall remain with Jutda. The software is protected by copyright laws and treaties. Title and related rights in the content generated through the software is the property of the applicable content owner and may be protected by applicable law. This license gives Jutda no rights to such content. - -TERMINATION - -This agreement will terminate automatically upon failure to comply with the limitations described herein or on written notice from an authorized representative of Jutda. On termination, you must destroy all copies of the software within 48 hours. Termination of the license due to non compliance will not result in any refunds of license fees. - -MISCELLANEOUS - -Jutda reserves the right to change the terms of this agreement at any time. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EXCEPTIONS diff --git a/README b/README index 0e88ec4b..149229d0 100644 --- a/README +++ b/README @@ -1,29 +1,6 @@ - .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. -$Id$ +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. ######################### 0. Table of Contents diff --git a/api.py b/api.py new file mode 100644 index 00000000..ed155a16 --- /dev/null +++ b/api.py @@ -0,0 +1,303 @@ +""" .. +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. + +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. + +api.py - Wrapper around API calls, and core functions to provide complete + API to third party applications. + +The API documentation can be accessed by visiting http://helpdesk/api/help/ +(obviously, substitute helpdesk for your Jutda Helpdesk URI), or by reading +through templates/helpdesk/api_help.html. +""" +from datetime import datetime +import simplejson + +from django.contrib.auth.models import User +from django.contrib.auth import authenticate +from django.http import HttpResponse +from django.shortcuts import render_to_response +from django.template import loader, Context +from django import newforms as forms + +from helpdesk.lib import send_multipart_mail +from helpdesk.models import Ticket, Queue, FollowUp + +STATUS_OK = 200 + +STATUS_ERROR = 400 +STATUS_ERROR_NOT_FOUND = 404 +STATUS_ERROR_PERMISSIONS = 403 +STATUS_ERROR_BADMETHOD = 405 + +def api(request, method): + if method == 'help': + """ Regardless of any other paramaters, we provide a help screen + to the user if they requested one. """ + return render_to_response('helpdesk/api_help.html') + + """ + If the user isn't looking for help, then we enforce a few conditions: + * The request must be sent via HTTP POST + * The request must contain a 'user' and 'password' which + must be valid users + * The method must match one of the public methods of the API class. + """ + + if request.method != 'POST': + return api_return(STATUS_ERROR_BADMETHOD) + + request.user = authenticate(username=request.POST.get('user', False), password=request.POST.get('password')) + if request.user is None: + return api_return(STATUS_ERROR_PERMISSIONS) + + api = API(request) + if hasattr(api, 'api_public_%s' % method): + return getattr(api, 'api_public_%s' % method)() + + return api_return(STATUS_ERROR) + + +def api_return(status, text='', json=False): + content_type = 'text/plain' + if status == STATUS_OK and json: + content_type = 'text/json' + + if text is None: + if status == STATUS_ERROR: + text = 'Error' + elif status == STATUS_ERROR_NOT_FOUND: + text = 'Resource Not Found' + elif status == STATUS_ERROR_PERMISSIONS: + text = 'Invalid username or password' + elif status == STATUS_ERROR_BADMETHOD: + text = 'Invalid request method' + elif status == STATUS_OK: + text = 'OK' + r = HttpResponse(status=status, content=text, content_type=content_type) + + if status == STATUS_ERROR_BADMETHOD: + r.Allow = 'POST' + return r + + +class API: + def __init__(self, request): + self.request = request + + def api_public_create_ticket(self): + + form = APITicketForm(self.request.POST) + form.fields['queue'].choices = [[q.id, q.title] for q in Queue.objects.all()] + form.fields['assigned_to'].choices = [[u.id, u.username] for u in User.objects.filter(is_active=True)] + if form.is_valid(): + ticket = form.save(user=self.request.user) + return api_return(STATUS_OK, "%s" % ticket.id) + else: + return api_return(STATUS_ERROR) + + + def api_public_list_queues(self): + return api_return(STATUS_OK, simplejson.dumps([{"id": "%s" % q.id, "title": "%s" % q.title} for q in Queue.objects.all()]), json=True) + + + def api_public_find_user(self): + username = self.request.POST.get('username', False) + try: + u = User.objects.get(username=username) + return api_return(STATUS_OK, "%s" % u.id) + except: + return api_return(STATUS_ERROR, "Invalid username provided") + + + def api_public_delete_ticket(self): + if not self.request.POST.get('confirm', False): + return api_return(STATUS_ERROR, "No confirmation provided") + + try: + ticket = Ticket.objects.get(id=self.request.POST.get('ticket', False)) + except: + return api_return(STATUS_ERROR, "Invalid ticket ID") + + ticket.delete() + return api_return(STATUS_OK) + + + def api_public_hold_ticket(self): + try: + ticket = Ticket.objects.get(id=self.request.POST.get('ticket', False)) + except: + return api_return(STATUS_ERROR, "Invalid ticket ID") + + ticket.on_hold = True + ticket.save() + + return api_return(STATUS_OK) + + + def api_public_unhold_ticket(self): + try: + ticket = Ticket.objects.get(id=self.request.POST.get('ticket', False)) + except: + return api_return(STATUS_ERROR, "Invalid ticket ID") + + ticket.on_hold = False + ticket.save() + + return api_return(STATUS_OK) + + + def api_public_add_followup(self): + try: + ticket = Ticket.objects.get(id=self.request.POST.get('ticket', False)) + except: + return api_return(STATUS_ERROR, "Invalid ticket ID") + + message = self.request.POST.get('message', None) + public = self.request.POST.get('public', 'n') + + if public not in ['y', 'n']: + return api_return(STATUS_ERROR, "Invalid 'public' flag") + + if not message: + return api_return(STATUS_ERROR, "Blank message") + + f = FollowUp(ticket=ticket, date=datetime.now(), comment=message, user=self.request.user, title='Comment Added') + if public: + f.public = True + f.save() + + context = { + 'ticket': ticket, + 'queue': ticket.queue, + 'comment': f.comment, + } + + subject = '%s %s (Updated)' % (ticket.ticket, ticket.title) + + if public and ticket.submitter_email: + template = 'helpdesk/emails/submitter_updated' + send_multipart_mail(template, context, subject, ticket.submitter_email, ticket.queue.from_address) + + if ticket.queue.updated_ticket_cc: + template_cc = 'helpdesk/emails/cc_updated' + send_multipart_mail(template_cc, context, subject, q.updated_ticket_cc, ticket.queue.from_address) + + if ticket.assigned_to and user != ticket.assigned_to: + template_owner = 'helpdesk/emails/owner_updated' + send_multipart_mail(template_owner, context, subject, t.assigned_to.email, ticket.queue.from_address) + + ticket.save() + + return api_return(STATUS_OK) + + + def api_public_resolve(self): + try: + ticket = Ticket.objects.get(id=self.request.POST.get('ticket', False)) + except: + return api_return(STATUS_ERROR, "Invalid ticket ID") + + resolution = self.request.POST.get('resolution', None) + + if not resolution: + return api_return(STATUS_ERROR, "Blank resolution") + + f = FollowUp(ticket=ticket, date=datetime.now(), comment=resolution, user=self.request.user, title='Resolved', public=True) + f.save() + + context = { + 'ticket': ticket, + 'queue': ticket.queue, + 'resolution': f.comment, + } + + subject = '%s %s (Resolved)' % (ticket.ticket, ticket.title) + + if public and ticket.submitter_email: + template = 'helpdesk/emails/submitter_resolved' + send_multipart_mail(template, context, subject, ticket.submitter_email, ticket.queue.from_address) + + if ticket.queue.updated_ticket_cc: + template_cc = 'helpdesk/emails/cc_resolved' + send_multipart_mail(template_cc, context, subject, q.updated_ticket_cc, ticket.queue.from_address) + + if ticket.assigned_to and user != ticket.assigned_to: + template_owner = 'helpdesk/emails/owner_resolved' + send_multipart_mail(template_owner, context, subject, t.assigned_to.email, ticket.queue.from_address) + + ticket.resoltuion = f.comment + ticket.status = Ticket.STATUS_RESOLVED + + ticket.save() + + return api_return(STATUS_OK) + + +class APITicketForm(forms.Form): + """ We make bastardised use of the forms functionality within Django to + validate incoming data for new tickets. """ + queue = forms.ChoiceField(required=True, choices=()) + title = forms.CharField(max_length=100, required=True) + submitter_email = forms.EmailField(required=False) + body = forms.CharField(widget=forms.Textarea(), required=True) + assigned_to = forms.ChoiceField(choices=(), required=False) + priority = forms.ChoiceField(choices=Ticket.PRIORITY_CHOICES, + required=False, + initial='3') + + def save(self, user): + """ + Writes and returns a Ticket() object + + """ + q = Queue.objects.get(id=int(self.cleaned_data['queue'])) + + t = Ticket( title = self.cleaned_data['title'], + submitter_email = self.cleaned_data['submitter_email'], + created = datetime.now(), + status = Ticket.OPEN_STATUS, + queue = q, + description = self.cleaned_data['body'], + priority = self.cleaned_data['priority'], + ) + + if self.cleaned_data['assigned_to']: + try: + u = User.objects.get(id=self.cleaned_data['assigned_to']) + t.assigned_to = u + except: + t.assigned_to = None + t.save() + + f = FollowUp( ticket = t, + title = 'Ticket Opened', + date = datetime.now(), + public = True, + comment = self.cleaned_data['body'], + user = user, + ) + if self.cleaned_data['assigned_to']: + f.title = 'Ticket Opened & Assigned to %s' % t.get_assigned_to + + f.save() + + context = { + 'ticket': t, + 'queue': q, + } + + + if t.submitter_email: + send_multipart_mail('helpdesk/emails/submitter_newticket', context, '%s %s' % (t.ticket, t.title), t.submitter_email, q.from_address) + + if t.assigned_to and t.assigned_to != user: + send_multipart_mail('helpdesk/emails/owner_assigned', context, '%s %s (Opened)' % (t.ticket, t.title), t.assigned_to.email, q.from_address) + + if q.new_ticket_cc: + send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), q.updated_ticket_cc, q.from_address) + + if q.updated_ticket_cc and q.updated_ticket_cc != q.new_ticket_cc: + send_multipart_mail('helpdesk/emails/cc_newticket', context, '%s %s (Opened)' % (t.ticket, t.title), q.updated_ticket_cc, q.from_address) + + return t diff --git a/forms.py b/forms.py index b0d56c32..3344830d 100644 --- a/forms.py +++ b/forms.py @@ -1,30 +1,10 @@ """ .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. -$Id$ +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. +forms.py - Definitions of newforms-based forms for creating and maintaining + tickets. """ from django import newforms as forms diff --git a/lib.py b/lib.py index 2bd174a2..0008b775 100644 --- a/lib.py +++ b/lib.py @@ -1,29 +1,9 @@ """ .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. -$Id$ +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. + +lib.py - Common functions (eg multipart e-mail) """ def send_multipart_mail(template_name, email_context, subject, recipients, sender=None, bcc=None, fail_silently=False, files=None): @@ -47,6 +27,7 @@ def send_multipart_mail(template_name, email_context, subject, recipients, sende sender can be an e-mail, 'Name ' or None. If unspecified, the DEFAULT_FROM_EMAIL will be used. + Originally posted on my blog at http://www.rossp.org/ """ from django.core.mail import EmailMultiAlternatives from django.template import loader, Context @@ -77,6 +58,9 @@ def send_multipart_mail(template_name, email_context, subject, recipients, sende return msg.send(fail_silently) def normalise_to_100(data): + """ + Used for normalising data prior to graphing with Google charting API + """ max_value = max(data) if max_value > 100: new_data = [] diff --git a/models.py b/models.py index 66d51fee..bebfd715 100644 --- a/models.py +++ b/models.py @@ -1,31 +1,12 @@ -""" .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. - -$Id$ - """ +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. + +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. + +models.py - Model (and hence database) definitions. This is the core of the + helpdesk structure. +""" + from datetime import datetime from django.contrib.auth.models import User @@ -313,7 +294,7 @@ class PreSetReply(models.Model): return u'%s' % self.name class EscalationExclusion(models.Model): - queues = models.ManyToManyField(Queue, blank=True, null=True, help_text='Leave blank for this exclusion to b eaplied to all queues, or select those queues you wish to exclude with this entry.') + queues = models.ManyToManyField(Queue, blank=True, null=True, help_text='Leave blank for this exclusion to be applied to all queues, or select those queues you wish to exclude with this entry.') name = models.CharField(maxlength=100) diff --git a/scripts/create_escalation_exclusions.py b/scripts/create_escalation_exclusions.py index 452656b2..27e16bda 100644 --- a/scripts/create_escalation_exclusions.py +++ b/scripts/create_escalation_exclusions.py @@ -1,30 +1,12 @@ -""" .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. +#!/usr/bin/python +""" +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. -$Id$ +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. +scripts/create_escalation_exclusion.py - Easy way to routinely add particular + days to the list of days on which no + escalation should take place. """ from datetime import datetime, timedelta, date from django.db.models import Q diff --git a/scripts/escalate_tickets.py b/scripts/escalate_tickets.py index fe7158a9..8f9cf625 100644 --- a/scripts/escalate_tickets.py +++ b/scripts/escalate_tickets.py @@ -1,30 +1,11 @@ -""" .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. +#!/usr/bin/python +""" +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. -$Id$ +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. +scripts/escalate_tickets.py - Easy way to escalate tickets based on their age, + designed to be run from Cron or similar. """ from datetime import datetime, timedelta, date from django.db.models import Q diff --git a/scripts/get_email.py b/scripts/get_email.py index 5aa0dd3b..979bbc85 100644 --- a/scripts/get_email.py +++ b/scripts/get_email.py @@ -1,37 +1,20 @@ -""" .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. +#!/usr/bin/python +""" +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. -$Id$ +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. +scripts/get_email.py - Designed to be run from cron, this script checks the + POP and IMAP boxes defined for the queues within a + helpdesk, creating tickets from the new messages (or + adding to existing tickets if needed) """ import poplib import imaplib from datetime import datetime, timedelta import email, mimetypes, re from email.Utils import parseaddr -from helpdesk.models import Queue,Ticket, FollowUp +from helpdesk.models import Queue, Ticket, FollowUp from helpdesk.lib import send_multipart_mail def process_email(): diff --git a/templates/helpdesk/api_help.html b/templates/helpdesk/api_help.html new file mode 100644 index 00000000..99ec82f1 --- /dev/null +++ b/templates/helpdesk/api_help.html @@ -0,0 +1,292 @@ + + + + Jutda Helpdesk API Documentation + + +

Jutda Helpdesk API Documentation

+ +

Contents

+ + + +

Introduction

+ +

Jutda Helpdesk provides a powerful API to allow you to interact with your helpdesk tickets by a means not otherwise provided by the helpdesk.

+ +

For example, you may use this API to implement a system to automatically open a ticket when an invoice is raised in your invoicing system, or to automatically close a ticket from an instant messenger application.

+ +

Your use of this system is open-ended: most business cases should be addressible with a little bit of coding to allow you to interact nicely with your helpdesk.

+ +

Request Basics & Authentication

+ +

All requests to the API must be made using HTTP POST requests. Any request that is not made using POST will raise an error.

+ +

Your requests must be made up of the following elements:

+ +
    +
  1. A method, or action. This tells the API what core functionality to execute.
  2. +
  3. A username and password which are valid and active within your helpdesk system. You may wish to create a specific API user just for API usage.
  4. +
  5. A set of data to be saved into the database. This data will vary from request to request, and is outlined in Methods below.
  6. +
+ +

To build your request, send a HTTP POST request to {% url helpdesk_api "method" %}, where method is the name of a valid method from the list below.

+ +

Your POST must include both user and password parameters.

+ +

A sample request for the method hold_ticket may look like this:

+ + + +

To complete this from a command-line using the cURL application, you may use a command such as this:

+ +
/usr/bin/curl {% url helpdesk_api "hold_ticket" %} --data "user=susan&password=fido&ticket=31794"
+ +

In PHP, providing you have access to the cURL libraries, you may use code such as this:

+ +
<?php
+$api = curl_init();
+curl_setopt($api, CURLOPT_URL, "{% url helpdesk_api "hold_ticket" %}");
+curl_setopt($api, CURLOPT_POST, 1);
+curl_setopt($api, CURLOPT_POSTFIELDS, "user=susan&password=fido&ticket=31794");
+$result = curl_exec($api);
+curl_close($api);
+echo $result;
+?<
+ +

Note that cURL expects all data to be urlencoded, this is left as an exercise for the reader.

+ +

Responses

+ +

The API system makes proper use of the following HTTP response codes:

+ +
+
200
+
OK - Data updated successfully
+ +
400
+
ERROR - Generic error. See returned text for details
+ +
404
+
ERROR - Data not found (eg, incorrect ticket). See returned text for details
+ +
403
+
ERROR - Invalid permissions (eg, incorrect username and/or password)
+ +
405
+
ERROR - Invalid method. You probably tried using GET, PUT or DELETE however we require POST.
+
+ +

Responses will have one of two content-types:

+ +
+
text/plain
+
Any error messages, or simple responses (eg a ticket ID)
+ +
text/json
+
Any complex responses, such as a list of data.
+
+ +

Method Documentation

+ +

The following public methods are available for use via the API. Each of them requires a valid request and authentication, and each has it's own parameters as described below.

+ + + +

create_ticket

+ +

This method creates a new helpdesk ticket.

+ +

Parameters

+ +
+
queue
+
Queue ID (use list_queues to get queue ID's) - this is an integer field.
+ +
title
+
Title or header of this ticket. Character field, maximum 100 characters.
+ +
submitter_email
+
(Optional) e-mail address of the person submitting this ticket. This e-mail address will receive copies of all public updates to this ticket, and will receive a notification when the ticket is created.
+ +
assigned_to
+
(Optional) Integer ID of the user to which this ticket should be assigned. Use find_user to find a user ID from a username.
+ +
priority
+
(Optional) Priority as an integer from 1 (high) to 5 (low). Defaults to 3 if no priority given.
+
+ +

Response

+ +

This method responds with plain-text.

+ +

If you receive a 200 OK response, then the content of the response will be the ticket ID.

+ +

delete_ticket

+ +

When given a ticket ID and confirmation, this method will delete a ticket entirely. This also deletes any followups, attachments, and other details.

+ +

Parameters

+ +
+
ticket
+
The numeric ticket ID to be deleted
+ +
confirm
+
You must provide this field, with any value, to enable deletion to continue
+
+ +

Response

+ +

A standard 200 OK response is given on success, or an error message on failure.

+ +

hold_ticket

+ +

If a ticket needs to be placed on hold, preventing it from being escalated, use this method.

+ +

Parameters

+
+
ticket
+
The numeric ticket ID to be placed on hold
+
+ +

Response

+ +

A standard 200 OK response is given on success, or an error message on failure.

+ + +

unhold_ticket

+ +

If a ticket is currently on hold and you wish to remove that hold, use this method.

+ +

Parameters

+
+
ticket
+
The numeric ticket ID to be taken off hold
+
+ +

Response

+ +

A standard 200 OK response is given on success, or an error message on failure.

+ + +

add_followup

+ +

This method adds a comment / followup to a ticket. The followup can be public, in which case it is e-mailed to the submitter, or private. The followup will also be sent to others involved in the ticket: The owner and the queue notification / CC address.

+ +

Parameters

+ +
+
ticket
+
The numeric ticket ID to which this followup should be added
+ +
message
+
Text of 'unlimited' length - optionally formatted with HTML - to add to the message.
+ +
public
+
Either 'y' for public, or 'n' for private. This is optional, and it is assumed that followups are private if it is not provided. Private tickets are not e-mailed to the ticket submitter.
+
+ +

Response

+ +

A standard 200 OK response is given on success, or an error message on failure.

+ + +

resolve

+ +

This method adds a resolution to a ticket and marks it as resolved. The resolution will be e-mailed to everybody involved with the ticket, including the submitter.

+ +

Parameters

+ +
+
ticket
+
The numeric ticket ID to which this followup should be added
+ +
resolution
+
Text of 'unlimited' length - optionally formatted with HTML. This is the resolution for this ticket.
+
+ +

Response

+ +

A standard 200 OK response is given on success, or an error message on failure.

+ + +

list_queues

+ +

This method provides a JSON-parsable list of queues, letting you access the individual queue ID in order to create tickets.

+ +

Response

+ +

This method responds with json.

+ +

It provides a list of queues in JSON format. The fields provided are ID and Title.

+ + +

find_user

+ +

When given a username, this method provides the related numeric user ID - commonly used when creating or reassigning tickets.

+ +

Parameters

+ +
+
username
+
The case-sensitive username of the user for which you require the user ID
+
+ +

Response

+ +

This method responds with plain-text.

+ +

If you receive a 200 OK response, then the content of the response will be the users ID.

+ + diff --git a/templatetags/in_list.py b/templatetags/in_list.py index e234e12a..2dc0e0aa 100644 --- a/templatetags/in_list.py +++ b/templatetags/in_list.py @@ -1,32 +1,19 @@ -""" .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. - -$Id$ - """ +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. + +templatetags/in_list.py - Very simple template tag to allow us to use the + equivilent of 'if x in y' in templates. eg: + +Assuming 'food' = 'pizza' and 'best_foods' = ['pizza', 'pie', 'cake]: + +{% if food|in_list:best_foods %} + You've selected one of our favourite foods! +{% else %} + Your food isn't one of our favourites. +{% endif %} +""" from django import template def in_list(value, arg): return value in arg diff --git a/templatetags/ticket_to_link.py b/templatetags/ticket_to_link.py index 6d216fd0..0211e74d 100644 --- a/templatetags/ticket_to_link.py +++ b/templatetags/ticket_to_link.py @@ -1,32 +1,15 @@ -""" .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. - -$Id$ - """ +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. + +templatetags/ticket_to_link.py - Used in ticket comments to allow wiki-style + linking to other tickets. Including text such + as '#3180' in a comment automatically links + that text to ticket number 3180, with styling + to show the status of that ticket (eg a closed + ticket would have a strikethrough). +""" from django import template from helpdesk.models import Ticket diff --git a/urls.py b/urls.py index 4b4af6a7..df92c245 100644 --- a/urls.py +++ b/urls.py @@ -1,30 +1,10 @@ -""" .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. +""" +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. -$Id$ +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. +urls.py - Mapping of URL's to our various views. Note we always used NAMED + views for simplicity in linking later on. """ from django.conf.urls.defaults import * @@ -72,7 +52,15 @@ urlpatterns = patterns('helpdesk.views', ) urlpatterns += patterns('', - url(r'^login/$', 'django.contrib.auth.views.login', name='login'), + url(r'^api/(?P[a-z_-]+)/$', + 'helpdesk.api.api', + name='helpdesk_api'), + + url(r'^login/$', + 'django.contrib.auth.views.login', + name='login'), - url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'), + url(r'^logout/$', + 'django.contrib.auth.views.logout', + name='logout'), ) diff --git a/views.py b/views.py index c6e478ad..f37fc792 100644 --- a/views.py +++ b/views.py @@ -1,35 +1,13 @@ -""" .. - .,::;:::::: - ..,::::::::,,,,::: Jutda Helpdesk - A Django - .,,::::::,,,,,,,,,,,,,:: powered ticket tracker for - .,::::::,,,,,,,,,,,,,,,,,,:;r. small enterprise - .::::,,,,,,,,,,,,,,,,,,,,,,:;;rr. - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;;;rr (c) Copyright 2008 - .:::,,,,,,,,,,,,,,,,,,,,,,,:;;;:::;;rr - .:::,,,,,,,,,,,,,,,,,,,,. ,;;;::::::;;rr Jutda - .:::,,,,,,,,,,,,,,,,,,. .:;;:::::::::;;rr - .:::,,,,,,,,,,,,,,,. .;r;::::::::::::;r; All Rights Reserved - .:::,,,,,,,,,,,,,,, .;r;;:::::::::::;;:. - .:::,,,,,,,,,,,,,,,. .;r;;::::::::::::;:. - .;:,,,,,,,,,,,,,,, .,;rr;::::::::::::;:. This software is released -.,:,,,,,,,,,,,,,. .,:;rrr;;::::::::::::;;. under a limited-use license that - :,,,,,,,,,,,,,..:;rrrrr;;;::::::::::::;;. allows you to freely download this - :,,,,,,,:::;;;rr;;;;;;:::::::::::::;;, software from it's manufacturer and - ::::;;;;;;;;;;;:::::::::::::::::;;, use it yourself, however you may not - .r;;;;:::::::::::::::::::::::;;;, distribute it. For further details, see - .r;::::::::::::::::::::;;;;;:, the enclosed LICENSE file. - .;;::::::::::::::;;;;;:,. - .;;:::::::;;;;;;:,. Please direct people who wish to download this - .r;;;;;;;;:,. software themselves to www.jutda.com.au. - ,,,.. - -$Id$ - """ -# Python imports +Jutda Helpdesk - A Django powered ticket tracker for small enterprise. + +(c) Copyright 2008 Jutda. All Rights Reserved. See LICENSE for details. + +views.py - The bulk of the application - provides most business logic and + renders all user-facing views. +""" from datetime import datetime -# Django imports from django.contrib.auth.models import User from django.contrib.auth.decorators import login_required from django.core.urlresolvers import reverse @@ -38,16 +16,15 @@ from django.http import HttpResponseRedirect, Http404, HttpResponse from django.shortcuts import render_to_response, get_object_or_404 from django.template import loader, Context, RequestContext -# Helpdesk imports from helpdesk.forms import TicketForm, PublicTicketForm from helpdesk.lib import send_multipart_mail from helpdesk.models import Ticket, Queue, FollowUp, TicketChange, PreSetReply def dashboard(request): """ - This isn't always truly a "dashboard" view. If the user is not logged in, we - instead show the user a "public submission" form and a way to view existing - tickets. + This isn't always truly a "dashboard" view. If the user is not logged in, + we instead show the user a "public submission" form and a way to view + existing tickets. """ if request.user.is_authenticated(): tickets = Ticket.objects.filter(assigned_to=request.user).exclude(status=Ticket.CLOSED_STATUS)