use naturaltime for elapsed times (resolves #229)

This commit is contained in:
Stefano Brentegani 2014-07-21 10:21:33 +02:00
parent 21e46f010d
commit fd0ab29dfc
8 changed files with 43 additions and 41 deletions

View File

@ -36,11 +36,12 @@ Adding To Your Django Project
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin', # Required for helpdesk admin/maintenance
'django.contrib.markup', # Required for helpdesk text display
'south', # Highly recommended to make database migrations simpler.
'markdown_deux', # Required for Knowledgebase item formatting
'helpdesk', # This is new!
'django.contrib.admin', # Required for helpdesk admin/maintenance
'django.contrib.markup', # Required for helpdesk text display
'django.contrib.humanize', # Required for elapsed time formatting
'south', # Highly recommended to make database migrations simpler.
'markdown_deux', # Required for Knowledgebase item formatting
'helpdesk', # This is new!
)
2. Make sure django-helpdesk is accessible via ``urls.py``. Add the following line to ``urls.py``::

View File

@ -1,4 +1,4 @@
{% extends "helpdesk/base.html" %}{% load i18n %}{% load url from future %}
{% extends "helpdesk/base.html" %}{% load i18n humanize %}{% load url from future %}
{% block helpdesk_title %}{% trans "Helpdesk Dashboard" %}{% endblock %}
{% block helpdesk_head %}
<script type='text/javascript' language='javascript' src='{{ STATIC_URL }}helpdesk/hover.js'></script>
@ -65,7 +65,7 @@
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status }}</td>
<td><span title='{{ ticket.modified|date:"r" }}'>{{ ticket.modified|timesince }}</span></td>
<td><span title='{{ ticket.modified|date:"r" }}'>{{ ticket.modified|naturaltime }}</span></td>
</tr>
{% endfor %}
</tbody>
@ -85,7 +85,7 @@
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status }}</td>
<td><span title='{{ ticket.modified|date:"r" }}'>{{ ticket.modified|timesince }}</span></td>
<td><span title='{{ ticket.modified|date:"r" }}'>{{ ticket.modified|naturaltime }}</span></td>
</tr>
{% endfor %}
{% if not user_tickets %}
@ -106,7 +106,7 @@
<td>{{ ticket.get_priority_span }}</td>
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|timesince }} ago</span></td>
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|naturaltime }}</span></td>
<th><a href='{{ ticket.get_absolute_url }}?take'><span class='button button_take'>{% trans "Take" %}</span></a> | <a href='{% url 'helpdesk_delete' ticket.id %}'><span class='button button_delete'>{% trans "Delete" %}</span></a></th>
</tr>
{% endfor %}
@ -131,7 +131,7 @@
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status }}</td>
<td><span title='{{ ticket.modified|date:"r" }}'>{{ ticket.modified|timesince }}</span></td>
<td><span title='{{ ticket.modified|date:"r" }}'>{{ ticket.modified|naturaltime }}</span></td>
</tr>
{% endfor %}
</tbody>

View File

@ -1,4 +1,4 @@
{% extends "helpdesk/public_base.html" %}{% load i18n %}
{% extends "helpdesk/public_base.html" %}{% load i18n humanize %}
{% block helpdesk_body %}
<h2>{% blocktrans with category.title as kbcat %}Knowledgebase Category: {{ kbcat }}{% endblocktrans %}</h2>
@ -14,7 +14,7 @@
</thead>
<tbody>
{% for item in items %}
<tr class='row_even row_hover'><th><a href='{{ item.get_absolute_url }}'>{{ item.title }}</a></th><td>Rating: {{ item.score }}</td><td>Last Update: {{ item.last_updated|timesince }} ago</td></tr>
<tr class='row_even row_hover'><th><a href='{{ item.get_absolute_url }}'>{{ item.title }}</a></th><td>Rating: {{ item.score }}</td><td>Last Update: {{ item.last_updated|naturaltime }}</td></tr>
<tr class='row_odd'><td colspan='3'>{{ item.question }}</td></tr>
{% endfor %}
</tbody>

View File

@ -1,4 +1,4 @@
{% extends "helpdesk/public_base.html" %}{% load i18n %}
{% extends "helpdesk/public_base.html" %}{% load i18n humanize %}
{% block helpdesk_title %}{% trans "View a Ticket" %}{% endblock %}
{% block helpdesk_body %}
@ -11,7 +11,7 @@
<tbody>
<tr class="{% cycle 'row_odd' 'row_even' as rowcolors %}">
<th>{% trans "Submitted On" %}</th>
<td>{{ ticket.created|date:"r" }} ({{ ticket.created|timesince }} ago)</td>
<td>{{ ticket.created|date:"r" }} ({{ ticket.created|naturaltime }})</td>
</tr>
<tr class='{% cycle rowcolors %}'>
@ -58,7 +58,7 @@
{% load ticket_to_link %}
{% for followup in ticket.followup_set.public_followups %}
<div class='followup well'>
<div class='title'>{{ followup.title }} <span class='byline text-info'>{% if followup.user %}by {{ followup.user }}{% endif %} <span title='{{ followup.date|date:"r" }}'>{{ followup.date|timesince }} ago</span></span></div>
<div class='title'>{{ followup.title }} <span class='byline text-info'>{% if followup.user %}by {{ followup.user }}{% endif %} <span title='{{ followup.date|date:"r" }}'>{{ followup.date|naturaltime }}</span></span></div>
{{ followup.comment|force_escape|urlizetrunc:50|num_to_link|linebreaksbr }}
{% if followup.ticketchange_set.all %}<div class='changes'><ul>
{% for change in followup.ticketchange_set.all %}

View File

@ -1,4 +1,4 @@
{% extends "helpdesk/base.html" %}{% load i18n bootstrap %}{% load url from future %}
{% extends "helpdesk/base.html" %}{% load i18n bootstrap humanize %}{% load url from future %}
{% block helpdesk_title %}{% trans "View Ticket Details" %}{% endblock %}
{% block helpdesk_head %}
<script type="text/javascript">
@ -69,7 +69,7 @@ function googleTranslateElementInit() {
{% if helpdesk_settings.HELPDESK_FOLLOWUP_MOD %}
<div class='followup_mod'>
<div class='title'>
<span class='byline text-info'>{{ followup.user.get_full_name }}&nbsp;&nbsp;&nbsp;&nbsp;{{ followup.date }} ({{ followup.date|timesince }} ago)</span> <small>{{ followup.title }}</small>
<span class='byline text-info'>{{ followup.user.get_full_name }}&nbsp;&nbsp;&nbsp;&nbsp;{{ followup.date }} ({{ followup.date|naturaltime }})</span> <small>{{ followup.title }}</small>
{% if not followup.public %} <span class='private'>({% trans "Private" %})</span>{% endif %}
{% if helpdesk_settings.HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP %}
{% if followup.user and request.user == followup.user and not followup.ticketchange_set.all %}
@ -83,7 +83,7 @@ function googleTranslateElementInit() {
{% else %}
<div class='followup well'>
<div class='title'>
{{ followup.title }} <span class='byline text-info'>{% if followup.user %}by {{ followup.user }}{% endif %} <span title='{{ followup.date|date:"r" }}'>{{ followup.date|timesince }} ago</span>{% if not followup.public %} <span class='private'>({% trans "Private" %})</span>{% endif %}</span>
{{ followup.title }} <span class='byline text-info'>{% if followup.user %}by {{ followup.user }}{% endif %} <span title='{{ followup.date|date:"r" }}'>{{ followup.date|naturaltime }}</span>{% if not followup.public %} <span class='private'>({% trans "Private" %})</span>{% endif %}</span>
{% if helpdesk_settings.HELPDESK_SHOW_EDIT_BUTTON_FOLLOW_UP %}
{% if followup.user and request.user == followup.user and not followup.ticketchange_set.all %}
<a href="{% url 'helpdesk_followup_edit' ticket.id followup.id %}" class='followup-edit'><img width="60" height="15" title="Edit" alt="Edit" src="{{ STATIC_URL }}helpdesk/buttons/edit.png"></a>

View File

@ -1,4 +1,4 @@
{% load i18n %}{% load url from future %}
{% load i18n humanize %}{% load url from future %}
<table class="table table-hover table-bordered">
<thead>
<tr class='row_tablehead'><td colspan='2'><h3>{{ ticket.id }}. {{ ticket.title }} [{{ ticket.get_status }}]</h3> <span class='ticket_toolbar'>
@ -30,7 +30,7 @@
</tr>{% endif %}
<tr class='{% cycle rowcolors %}'>
<th>{% trans "Submitted On" %}</th>
<td>{{ ticket.created|date:"r" }} ({{ ticket.created|timesince }} ago)</td>
<td>{{ ticket.created|date:"r" }} ({{ ticket.created|naturaltime }})</td>
</tr>
<tr class='{% cycle rowcolors %}'>

View File

@ -1,4 +1,4 @@
{% extends "helpdesk/base.html" %}{% load i18n %}{% load url from future %}
{% extends "helpdesk/base.html" %}{% load i18n humanize %}{% load url from future %}
{% block helpdesk_title %}{% trans "Tickets" %}{% endblock %}
{% block helpdesk_head %}
@ -232,7 +232,7 @@ $(document).ready(function() {
<th><a href='{{ ticket.get_absolute_url }}'>{{ ticket.title }}</a></th>
<td>{{ ticket.queue }}</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|naturaltime }}</span></td>
<td>{{ ticket.get_assigned_to }}</td>
</tr>
{% endfor %}{% else %}

View File

@ -22,6 +22,7 @@ class QuickDjangoTest(object):
'django.contrib.admin',
'django.contrib.staticfiles',
'django.contrib.messages',
'django.contrib.humanize',
'bootstrapform',
)