diff --git a/lib.py b/lib.py index 6767511b..5ed56631 100644 --- a/lib.py +++ b/lib.py @@ -279,3 +279,49 @@ def apply_query(queryset, params): queryset = queryset.order_by(params['sorting']) return queryset + + +def safe_template_context(ticket): + """ + Return a dictionary that can be used as a template context to render + comments and other details with ticket or queue paramaters. Note that + we don't just provide the Ticket & Queue objects to the template as + they could reveal confidential information. Just imagine these two options: + * {{ ticket.queue.email_box_password }} + * {{ ticket.assigned_to.password }} + + Ouch! + + The downside to this is that if we make changes to the model, we will also + have to update this code. Perhaps we can find a better way in the future. + """ + + context = { + 'queue': {}, + 'ticket': {}, + } + queue = ticket.queue + + for field in ( 'title', 'slug', 'email_address', 'from_address'): + attr = getattr(queue, field, None) + if callable(attr): + context['queue'][field] = attr() + else: + context['queue'][field] = attr + + for field in ( 'title', 'created', 'modified', 'submitter_email', + 'status', 'get_status_display', 'on_hold', 'description', + 'resolution', 'priority', 'get_priority_display', + 'last_escalation', 'ticket', 'ticket_for_url', + 'get_status', 'ticket_url', 'staff_url', '_get_assigned_to' + ): + attr = getattr(ticket, field, None) + if callable(attr): + context['ticket'][field] = '%s' % attr() + else: + context['ticket'][field] = attr + + context['ticket']['queue'] = context['queue'] + context['ticket']['assigned_to'] = context['ticket']['_get_assigned_to'] + + return context diff --git a/locale/en/LC_MESSAGES/django.mo b/locale/en/LC_MESSAGES/django.mo index e8f5dc08..31ba0448 100644 Binary files a/locale/en/LC_MESSAGES/django.mo and b/locale/en/LC_MESSAGES/django.mo differ diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index 65019906..84630416 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/locale/en/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-08-28 02:50+0000\n" +"POT-Creation-Date: 2008-08-29 05:10+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -54,7 +54,7 @@ msgstr "" #: forms.py:58 models.py:301 management/commands/escalate_tickets.py:152 #: templates/helpdesk/public_view_ticket.html:29 #: templates/helpdesk/ticket.html:67 templates/helpdesk/ticket.html.py:159 -#: templates/helpdesk/ticket_list.html:43 views/staff.py:186 +#: templates/helpdesk/ticket_list.html:43 views/staff.py:192 msgid "Priority" msgstr "" @@ -108,7 +108,7 @@ msgstr "" #: models.py:29 models.py:239 models.py:446 models.py:740 models.py:771 #: templates/helpdesk/dashboard.html:26 templates/helpdesk/dashboard.html:41 #: templates/helpdesk/ticket.html:153 templates/helpdesk/ticket_list.html:40 -#: templates/helpdesk/ticket_list.html:115 views/staff.py:176 +#: templates/helpdesk/ticket_list.html:115 views/staff.py:182 msgid "Title" msgstr "" @@ -378,7 +378,7 @@ msgid "" msgstr "" #: models.py:321 templates/helpdesk/ticket.html:58 views/feeds.py:91 -#: views/feeds.py:117 views/feeds.py:171 views/staff.py:153 +#: views/feeds.py:117 views/feeds.py:171 views/staff.py:159 msgid "Unassigned" msgstr "" @@ -390,7 +390,7 @@ msgstr "" msgid "Date" msgstr "" -#: models.py:453 views/staff.py:167 +#: models.py:453 views/staff.py:173 msgid "Comment" msgstr "" @@ -1079,8 +1079,8 @@ msgstr "" #: templates/helpdesk/ticket.html:119 msgid "" -"You can use the {{ ticket }} and {{ queue }} template variables in your " -"message." +"You can insert ticket and queue details in your message. For more " +"information, see the context help page." msgstr "" #: templates/helpdesk/ticket.html:142 @@ -1289,19 +1289,19 @@ msgstr "" msgid "Accepted resolution and closed ticket" msgstr "" -#: views/staff.py:147 +#: views/staff.py:153 #, python-format msgid "Assigned to %(username)s" msgstr "" -#: views/staff.py:169 +#: views/staff.py:175 msgid "Updated" msgstr "" -#: views/staff.py:401 +#: views/staff.py:422 msgid "Ticket taken off hold" msgstr "" -#: views/staff.py:404 +#: views/staff.py:425 msgid "Ticket placed on hold" msgstr "" diff --git a/templates/helpdesk/api_help.html b/templates/helpdesk/help_api.html similarity index 92% rename from templates/helpdesk/api_help.html rename to templates/helpdesk/help_api.html index e2f97ac9..bdbd9186 100644 --- a/templates/helpdesk/api_help.html +++ b/templates/helpdesk/help_api.html @@ -1,46 +1,9 @@ - - - - Jutda Helpdesk API Documentation - - -

Jutda Helpdesk API Documentation

+{% block title %}Jutda Helpdesk API Documentation{% endblock %} +{% block heading %}Jutda Helpdesk API Documentation{% endblock %} +{% block content %}

Contents