Merge pull request #10 from django-helpdesk/master

update
This commit is contained in:
Tom Weber 2021-02-09 12:56:17 -07:00 committed by GitHub
commit e52471b49b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 287 additions and 290 deletions

File diff suppressed because it is too large Load Diff

View File

@ -83,6 +83,12 @@ class CustomFieldMixin(object):
class EditTicketForm(CustomFieldMixin, forms.ModelForm):
merged_to = forms.ModelChoiceField(
label=_('Merged to'),
help_text=_('This ticket is merged into the selected ticket.'),
queryset=Ticket.objects.all(),
disabled=True
)
class Meta:
model = Ticket

View File

@ -1,4 +1,4 @@
from celery import task
from celery.decorators import task
from .email import process_email

View File

@ -1,58 +1,52 @@
{% extends "helpdesk/base.html" %}{% load i18n bootstrap4form %}
{% extends "helpdesk/base.html" %}
{% load i18n bootstrap4form %}
{% block helpdesk_title %}{% trans "Edit Ticket" %}{% endblock %}
{% block helpdesk_breadcrumb %}
<li class="breadcrumb-item">
<a href="{% url 'helpdesk:list' %}">{% trans "Tickets" %}</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'helpdesk:list' %}{{ ticket.id }}/">{{ ticket.queue.slug }}-{{ ticket.id }}</a>
</li>
<li class="breadcrumb-item active">{% trans "Edit Ticket" %}</li>
<li class="breadcrumb-item">
<a href="{% url 'helpdesk:list' %}">{% trans "Tickets" %}</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'helpdesk:list' %}{{ ticket.id }}/">{{ ticket.queue.slug }}-{{ ticket.id }}</a>
</li>
<li class="breadcrumb-item active">{% trans "Edit Ticket" %}</li>
{% endblock %}
{% block helpdesk_body %}
<div class="col-xs-6">
<div class="panel panel-default">
<div class="panel-body"><h2>{% trans "Edit a Ticket" %}</h2>
<p>{% trans "Unless otherwise stated, all fields are required." %} {% trans "Please provide as descriptive a title and description as possible." %}</p>
<p><strong>{% trans "Note" %}:</strong> {% blocktrans %}Editing a ticket does <em>not</em> send an e-mail to the ticket owner or submitter. No new details should be entered, this form should only be used to fix incorrect details or clean up the submission.{% endblocktrans %}</p>
<form method='post' action='./'>
<fieldset>
{{ form|bootstrap4form }}
{% comment %}
{% for field in form %}
{% if field.is_hidden %}
{{ field }}
{% else %}
<dt><label for='id_{{ field.name }}'>{{ field.label }}</label>{% if not field.field.required %} <span class='form_optional'>{% trans "(Optional)" %}</span>{% endif %}</dt>
<dd>{{ field }}</dd>
{% if field.errors %}<dd class='error'>{{ field.errors }}</dd>{% endif %}
{% if field.help_text %}<dd class='form_help_text'>{{ field.help_text }}</dd>{% endif %}</label>
{% endif %}
{% endfor %}
</dl>
{% endcomment %}
<div class='buttons form-group'>
<input type='submit' class="btn btn-primary btn-sm" value='{% trans "Save Changes" %}' />
<a href='{{ ticket.get_absolute_url }}'><button class="btn btn-danger">{% trans "Cancel Changes" %}</button></a>
<div class="col-xs-6">
<div class="panel panel-default">
<div class="panel-body"><h2>{% trans "Edit a Ticket" %}</h2>
<p>
{% trans "Unless otherwise stated, all fields are required." %}
{% trans "Please provide as descriptive a title and description as possible." %}
</p>
<p>
<strong>{% trans "Note" %}:</strong>
{% blocktrans %}Editing a ticket does <em>not</em> send an e-mail to the ticket owner or submitter. No new details should be entered, this form should only be used to fix incorrect details or clean up the submission.{% endblocktrans %}
</p>
<form method='post'>
{% csrf_token %}
<fieldset>
{{ form|bootstrap4form }}
<div class='buttons form-group'>
<input type='submit' class="btn btn-primary btn-sm" value='{% trans "Save Changes" %}'/>
<a href='{{ ticket.get_absolute_url }}'>
<button class="btn btn-danger">{% trans "Cancel Changes" %}</button>
</a>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</fieldset>
{% csrf_token %}</form>
</div>
</div>
</div>
<script>
$( function() {
$( "#id_due_date" ).datepicker({dateFormat: 'yy-mm-dd'});
} );
</script>
{% endblock %}
{% block helpdesk_js %}
<script>
$(() => {
$("#id_due_date").datepicker({dateFormat: 'yy-mm-dd'});
})
</script>
{% endblock %}

View File

@ -25,7 +25,7 @@
<td>{{ ticket.priority }}</td>
<td>{{ ticket.queue }}</td>
<td>{{ ticket.get_status }}</td>
<td><span title='{{ ticket.modified|date }}'>{{ ticket.modified|naturaltime }}</span></td>
<td><span title='{{ ticket.modified|date:"DATETIME_FORMAT" }}'>{{ ticket.modified|naturaltime }}</span></td>
</tr>
{% empty %}
<tr>{% if ticket_list_empty_message %}<td colspan='6'>{{ ticket_list_empty_message }}</td>{% else %}<td colspan='6'>{% trans "You do not have any pending tickets." %}</td>{% endif %}</tr>

View File

@ -23,7 +23,7 @@
<td class="tickettitle"><a href='{{ ticket.get_absolute_url }}'>{{ ticket.id }}. {{ ticket.title }} </a></td>
<td>{{ ticket.priority }}</td>
<td>{{ ticket.queue }}</td>
<td><span title='{{ ticket.created|date:"r" }}'>{{ ticket.created|naturaltime }}</span></td>
<td><span title='{{ ticket.created|date:"DATETIME_FORMAT" }}'>{{ ticket.created|naturaltime }}</span></td>
<td class="text-center">
<a href='{{ ticket.get_absolute_url }}?take'><button class='btn btn-primary btn-sm'><i class="fas fa-hand-paper"></i>&nbsp;{% trans "Take" %}</button></a>
<a href='{% url 'helpdesk:delete' ticket.id %}?next=dashboard'><button class='btn btn-danger btn-sm'><i class="fas fa-trash"></i>&nbsp;{% trans "Delete" %}</button></a>
@ -63,7 +63,7 @@
<td class="tickettitle"><a href='{{ ticket.get_absolute_url }}'>{{ ticket.id }}. {{ ticket.title }} </a></td>
<td>{{ ticket.priority }}</td>
<td>{{ ticket.queue }}</td>
<td><span title='{{ ticket.created|date }}'>{{ ticket.created|naturaltime }}</span></td>
<td><span title='{{ ticket.created|date:"DATETIME_FORMAT" }}'>{{ ticket.created|naturaltime }}</span></td>
<td class="text-center">
<a href='{{ ticket.get_absolute_url }}?take'><button class='btn btn-primary btn-sm'><i class="fas fa-hand-paper"></i>&nbsp;{% trans "Take" %}</button></a>
<a href='{% url 'helpdesk:delete' ticket.id %}?next=dashboard'><button class='btn btn-danger btn-sm'><i class="fas fa-trash"></i>&nbsp;{% trans "Delete" %}</button></a>

View File

@ -36,7 +36,7 @@
{% endif %}
<a href='{% if iframe %}{% url 'helpdesk:submit_iframe' %}{% else %}{% url 'helpdesk:submit' %}{%endif%}?{% if category.queue %}queue={{category.queue.pk}};_readonly_fields_=queue;{%endif%}kbitem={{item.id}};{{query_param_string}}' class="col-sm">
<div class="btn btn-success btn-circle btn-xl float-right"><i class="fa fa-envelope fa-lg"></i> {% trans 'Contact a human' %}</div>
<div class="btn btn-success btn-circle btn-xl float-right"><i class="fa fa-plus-circle fa-lg"></i> {% trans 'Create New Ticket' %}{% trans " Queue: " %}{{item}}</div>
</a>
</div>
<div>
@ -57,7 +57,7 @@
{% if category.queue %}
<a href='{% if iframe %}{% url 'helpdesk:submit_iframe' %}{% else %}{% url 'helpdesk:submit' %}{%endif%}?queue={{category.queue.pk}};_readonly_fields_=queue;{{query_param_string}}'>
{% block submit_button %}
<div class="btn btn-danger btn-circle btn-xl float-right"><i class="fa fa-envelope fa-lg"></i> {% trans 'Contact a human' %}</div>
<div class="btn btn-danger btn-circle btn-xl float-right"><i class="fa fa-plus-circle fa-lg"></i> {% trans 'Create New Ticket' %}{% if category.queue %}{% trans " Queue: " %}{{category.queue}}{% endif %}</div>
{% endblock %}
</a>
{% endif %}

View File

@ -12,13 +12,13 @@
<tbody>
<tr>
<th>{% trans "Submitted On" %}</th>
<td>{{ ticket.created|date }} ({{ ticket.created|naturaltime }})</td>
<td>{{ ticket.created|date:"DATETIME_FORMAT" }} ({{ ticket.created|naturaltime }})</td>
</tr>
{% if ticket.due_date %}
<tr>
<th>{% trans "Due On" %}</th>
<td>{{ ticket.due_date|date }} ({{ ticket.due_date|naturaltime }})</td>
<td>{{ ticket.due_date|date:"DATETIME_FORMAT" }} ({{ ticket.due_date|naturaltime }})</td>
</tr>
{% endif %}
@ -67,7 +67,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 }}'>{{ followup.date|naturaltime }}</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:"DATETIME_FORMAT" }}'>{{ 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

@ -46,7 +46,7 @@
<div class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">{{ followup.title|num_to_link }}</h5>
<small><i class="fas fa-clock"></i>&nbsp;<span class='byline text-info'>{% if followup.user %}by {{ followup.user }},{% endif %} <span title='{{ followup.date|date }}'>{{ followup.date|naturaltime }}</span>{% if followup.time_spent %}, <span>{% trans "time spent" %}: {{ followup.time_spent_formated }}</span>{% endif %} {% if not followup.public %} <span class='private'>({% trans "Private" %})</span>{% endif %}</span></small>
<small><i class="fas fa-clock"></i>&nbsp;<span class='byline text-info'>{% if followup.user %}by {{ followup.user }},{% endif %} <span title='{{ followup.date|date:"DATETIME_FORMAT" }}'>{{ followup.date|naturaltime }}</span>{% if followup.time_spent %}, <span>{% trans "time spent" %}: {{ followup.time_spent_formated }}</span>{% endif %} {% if not followup.public %} <span class='private'>({% trans "Private" %})</span>{% endif %}</span></small>
</div>
<p class="mb-1">
{% if followup.comment %}

View File

@ -33,15 +33,15 @@
<tr>
<th class="table-active">{% trans "Assigned To" %}</th>
<td>{{ ticket.get_assigned_to }}{% ifequal ticket.get_assigned_to _('Unassigned') %} <strong>
<a href='?take'><button type="button" class="btn btn-primary btn-sm float-right"><i class="fas fa-hand-paper"></i></button></a>
<a data-toggle="tooltip" href='?take' title='{% trans "Assign this ticket to " %}{{ request.user.email }}'><button type="button" class="btn btn-primary btn-sm float-right"><i class="fas fa-hand-paper"></i></button></a>
</strong>{% endifequal %}
</td>
<th class="table-active">{% trans "Submitter E-Mail" %}</th>
<td> {{ ticket.submitter_email }}
{% if user.is_superuser %} {% if submitter_userprofile_url %}<strong><a href='{{submitter_userprofile_url}}'><button type="button" class="btn btn-primary btn-sm"><i class="fas fa-address-book"></i></button></a></strong>{% endif %}
<strong><a href ="{% url 'helpdesk:list'%}?q={{ticket.submitter_email}}">
{% if user.is_superuser %} {% if submitter_userprofile_url %}<strong><a data-toggle="tooltip" href='{{submitter_userprofile_url}}' title='{% trans "Edit " %}{{ ticket.submitter_email }}{% trans " user profile" %}'><button type="button" class="btn btn-primary btn-sm"><i class="fas fa-address-book"></i></button></a></strong>{% endif %}
<strong><a data-toggle="tooltip" href ="{% url 'helpdesk:list'%}?q={{ticket.submitter_email}}" title='{% trans "Display tickets filtered for " %}{{ ticket.submitter_email }}{% trans " as a keyword" %}'>
<button type="button" class="btn btn-primary btn-sm"><i class="fas fa-search"></i></button></a></strong>
<strong><a href='{% url 'helpdesk:email_ignore_add' %}?email={{ ticket.submitter_email }}'>
<strong><a data-toggle="tooltip" href='{% url 'helpdesk:email_ignore_add' %}?email={{ ticket.submitter_email }}' title='{% trans "Add email address for the ticket system to ignore." %}'>
<button type="button" class="btn btn-warning btn-sm float-right"><i class="fas fa-eye-slash"></i></button></a></strong>{% endif %}
</td>
</tr>

View File

@ -1213,13 +1213,10 @@ def edit_ticket(request, ticket_id):
ticket = get_object_or_404(Ticket, id=ticket_id)
ticket_perm_check(request, ticket)
if request.method == 'POST':
form = EditTicketForm(request.POST, instance=ticket)
if form.is_valid():
ticket = form.save()
return HttpResponseRedirect(ticket.get_absolute_url())
else:
form = EditTicketForm(instance=ticket)
form = EditTicketForm(request.POST or None, instance=ticket)
if form.is_valid():
ticket = form.save()
return redirect(ticket)
return render(request, 'helpdesk/edit_ticket.html', {'form': form, 'ticket': ticket})