diff --git a/CHANGELOG b/CHANGELOG index 6f63438c..b208c928 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,3 +4,8 @@ Add rudimentary CC: functionality on tickets, controlled by staff users. CC's can be e-mail addresses or users, who will receive copies of all emails sent to the Submitter. This is a work in progress. + +2009-09-09 r140 Issue #13 Add Tags to tickets +Patch courtesy of david@zettazebra.com, adds the ability to add tags to +tickets if django-tagging is installed and in use. If django-tagging isn't +being used, no change is visible to the user. diff --git a/forms.py b/forms.py index bf533568..33156796 100644 --- a/forms.py +++ b/forms.py @@ -16,6 +16,7 @@ from django.utils.translation import ugettext as _ from helpdesk.lib import send_templated_mail from helpdesk.models import Ticket, Queue, FollowUp, Attachment, IgnoreEmail, TicketCC +from helpdesk.settings import HAS_TAG_SUPPORT class EditTicketForm(forms.ModelForm): class Meta: @@ -72,6 +73,17 @@ class TicketForm(forms.Form): help_text=_('You can attach a file such as a document or screenshot to this ticket.'), ) + if HAS_TAG_SUPPORT: + tags = forms.CharField( + max_length=255, + required=False, + widget=forms.TextInput(), + label=_('Tags'), + help_text=_('Words, separated by spaces, or phrases separated by commas. ' + 'These should communicate significant characteristics of this ' + 'ticket'), + ) + def save(self, user): """ Writes and returns a Ticket() object @@ -88,6 +100,9 @@ class TicketForm(forms.Form): priority = self.cleaned_data['priority'], ) + if HAS_TAG_SUPPORT: + t.tags = self.cleaned_data['tags'] + if self.cleaned_data['assigned_to']: try: u = User.objects.get(id=self.cleaned_data['assigned_to']) diff --git a/models.py b/models.py index 2ec8da2d..fbeaa3f1 100644 --- a/models.py +++ b/models.py @@ -13,7 +13,10 @@ from django.contrib.auth.models import User from django.db import models from django.conf import settings from django.utils.translation import ugettext_lazy as _ +from helpdesk.settings import HAS_TAG_SUPPORT +if HAS_TAG_SUPPORT: + from tagging.fields import TagField class Queue(models.Model): """ @@ -400,6 +403,9 @@ class Ticket(models.Model): ) staff_url = property(_get_staff_url) + if HAS_TAG_SUPPORT: + tags = TagField(blank=True) + class Meta: get_latest_by = "created" diff --git a/settings.py b/settings.py new file mode 100644 index 00000000..dbbbd3e9 --- /dev/null +++ b/settings.py @@ -0,0 +1,14 @@ + +""" +Default settings for jutda-helpdesk. + +""" + +from django.conf import settings + +# check for django-tagging support +HAS_TAG_SUPPORT = 'tagging' in settings.INSTALLED_APPS +try: + import tagging +except ImportError: + HAS_TAG_SUPPORT = False diff --git a/templates/helpdesk/public_view_ticket.html b/templates/helpdesk/public_view_ticket.html index c9b8dc3a..ea80c8bf 100644 --- a/templates/helpdesk/public_view_ticket.html +++ b/templates/helpdesk/public_view_ticket.html @@ -22,17 +22,24 @@