* Removed horrid license - moved to BSD.

* Removed horrid file headers

* Added API - Mostly untested at this stage. Works via HTTP POST.
* Added API documentation
This commit is contained in:
Ross Poulton 2008-02-06 04:36:07 +00:00
parent 4a082e0bfb
commit 2895891fb0
14 changed files with 711 additions and 335 deletions

66
LICENSE
View File

@ -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

27
README
View File

@ -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

303
api.py Normal file
View File

@ -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

View File

@ -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

32
lib.py
View File

@ -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 <email>' 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 = []

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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():

View File

@ -0,0 +1,292 @@
<html>
<head>
<style type='text/css'>
body {
background-color: #fff;
color: #333;
font: 10pt "Trebuchet MS", Arial, sans-serif;
}
h1 {
color: #00c;
}
h1, h2, h3, h4 {
font-family: Garamond, Times, serif;
}
h2 {
color: #c00;
}
</style>
<title>Jutda Helpdesk API Documentation</title>
</head>
<body>
<h1>Jutda Helpdesk API Documentation</h1>
<h2>Contents</h2>
<ul>
<li><a href='#introduction'>Introduction</a></li>
<li><a href='#request'>Request Basics &amp; Authentication</a></li>
<li><a href='#response'>Responses</a></li>
<li><a href='#methods'>Method Documentation</a>
<ul>
<li><a href='#method_create_ticket'>create_ticket</a></li>
<li><a href='#method_delete_ticket'>delete_ticket</a></li>
<li><a href='#method_hold_ticket'>hold_ticket</a></li>
<li><a href='#method_unhold_ticket'>unhold_ticket</a></li>
<li><a href='#method_add_followup'>add_followup</a></li>
<li><a href='#method_resolve'>resolve</a></li>
<li><a href='#method_list_queues'>list_queues</a></li>
<li><a href='#method_find_user'>find_user</a></li>
</ul>
</li>
</ul>
<h2 name='introduction'>Introduction</h2>
<p>Jutda Helpdesk provides a powerful <acronym title='Application Programming Interface'>API</acroynm> to allow you to interact with your helpdesk tickets by a means not otherwise provided by the helpdesk.</p>
<p>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.</p>
<p>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.</p>
<h2 name='request'>Request Basics &amp; Authentication</h2>
<p>All requests to the API must be made using <acroynm title='HyperText Transfer Protocol'>HTTP</acronym> POST requests. Any request that is not made using POST will raise an error.</p>
<p>Your requests must be made up of the following elements:</p>
<ol>
<li>A <em>method</em>, or action. This tells the API what core functionality to execute.</li>
<li>A <em>username</em> and <em>password</em> which are valid and active within your helpdesk system. You may wish to create a specific API user just for API usage.</li>
<li>A set of <em>data</em> to be saved into the database. This data will vary from request to request, and is outlined in <a href='#methods'>Methods</a> below.</li>
</ol>
<p>To build your request, send a HTTP POST request to <em>{% url helpdesk_api "method" %}</em>, where <em>method</em> is the name of a <a href='#methods'>valid method</a> from the list below.</p>
<p>Your POST must include both <em>user</em> and <em>password</em> parameters.</p>
<p>A sample request for the method <em>hold_ticket</em> may look like this:</p>
<ul>
<li>A HTTP POST to <em>{% url helpdesk_api "hold_ticket" %}</em></li>
<li>A set of POST data containing:<ul>
<li>username=susan</li>
<li>password=fido</li>
<li>ticket=31794</li>
</ul></li>
</ul>
<p>To complete this from a command-line using the <a href='http://curl.haxx.se/'>cURL</a> application, you may use a command such as this:</p>
<pre>/usr/bin/curl {% url helpdesk_api "hold_ticket" %} --data "user=susan&amp;password=fido&amp;ticket=31794"</pre>
<p>In <a href='http://www.php.net/'>PHP</a>, providing you have access to the <a href='http://www.php.net/curl'>cURL libraries</a>, you may use code such as this:</p>
<pre>&lt;?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&amp;password=fido&amp;ticket=31794");
$result = curl_exec($api);
curl_close($api);
echo $result;
?&lt;</pre>
<p>Note that cURL expects all data to be urlencoded, this is left as an exercise for the reader.</p>
<h2 name='#response'>Responses</h2>
<p>The API system makes proper use of the following HTTP response codes:</p>
<dl>
<dt>200</dt>
<dd>OK - Data updated successfully</dd>
<dt>400</dt>
<dd>ERROR - Generic error. See returned text for details</dd>
<dt>404</dt>
<dd>ERROR - Data not found (eg, incorrect ticket). See returned text for details</dd>
<dt>403</dt>
<dd>ERROR - Invalid permissions (eg, incorrect username and/or password)</dd>
<dt>405</dt>
<dd>ERROR - Invalid method. You probably tried using GET, PUT or DELETE however we require POST.</dd>
</dl>
<p>Responses will have one of two content-types:</p>
<dl>
<dt>text/plain</dt>
<dd>Any error messages, or simple responses (eg a ticket ID)</dd>
<dt>text/json</dt>
<dd>Any complex responses, such as a list of data.</dd>
</dl>
<h2 name='methods'>Method Documentation</h2>
<p>The following public methods are available for use via the API. Each of them requires <a href='#request'>a valid request and authentication</a>, and each has it's own parameters as described below.</p>
<ul>
<li><a href='#method_create_ticket'>create_ticket</a></li>
<li><a href='#method_delete_ticket'>delete_ticket</a></li>
<li><a href='#method_hold_ticket'>hold_ticket</a></li>
<li><a href='#method_unhold_ticket'>unhold_ticket</a></li>
<li><a href='#method_add_followup'>add_followup</a></li>
<li><a href='#method_resolve'>resolve</a></li>
<li><a href='#method_list_queues'>list_queues</a></li>
<li><a href='#method_find_user'>find_user</a></li>
</ul>
<h3 name='method_create_ticket'>create_ticket</h3>
<p>This method creates a new helpdesk ticket.</p>
<h4>Parameters</h4>
<dl>
<dt>queue</dt>
<dd>Queue ID (use <a href='#method_list_queues'>list_queues</a> to get queue ID's) - this is an integer field.</dd>
<dt>title</dt>
<dd>Title or header of this ticket. Character field, maximum 100 characters.</dd>
<dt>submitter_email</dt>
<dd>(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.</dd>
<dt>assigned_to</dt>
<dd>(Optional) Integer ID of the user to which this ticket should be assigned. Use <a href='#method_find_user'>find_user</a> to find a user ID from a username.</dd>
<dt>priority</dt>
<dd>(Optional) Priority as an integer from 1 (high) to 5 (low). Defaults to 3 if no priority given.</dd>
</dl>
<h4>Response</h4>
<p>This method responds with <strong>plain-text</strong>.</p>
<p>If you receive a 200 OK <a href='#response'>response</a>, then the content of the response will be the ticket ID.</p>
<h3 name='method_delete_ticket'>delete_ticket</h3>
<p>When given a ticket ID and confirmation, this method will delete a ticket entirely. This also deletes any followups, attachments, and other details.</p>
<h4>Parameters</h4>
<dl>
<dt>ticket</dt>
<dd>The numeric ticket ID to be deleted</dd>
<dt>confirm</dt>
<dd>You must provide this field, with any value, to enable deletion to continue</dd>
</dl>
<h4>Response</h4>
<p>A standard <a href='#response'>200 OK response</a> is given on success, or an error message on failure.</p>
<h3 name='method_hold_ticket'>hold_ticket</h3>
<p>If a ticket needs to be placed on hold, preventing it from being escalated, use this method.</p>
<h4>Parameters</h4>
<dl>
<dt>ticket</dt>
<dd>The numeric ticket ID to be placed on hold</dd>
</dl>
<h4>Response</h4>
<p>A standard <a href='#response'>200 OK response</a> is given on success, or an error message on failure.</p>
<h3 name='method_unhold_ticket'>unhold_ticket</h3>
<p>If a ticket is currently on hold and you wish to remove that hold, use this method.</p>
<h4>Parameters</h4>
<dl>
<dt>ticket</dt>
<dd>The numeric ticket ID to be taken off hold</dd>
</dl>
<h4>Response</h4>
<p>A standard <a href='#response'>200 OK response</a> is given on success, or an error message on failure.</p>
<h3 name='method_add_followup'>add_followup</h3>
<p>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.</p>
<h4>Parameters</h4>
<dl>
<dt>ticket</dt>
<dd>The numeric ticket ID to which this followup should be added</dd>
<dt>message</dt>
<dd>Text of 'unlimited' length - optionally formatted with HTML - to add to the message.</dd>
<dt>public</dt>
<dd>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 <strong>not</strong> e-mailed to the ticket submitter.</dd>
</dl>
<h4>Response</h4>
<p>A standard <a href='#response'>200 OK response</a> is given on success, or an error message on failure.</p>
<h3 name='method_resolve'>resolve</h3>
<p>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.</p>
<h4>Parameters</h4>
<dl>
<dt>ticket</dt>
<dd>The numeric ticket ID to which this followup should be added</dd>
<dt>resolution</dt>
<dd>Text of 'unlimited' length - optionally formatted with HTML. This is the resolution for this ticket.</dd>
</dl>
<h4>Response</h4>
<p>A standard <a href='#response'>200 OK response</a> is given on success, or an error message on failure.</p>
<h3 name='method_list_queues'>list_queues</h3>
<p>This method provides a JSON-parsable list of queues, letting you access the individual queue ID in order to create tickets.</p>
<h4>Response</h4>
<p>This method responds with <strong>json</strong>.</p>
<p>It provides a list of queues in JSON format. The fields provided are ID and Title.</p>
<h3 name='method_find_user'>find_user</h3>
<p>When given a username, this method provides the related numeric user ID - commonly used when creating or reassigning tickets.</p>
<h4>Parameters</h4>
<dl>
<dt>username</dt>
<dd>The case-sensitive username of the user for which you require the user ID</dd>
</dl>
<h4>Response</h4>
<p>This method responds with <strong>plain-text</strong>.</p>
<p>If you receive a 200 OK <a href='#response'>response</a>, then the content of the response will be the users ID.</p>
</body>
</html>

View File

@ -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

View File

@ -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

42
urls.py
View File

@ -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<method>[a-z_-]+)/$',
'helpdesk.api.api',
name='helpdesk_api'),
url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),
url(r'^login/$',
'django.contrib.auth.views.login',
name='login'),
url(r'^logout/$',
'django.contrib.auth.views.logout',
name='logout'),
)

View File

@ -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)