forked from extern/django-helpdesk
* General clean-up, especially for Django admin - added help_text to more fields and defined other admin options to make life easier.
This commit is contained in:
parent
dce7731957
commit
038ea15877
48
models.py
48
models.py
@ -26,10 +26,11 @@
|
||||
$Id$
|
||||
|
||||
"""
|
||||
from django.db import models
|
||||
from datetime import datetime
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import permalink
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
|
||||
class Queue(models.Model):
|
||||
"""
|
||||
@ -43,10 +44,13 @@ class Queue(models.Model):
|
||||
can automatically get tickets via e-mail.
|
||||
"""
|
||||
title = models.CharField(maxlength=100)
|
||||
slug = models.SlugField()
|
||||
email_address = models.EmailField(blank=True, null=True)
|
||||
slug = models.SlugField(help_text='This slug is used when building ticket ID\'s. Once set, try not to change it or e-mailing may get messy.')
|
||||
email_address = models.EmailField(blank=True, null=True, help_text='All outgoing e-mails for this queue will use this e-mail address. If you use IMAP or POP3, this shoul be the e-mail address for that mailbox.')
|
||||
|
||||
def _from_address(self):
|
||||
if not self.email_address:
|
||||
return 'NO QUEUE EMAIL ADDRESS DEFINED <%s>' % settings.DEFAULT_FROM_EMAIL
|
||||
else:
|
||||
return '%s <%s>' % (self.title, self.email_address)
|
||||
from_address = property(_from_address)
|
||||
|
||||
@ -63,13 +67,17 @@ class Queue(models.Model):
|
||||
return u"%s" % self.title
|
||||
|
||||
class Admin:
|
||||
pass
|
||||
list_display = ('title', 'slug', 'email_address')
|
||||
|
||||
class Meta:
|
||||
ordering = ('title',)
|
||||
|
||||
def save(self):
|
||||
if self.email_box_type == 'imap' and not self.email_box_imap_folder:
|
||||
self.email_box_imap_folder = 'INBOX'
|
||||
super(Queue, self).save()
|
||||
|
||||
|
||||
class Ticket(models.Model):
|
||||
"""
|
||||
To allow a ticket to be entered as quickly as possible, only the
|
||||
@ -146,19 +154,19 @@ class Ticket(models.Model):
|
||||
get_priority_img = property(_get_priority_img)
|
||||
|
||||
class Admin:
|
||||
list_display = ('title', 'status', 'assigned_to',)
|
||||
list_display = ('title', 'status', 'assigned_to', 'submitter_email',)
|
||||
date_hierarchy = 'created'
|
||||
list_filter = ('assigned_to',)
|
||||
list_filter = ('assigned_to', 'status', )
|
||||
|
||||
class Meta:
|
||||
get_latest_by = "created"
|
||||
|
||||
def __unicode__(self):
|
||||
return '%s' % self.title
|
||||
return u'%s' % self.title
|
||||
|
||||
def get_absolute_url(self):
|
||||
return ('helpdesk.views.view_ticket', [str(self.id)])
|
||||
get_absolute_url = permalink(get_absolute_url)
|
||||
get_absolute_url = models.permalink(get_absolute_url)
|
||||
|
||||
def save(self):
|
||||
if not self.id:
|
||||
@ -200,7 +208,7 @@ class FollowUp(models.Model):
|
||||
pass
|
||||
|
||||
def __unicode__(self):
|
||||
return '%s' % self.title
|
||||
return u'%s' % self.title
|
||||
|
||||
|
||||
def save(self):
|
||||
@ -219,7 +227,7 @@ class TicketChange(models.Model):
|
||||
new_value = models.TextField(blank=True, null=True, core=True)
|
||||
|
||||
def __unicode__(self):
|
||||
str = '%s ' % field
|
||||
str = u'%s ' % field
|
||||
if not new_value:
|
||||
str += 'removed'
|
||||
elif not old_value:
|
||||
@ -233,12 +241,24 @@ class TicketChange(models.Model):
|
||||
#file = models.FileField()
|
||||
|
||||
class PreSetReply(models.Model):
|
||||
queues = models.ManyToManyField(Queue, blank=True, null=True)
|
||||
name = models.CharField(max_length=100)
|
||||
""" We can allow the admin to define a number of pre-set replies, used to
|
||||
simplify the sending of updates and resolutions. These are basically Django
|
||||
templates with a limited context - however if yo uwanted to get crafy it would
|
||||
be easy to write a reply that displays ALL updates in hierarchical order etc
|
||||
with use of for loops over {{ ticket.followup_set.all }} and friends.
|
||||
|
||||
When replying to a ticket, the user can select any reply set for the current
|
||||
queue, and the body text is fetched via AJAX."""
|
||||
|
||||
queues = models.ManyToManyField(Queue, blank=True, null=True, help_text='Leave blank to allow this reply to be used for all queues, or select those queues you wish to limit this reply to.')
|
||||
name = models.CharField(max_length=100, help_text='Only used to assist users with selecting a reply - not shown to the user.')
|
||||
body = models.TextField(help_text='Context available: {{ ticket }} - ticket object (eg {{ ticket.title }}); {{ queue }} - The queue; and {{ user }} - the current user.')
|
||||
|
||||
class Admin:
|
||||
pass
|
||||
list_display = ('name',)
|
||||
|
||||
class Meta:
|
||||
ordering = ['name',]
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s' % self.name
|
||||
|
15
views.py
15
views.py
@ -32,15 +32,16 @@ from datetime import datetime
|
||||
# Django imports
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.template import loader, Context, RequestContext
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from django.http import HttpResponseRedirect, Http404, HttpResponse
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db.models import Q
|
||||
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
|
||||
from helpdesk.models import Ticket, Queue, FollowUp, TicketChange, PreSetReply
|
||||
from helpdesk.lib import send_multipart_mail
|
||||
from helpdesk.models import Ticket, Queue, FollowUp, TicketChange, PreSetReply
|
||||
|
||||
def dashboard(request):
|
||||
tickets = Ticket.objects.filter(assigned_to=request.user).exclude(status=Ticket.CLOSED_STATUS)
|
||||
@ -68,6 +69,12 @@ def view_ticket(request, ticket_id):
|
||||
ticket.assigned_to = request.user
|
||||
ticket.save()
|
||||
|
||||
if request.GET.has_key('delete'):
|
||||
if request.method == 'GET':
|
||||
else:
|
||||
ticket.delete()
|
||||
return HttpResponseRedirect(reverse('helpdesk_dashboard'))
|
||||
|
||||
if request.GET.has_key('close') and ticket.status == Ticket.RESOLVED_STATUS:
|
||||
if not ticket.assigned_to:
|
||||
owner = 0
|
||||
|
Loading…
Reference in New Issue
Block a user