Merge branch 'kotowicz-master'

This commit is contained in:
Ross Poulton 2011-02-03 10:19:33 +00:00
commit 99183ce6a5
3 changed files with 38 additions and 20 deletions

View File

@ -1,4 +1,7 @@
{% load i18n %}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> {% load i18n %}
{% load saved_queries %}
{% with request|saved_queries as user_saved_queries_ %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>{% block helpdesk_title %}Helpdesk{% endblock %} :: {% trans "Powered by django-helpdesk" %}</title> <title>{% block helpdesk_title %}Helpdesk{% endblock %} :: {% trans "Powered by django-helpdesk" %}</title>
@ -36,26 +39,26 @@
<li><a href='{% url helpdesk_list %}'>{% trans "Tickets" %}</a></li> <li><a href='{% url helpdesk_list %}'>{% trans "Tickets" %}</a></li>
<li><a href='{% url helpdesk_submit %}'>{% trans "New Ticket" %}</a></li> <li><a href='{% url helpdesk_submit %}'>{% trans "New Ticket" %}</a></li>
<li><a href='{% url helpdesk_report_index %}'>{% trans "Stats" %}</a></li> <li><a href='{% url helpdesk_report_index %}'>{% trans "Stats" %}</a></li>
{% if user_saved_queries %} {% if user_saved_queries_ %}
<li><a href="#queryloadheader" id="toggle_query">Load Saved Query</a></li> <li><a href="#queryloadheader" id="toggle_query">Load Saved Query</a></li>
{% endif %} {% endif %}
<li><a href='{% url logout %}'>{% trans "Logout" %}</a></li> <li><a href='{% url logout %}'>{% trans "Logout" %}</a></li>
{% if not query %}<li><form id='searchform' method='get' action='{% url helpdesk_list %}'><input type='text' name='q' size='10' class='input' value='{% trans "Search..." %}' id='search_query' onFocus='s=document.getElementById("search_query");if (s.value == "{% trans "Search..." %}") { s.value = ""; }' title='{% trans "Enter a keyword, or a ticket number to jump straight to that ticket." %}'/><input type='hidden' name='status' value='1' /><input type='hidden' name='status' value='2' /><input type='hidden' name='status' value='3' /><input type='hidden' name='search_type' value='header' />{% csrf_token %}</form></li>{% endif %} {% if not query %}<li><form id='searchform' method='get' action='{% url helpdesk_list %}'><input type='text' name='q' size='10' class='input' value='{% trans "Search..." %}' id='search_query' onFocus='s=document.getElementById("search_query");if (s.value == "{% trans "Search..." %}") { s.value = ""; }' title='{% trans "Enter a keyword, or a ticket number to jump straight to that ticket." %}'/><input type='hidden' name='status' value='1' /><input type='hidden' name='status' value='2' /><input type='hidden' name='status' value='3' /><input type='hidden' name='search_type' value='header' />{% csrf_token %}</form></li>{% endif %}
</ul> </ul>
</div> </div>
{% if user_saved_queries %} {% if user_saved_queries_ %}
<div id="queryloadheader" style="float:right; padding: 20px; background:#ECF1EF; "> <div id="queryloadheader" style="float:right; padding: 20px; background:#ECF1EF; ">
<form method='get' action='{% url helpdesk_list %}'> <form method='get' action='{% url helpdesk_list %}'>
<label for='id_query_selector'>{% trans "Query" %}</label> <select name='saved_query' id='id_query_selector' /> <label for='id_query_selector'>{% trans "Query" %}</label> <select name='saved_query' id='id_query_selector' />
{% for q in user_saved_queries %} {% for q in user_saved_queries_ %}
<option value='{{ q.id }}'>{{ q.title }}{% if q.shared %} (Shared{% ifnotequal user q.user %} by {{ q.user.username }}{% endifnotequal %}){% endif %}</option> <option value='{{ q.id }}'>{{ q.title }}{% if q.shared %} (Shared{% ifnotequal user q.user %} by {{ q.user.username }}{% endifnotequal %}){% endif %}</option>
{% endfor %} {% endfor %}
</select> </select>
<input type='submit' value='{% trans "Run Query" %}'> <input type='submit' value='{% trans "Run Query" %}'>
{% csrf_token %}</form> {% csrf_token %}</form>
</div> </div>
{% endif %} {% endif %}
<div id='body'> <div id='body'>
{% block helpdesk_body %}{% endblock %} {% block helpdesk_body %}{% endblock %}
@ -67,3 +70,4 @@
{% include "helpdesk/debug.html" %} {% include "helpdesk/debug.html" %}
</body> </body>
</html> </html>
{% endwith %}

View File

@ -0,0 +1,19 @@
"""
django-helpdesk - A Django powered ticket tracker for small enterprise.
templatetags/saved_queries.py - This template tag returns previously saved
queries. Therefore you don't need to modify
any views.
"""
from django.template import Library
from django.db.models import Q
from helpdesk.models import SavedSearch
def saved_queries(request):
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
return user_saved_queries
register = Library()
register.filter('saved_queries', saved_queries)

View File

@ -74,14 +74,12 @@ def dashboard(request):
ORDER BY q.id; ORDER BY q.id;
""") """)
dash_tickets = query_to_dict(cursor.fetchall(), cursor.description) dash_tickets = query_to_dict(cursor.fetchall(), cursor.description)
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
return render_to_response('helpdesk/dashboard.html', return render_to_response('helpdesk/dashboard.html',
RequestContext(request, { RequestContext(request, {
'user_tickets': tickets, 'user_tickets': tickets,
'unassigned_tickets': unassigned_tickets, 'unassigned_tickets': unassigned_tickets,
'dash_tickets': dash_tickets, 'dash_tickets': dash_tickets,
'user_saved_queries': user_saved_queries,
})) }))
dashboard = staff_member_required(dashboard) dashboard = staff_member_required(dashboard)
@ -135,7 +133,6 @@ def followup_edit(request, ticket_id, followup_id, ):
def view_ticket(request, ticket_id): def view_ticket(request, ticket_id):
ticket = get_object_or_404(Ticket, id=ticket_id) ticket = get_object_or_404(Ticket, id=ticket_id)
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
if request.GET.has_key('take'): if request.GET.has_key('take'):
# Allow the user to assign the ticket to themselves whilst viewing it. # Allow the user to assign the ticket to themselves whilst viewing it.
@ -156,7 +153,6 @@ def view_ticket(request, ticket_id):
'owner': owner, 'owner': owner,
'title': ticket.title, 'title': ticket.title,
'comment': _('Accepted resolution and closed ticket'), 'comment': _('Accepted resolution and closed ticket'),
'user_saved_queries': user_saved_queries,
} }
return update_ticket(request, ticket_id) return update_ticket(request, ticket_id)
@ -168,7 +164,6 @@ def view_ticket(request, ticket_id):
'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, 'tags_enabled': HAS_TAG_SUPPORT,
'user_saved_queries': user_saved_queries,
})) }))
view_ticket = staff_member_required(view_ticket) view_ticket = staff_member_required(view_ticket)