Remove django-tagging support, as that library is unmaintained. Closes #194.

This commit is contained in:
Ross Poulton 2014-01-29 22:00:00 +11:00
parent 3de2cc42ba
commit d340446feb
8 changed files with 7 additions and 98 deletions

View File

@ -26,11 +26,11 @@ Dependencies (pre-flight checklist)
----------------------------------- -----------------------------------
1. Python 2.5+ 1. Python 2.5+
2. Django (1.3 or newer) 2. Django (1.4 or newer)
3. South for database migrations (highly recommended, but not required). Download from http://south.aeracode.org/ 3. South for database migrations (highly recommended, but not required). Download from http://south.aeracode.org/
4. An existing WORKING Django project with database etc. If you 4. An existing WORKING Django project with database etc. If you
cannot log into the Admin, you won't get this product working. cannot log into the Admin, you won't get this product working.
5. You must have ``django.contrib.markup`` in your ``settings.INSTALLED_APPS`` setting. 5. `pip install django-bootstrap-form` and add `bootstrapform` to `settings.INSTALLED_APPS`
**NOTE REGARDING SQLITE AND SEARCHING:** **NOTE REGARDING SQLITE AND SEARCHING:**
If you use sqlite as your database, the search function will not work as If you use sqlite as your database, the search function will not work as
@ -55,13 +55,6 @@ If you do NOT do this step, and you only want to use English-language templates,
you can continue however you will receive a warning when running the 'migrate' you can continue however you will receive a warning when running the 'migrate'
commands. commands.
Tagging
-------
If you use Django-tagging and want to tag your Helpdesk tickets, ensure that
django-tagging is installed and you have done a ``syncdb`` **before** you
add ``helpdesk`` to your ``INSTALLED_APPS``.
Fresh Django Installations Fresh Django Installations
-------------------------- --------------------------

View File

@ -22,7 +22,6 @@ except ImportError:
from helpdesk.lib import send_templated_mail, safe_template_context from helpdesk.lib import send_templated_mail, safe_template_context
from helpdesk.models import Ticket, Queue, FollowUp, Attachment, IgnoreEmail, TicketCC, CustomField, TicketCustomFieldValue, TicketDependency from helpdesk.models import Ticket, Queue, FollowUp, Attachment, IgnoreEmail, TicketCC, CustomField, TicketCustomFieldValue, TicketDependency
from helpdesk.settings import HAS_TAG_SUPPORT
from helpdesk import settings as helpdesk_settings from helpdesk import settings as helpdesk_settings
class EditTicketForm(forms.ModelForm): class EditTicketForm(forms.ModelForm):
@ -176,17 +175,6 @@ class TicketForm(forms.Form):
help_text=_('You can attach a file such as a document or screenshot to this ticket.'), 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 __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
Add any custom fields that are defined to the form Add any custom fields that are defined to the form
@ -255,9 +243,6 @@ class TicketForm(forms.Form):
due_date = self.cleaned_data['due_date'], due_date = self.cleaned_data['due_date'],
) )
if HAS_TAG_SUPPORT:
t.tags = self.cleaned_data['tags']
if self.cleaned_data['assigned_to']: if self.cleaned_data['assigned_to']:
try: try:
u = User.objects.get(id=self.cleaned_data['assigned_to']) u = User.objects.get(id=self.cleaned_data['assigned_to'])

View File

@ -21,11 +21,6 @@ try:
except ImportError: except ImportError:
from datetime import datetime as timezone from datetime import datetime as timezone
from helpdesk.settings import HAS_TAG_SUPPORT
if HAS_TAG_SUPPORT:
from tagging.fields import TagField
class Queue(models.Model): class Queue(models.Model):
""" """
A queue is a collection of tickets into what would generally be business A queue is a collection of tickets into what would generally be business
@ -445,9 +440,6 @@ class Ticket(models.Model):
return TicketDependency.objects.filter(ticket=self).filter(depends_on__status__in=OPEN_STATUSES).count() == 0 return TicketDependency.objects.filter(ticket=self).filter(depends_on__status__in=OPEN_STATUSES).count() == 0
can_be_resolved = property(_can_be_resolved) can_be_resolved = property(_can_be_resolved)
if HAS_TAG_SUPPORT:
tags = TagField(blank=True)
class Meta: class Meta:
get_latest_by = "created" get_latest_by = "created"

View File

@ -6,12 +6,6 @@ Default settings for django-helpdesk.
from django.conf import settings 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
try: try:
DEFAULT_USER_SETTINGS = settings.HELPDESK_DEFAULT_SETTINGS DEFAULT_USER_SETTINGS = settings.HELPDESK_DEFAULT_SETTINGS
@ -154,3 +148,5 @@ QUEUE_EMAIL_BOX_SSL = getattr(settings, 'QUEUE_EMAIL_BOX_SSL', None)
QUEUE_EMAIL_BOX_HOST = getattr(settings, 'QUEUE_EMAIL_BOX_HOST', None) QUEUE_EMAIL_BOX_HOST = getattr(settings, 'QUEUE_EMAIL_BOX_HOST', None)
QUEUE_EMAIL_BOX_USER = getattr(settings, 'QUEUE_EMAIL_BOX_USER', None) QUEUE_EMAIL_BOX_USER = getattr(settings, 'QUEUE_EMAIL_BOX_USER', None)
QUEUE_EMAIL_BOX_PASSWORD = getattr(settings, 'QUEUE_EMAIL_BOX_PASSWORD', None) QUEUE_EMAIL_BOX_PASSWORD = getattr(settings, 'QUEUE_EMAIL_BOX_PASSWORD', None)
HAS_TAG_SUPPORT = False

View File

@ -186,11 +186,6 @@ function googleTranslateElementInit() {
<dt><label for='id_due_date'>{% trans "Due on" %}</label></dt> <dt><label for='id_due_date'>{% trans "Due on" %}</label></dt>
<dd>{{ form.due_date }}</dd> <dd>{{ form.due_date }}</dd>
{% if tags_enabled %}
<dt><label for='id_tags'>{% trans "Tags" %}</label></dt>
<dd><input type='text' id='id_tags' name='tags' value='{{ ticket.tags }}'/></dd>
{% endif %}
</dl> </dl>
</div> </div>

View File

@ -58,13 +58,6 @@
<td>{{ ticketcc_string }} <strong><a class='tooltip' href='{% url 'helpdesk_ticket_cc' ticket.id %}'>{% trans "Manage" %}<span>{% trans "Click here to add / remove people who should receive an e-mail whenever this ticket is updated." %}</span></a></strong>{% if SHOW_SUBSCRIBE %}, <strong><a class='tooltip' href='?subscribe'>{% trans "Subscribe" %}<span>{% trans "Click here to subscribe yourself to this ticket, if you want to receive an e-mail whenever this ticket is updated." %}</span></a></strong>{% endif %}</td> <td>{{ ticketcc_string }} <strong><a class='tooltip' href='{% url 'helpdesk_ticket_cc' ticket.id %}'>{% trans "Manage" %}<span>{% trans "Click here to add / remove people who should receive an e-mail whenever this ticket is updated." %}</span></a></strong>{% if SHOW_SUBSCRIBE %}, <strong><a class='tooltip' href='?subscribe'>{% trans "Subscribe" %}<span>{% trans "Click here to subscribe yourself to this ticket, if you want to receive an e-mail whenever this ticket is updated." %}</span></a></strong>{% endif %}</td>
</tr> </tr>
{% if tags_enabled %}
<tr class='{% cycle rowcolors %}'>
<th>{% trans "Tags" %}</th>
<td>{{ ticket.tags }}</td>
</tr>
{% endif %}
<tr class='{% cycle rowcolors %}'> <tr class='{% cycle rowcolors %}'>
<th>{% trans "Dependencies" %}</th> <th>{% trans "Dependencies" %}</th>
<td>{% for dep in ticket.ticketdependency.all %} <td>{% for dep in ticket.ticketdependency.all %}

View File

@ -69,9 +69,6 @@ $(document).ready(function() {
<option value='Status'>{% trans "Status" %}</option> <option value='Status'>{% trans "Status" %}</option>
<option value='Keywords'>{% trans "Keywords" %}</option> <option value='Keywords'>{% trans "Keywords" %}</option>
<option value='Dates'>{% trans "Date Range" %}</option> <option value='Dates'>{% trans "Date Range" %}</option>
{% if tags_enabled %}
<option value='Tags'>{% trans "Tags" %}</option>
{% endif %}
</select> </select>
<input type='button' id='filterBuilderButton' value='+' /> <input type='button' id='filterBuilderButton' value='+' />
{% csrf_token %}</form> {% csrf_token %}</form>
@ -137,14 +134,6 @@ $(document).ready(function() {
<input type='button' class='filterBuilderRemove' value='-' /> <input type='button' class='filterBuilderRemove' value='-' />
</div> </div>
{% if tags_enabled %}
<div class='thumbnail filterBox{% if query_params.tags %} filterBoxShow{% endif %}' id='filterBoxTags'>
<label for='id_tags'>{% trans "Tag(s)" %}</label><select id='id_tags' name='tags' multiple='selected' size='5'>{% for t in tag_choices %}<option value='{{t.name}}'{% if t.name|in_list:query_params.tags %} selected='selected'{% endif %}>{{ t.name }}</option>{% endfor %}</select>
<p class='filterHelp'>{% trans "Ctrl-click to select multiple options" %}</p>
<input type='button' class='filterBuilderRemove' value='-' />
</div>
{% endif %}
<div class='thumbnail filterBox{% if query %} filterBoxShow{% endif %}' id='filterBoxKeywords'> <div class='thumbnail filterBox{% if query %} filterBoxShow{% endif %}' id='filterBoxKeywords'>
<label for='id_query'>{% trans "Keywords" %}</label><input type='text' name='q' value='{{ query }}' id='id_query' /> <label for='id_query'>{% trans "Keywords" %}</label><input type='text' name='q' value='{{ query }}' id='id_query' />
<p class='filterHelp'>{% trans "Keywords are case-insensitive, and will be looked for in the title, body and submitter fields." %}</p> <p class='filterHelp'>{% trans "Keywords are case-insensitive, and will be looked for in the title, body and submitter fields." %}</p>
@ -232,7 +221,7 @@ $(document).ready(function() {
<table class="table table-hover table-bordered"> <table class="table table-hover table-bordered">
<thead> <thead>
<tr class='row_tablehead'><td colspan='9'>{% trans "Tickets" %}</td></tr> <tr class='row_tablehead'><td colspan='9'>{% trans "Tickets" %}</td></tr>
<tr class='row_columnheads'><th>#</th><th>&nbsp;</th><th>{% trans "Pr" %}</th><th>{% trans "Title" %}</th><th>{% trans "Queue" %}</th><th>{% trans "Status" %}</th><th>{% trans "Created" %}</th><th>{% trans "Owner" %}</th>{% if tags_enabled %}<th>{% trans "Tags" %}</th>{% endif %}</tr> <tr class='row_columnheads'><th>#</th><th>&nbsp;</th><th>{% trans "Pr" %}</th><th>{% trans "Title" %}</th><th>{% trans "Queue" %}</th><th>{% trans "Status" %}</th><th>{% trans "Created" %}</th><th>{% trans "Owner" %}</th></tr>
</thead> </thead>
<tbody> <tbody>
{% if tickets %}{% for ticket in tickets.object_list %} {% if tickets %}{% for ticket in tickets.object_list %}
@ -245,7 +234,6 @@ $(document).ready(function() {
<td>{{ ticket.get_status }}</td> <td>{{ ticket.get_status }}</td>
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|timesince }} ago</span></td> <td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|timesince }} ago</span></td>
<td>{{ ticket.get_assigned_to }}</td> <td>{{ ticket.get_assigned_to }}</td>
{% if tags_enabled %}<td>{{ ticket.tags }}</td>{% endif %}
</tr> </tr>
{% endfor %}{% else %} {% endfor %}{% else %}
<tr class='row_odd'><td colspan='5'>{% trans "No Tickets Match Your Selection" %}</td></tr> <tr class='row_odd'><td colspan='5'>{% trans "No Tickets Match Your Selection" %}</td></tr>
@ -273,4 +261,4 @@ $(document).ready(function() {
<p><label for='id_mass_action'>{% trans "With Selected Tickets:" %}</label> <select name='action' id='id_mass_action'><option value='take'>{% trans "Take (Assign to me)" %}</option><option value='delete'>{% trans "Delete" %}</option><optgroup label='{% trans "Close" %}'><option value='close'>{% trans "Close (Don't Send E-Mail)" %}</option><option value='close_public'>{% trans "Close (Send E-Mail)" %}</option></optgroup><optgroup label='{% trans "Assign To" %}'><option value='unassign'>{% trans "Nobody (Unassign)" %}</option>{% for u in user_choices %}<option value='assign_{{ u.id }}'>{{ u.username }}</option>{% endfor %}</optgroup></select> <input type='submit' value='Go' /></p> <p><label for='id_mass_action'>{% trans "With Selected Tickets:" %}</label> <select name='action' id='id_mass_action'><option value='take'>{% trans "Take (Assign to me)" %}</option><option value='delete'>{% trans "Delete" %}</option><optgroup label='{% trans "Close" %}'><option value='close'>{% trans "Close (Don't Send E-Mail)" %}</option><option value='close_public'>{% trans "Close (Send E-Mail)" %}</option></optgroup><optgroup label='{% trans "Assign To" %}'><option value='unassign'>{% trans "Nobody (Unassign)" %}</option>{% for u in user_choices %}<option value='assign_{{ u.id }}'>{{ u.username }}</option>{% endfor %}</optgroup></select> <input type='submit' value='Go' /></p>
{% csrf_token %}</form> {% csrf_token %}</form>
{% endblock %} {% endblock %}
</div> </div>

View File

@ -34,12 +34,8 @@ except ImportError:
from helpdesk.forms import TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm, TicketCCForm, EditFollowUpForm, TicketDependencyForm from helpdesk.forms import TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm, TicketCCForm, EditFollowUpForm, TicketDependencyForm
from helpdesk.lib import send_templated_mail, query_to_dict, apply_query, safe_template_context from helpdesk.lib import send_templated_mail, query_to_dict, apply_query, safe_template_context
from helpdesk.models import Ticket, Queue, FollowUp, TicketChange, PreSetReply, Attachment, SavedSearch, IgnoreEmail, TicketCC, TicketDependency from helpdesk.models import Ticket, Queue, FollowUp, TicketChange, PreSetReply, Attachment, SavedSearch, IgnoreEmail, TicketCC, TicketDependency
from helpdesk.settings import HAS_TAG_SUPPORT
from helpdesk import settings as helpdesk_settings from helpdesk import settings as helpdesk_settings
if HAS_TAG_SUPPORT:
from tagging.models import Tag, TaggedItem
if helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE: if helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE:
# treat 'normal' users like 'staff' # treat 'normal' users like 'staff'
staff_member_required = user_passes_test(lambda u: u.is_authenticated() and u.is_active) staff_member_required = user_passes_test(lambda u: u.is_authenticated() and u.is_active)
@ -272,7 +268,6 @@ def view_ticket(request, ticket_id):
'active_users': users, 'active_users': users,
'priorities': Ticket.PRIORITY_CHOICES, 'priorities': Ticket.PRIORITY_CHOICES,
'preset_replies': PreSetReply.objects.filter(Q(queues=ticket.queue) | Q(queues__isnull=True)), 'preset_replies': PreSetReply.objects.filter(Q(queues=ticket.queue) | Q(queues__isnull=True)),
'tags_enabled': HAS_TAG_SUPPORT,
'ticketcc_string': ticketcc_string, 'ticketcc_string': ticketcc_string,
'SHOW_SUBSCRIBE': SHOW_SUBSCRIBE, 'SHOW_SUBSCRIBE': SHOW_SUBSCRIBE,
})) }))
@ -346,7 +341,6 @@ def update_ticket(request, ticket_id, public=False):
else: else:
due_date = timezone.now() due_date = timezone.now()
due_date = due_date.replace(due_date_year, due_date_month, due_date_day) due_date = due_date.replace(due_date_year, due_date_month, due_date_day)
tags = request.POST.get('tags', '')
no_changes = all([ no_changes = all([
not request.FILES, not request.FILES,
@ -356,7 +350,6 @@ def update_ticket(request, ticket_id, public=False):
priority == int(ticket.priority), priority == int(ticket.priority),
due_date == ticket.due_date, due_date == ticket.due_date,
(owner == -1) or (not owner and not ticket.assigned_to) or (owner and User.objects.get(id=owner) == ticket.assigned_to), (owner == -1) or (not owner and not ticket.assigned_to) or (owner and User.objects.get(id=owner) == ticket.assigned_to),
(HAS_TAG_SUPPORT and tags == ticket.tags) or not HAS_TAG_SUPPORT,
]) ])
if no_changes: if no_changes:
return return_to_ticket(request.user, helpdesk_settings, ticket) return return_to_ticket(request.user, helpdesk_settings, ticket)
@ -463,17 +456,6 @@ def update_ticket(request, ticket_id, public=False):
c.save() c.save()
ticket.due_date = due_date ticket.due_date = due_date
if HAS_TAG_SUPPORT:
if tags != ticket.tags:
c = TicketChange(
followup=f,
field=_('Tags'),
old_value=ticket.tags,
new_value=tags,
)
c.save()
ticket.tags = tags
if new_status in [ Ticket.RESOLVED_STATUS, Ticket.CLOSED_STATUS ]: if new_status in [ Ticket.RESOLVED_STATUS, Ticket.CLOSED_STATUS ]:
if new_status == Ticket.RESOLVED_STATUS or ticket.resolution is None: if new_status == Ticket.RESOLVED_STATUS or ticket.resolution is None:
ticket.resolution = comment ticket.resolution = comment
@ -745,7 +727,7 @@ def ticket_list(request):
or request.GET.has_key('q') or request.GET.has_key('q')
or request.GET.has_key('sort') or request.GET.has_key('sort')
or request.GET.has_key('sortreverse') or request.GET.has_key('sortreverse')
or request.GET.has_key('tags') ): ):
# Fall-back if no querying is being done, force the list to only # Fall-back if no querying is being done, force the list to only
# show open/reopened/resolved (not closed) cases sorted by creation # show open/reopened/resolved (not closed) cases sorted by creation
@ -821,13 +803,6 @@ def ticket_list(request):
} }
ticket_qs = apply_query(Ticket.objects.select_related(), query_params) ticket_qs = apply_query(Ticket.objects.select_related(), query_params)
## TAG MATCHING
if HAS_TAG_SUPPORT:
tags = request.GET.getlist('tags')
if tags:
ticket_qs = TaggedItem.objects.get_by_model(ticket_qs, tags)
query_params['tags'] = tags
ticket_paginator = paginator.Paginator(ticket_qs, request.user.usersettings.settings.get('tickets_per_page') or 20) ticket_paginator = paginator.Paginator(ticket_qs, request.user.usersettings.settings.get('tickets_per_page') or 20)
try: try:
page = int(request.GET.get('page', '1')) page = int(request.GET.get('page', '1'))
@ -853,10 +828,6 @@ def ticket_list(request):
querydict = request.GET.copy() querydict = request.GET.copy()
querydict.pop('page', 1) querydict.pop('page', 1)
tag_choices = []
if HAS_TAG_SUPPORT:
# FIXME: restrict this to tags that are actually in use
tag_choices = Tag.objects.all()
return render_to_response('helpdesk/ticket_list.html', return render_to_response('helpdesk/ticket_list.html',
RequestContext(request, dict( RequestContext(request, dict(
@ -866,14 +837,12 @@ def ticket_list(request):
user_choices=User.objects.filter(is_active=True,is_staff=True), user_choices=User.objects.filter(is_active=True,is_staff=True),
queue_choices=Queue.objects.all(), queue_choices=Queue.objects.all(),
status_choices=Ticket.STATUS_CHOICES, status_choices=Ticket.STATUS_CHOICES,
tag_choices=tag_choices,
urlsafe_query=urlsafe_query, urlsafe_query=urlsafe_query,
user_saved_queries=user_saved_queries, user_saved_queries=user_saved_queries,
query_params=query_params, query_params=query_params,
from_saved_query=from_saved_query, from_saved_query=from_saved_query,
saved_query=saved_query, saved_query=saved_query,
search_message=search_message, search_message=search_message,
tags_enabled=HAS_TAG_SUPPORT
))) )))
ticket_list = staff_member_required(ticket_list) ticket_list = staff_member_required(ticket_list)
@ -891,7 +860,6 @@ def edit_ticket(request, ticket_id):
return render_to_response('helpdesk/edit_ticket.html', return render_to_response('helpdesk/edit_ticket.html',
RequestContext(request, { RequestContext(request, {
'form': form, 'form': form,
'tags_enabled': HAS_TAG_SUPPORT,
})) }))
edit_ticket = staff_member_required(edit_ticket) edit_ticket = staff_member_required(edit_ticket)
@ -924,7 +892,6 @@ def create_ticket(request):
return render_to_response('helpdesk/create_ticket.html', return render_to_response('helpdesk/create_ticket.html',
RequestContext(request, { RequestContext(request, {
'form': form, 'form': form,
'tags_enabled': HAS_TAG_SUPPORT,
})) }))
create_ticket = staff_member_required(create_ticket) create_ticket = staff_member_required(create_ticket)