mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-11 12:16:40 +02:00
last followups show in all tickets but cant be sorted by
This commit is contained in:
parent
3a33f7fef9
commit
921d424239
@ -34,6 +34,7 @@ def ticket_template_context(ticket):
|
||||
else:
|
||||
context[field] = attr
|
||||
context['assigned_to'] = context['_get_assigned_to']
|
||||
context['last_followup'] = ticket.followups.latest('date')
|
||||
|
||||
return context
|
||||
|
||||
|
@ -65,8 +65,9 @@ DATATABLES_ORDER_COLUMN_CHOICES = Choices(
|
||||
('6', 'due_date'),
|
||||
('7', 'assigned_to'),
|
||||
('8', 'submitter_email'),
|
||||
# ('9', 'time_spent'),
|
||||
('10', 'kbitem'),
|
||||
('9', 'last_followup'),
|
||||
# ('10', 'time_spent'),
|
||||
('11', 'kbitem'),
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.humanize.templatetags import humanize
|
||||
from django.utils.timezone import localtime
|
||||
from rest_framework import serializers
|
||||
from rest_framework.exceptions import ValidationError
|
||||
|
||||
@ -18,6 +19,7 @@ class DatatablesTicketSerializer(serializers.ModelSerializer):
|
||||
ticket = serializers.SerializerMethodField()
|
||||
assigned_to = serializers.SerializerMethodField()
|
||||
submitter = serializers.SerializerMethodField()
|
||||
last_followup = serializers.SerializerMethodField()
|
||||
created = serializers.SerializerMethodField()
|
||||
due_date = serializers.SerializerMethodField()
|
||||
status = serializers.SerializerMethodField()
|
||||
@ -30,8 +32,8 @@ class DatatablesTicketSerializer(serializers.ModelSerializer):
|
||||
model = Ticket
|
||||
# fields = '__all__'
|
||||
fields = ('ticket', 'id', 'priority', 'title', 'queue', 'status',
|
||||
'created', 'due_date', 'assigned_to', 'submitter', 'row_class',
|
||||
'time_spent', 'kbitem')
|
||||
'created', 'due_date', 'assigned_to', 'submitter', 'last_followup',
|
||||
'row_class', 'time_spent', 'kbitem')
|
||||
|
||||
def get_queue(self, obj):
|
||||
return {"title": obj.queue.title, "id": obj.queue.id}
|
||||
@ -70,8 +72,11 @@ class DatatablesTicketSerializer(serializers.ModelSerializer):
|
||||
|
||||
def get_kbitem(self, obj):
|
||||
return obj.kbitem.title if obj.kbitem else ""
|
||||
|
||||
|
||||
|
||||
def get_last_followup(self, obj):
|
||||
followup = obj.followup_set.latest('date')
|
||||
return localtime(followup.date).strftime('%Y-%m-%d %H:%M:%S') if followup else ""
|
||||
|
||||
class FollowUpAttachmentSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = FollowUpAttachment
|
||||
|
20
helpdesk/templates/helpdesk/filters/followupdates.html
Normal file
20
helpdesk/templates/helpdesk/filters/followupdates.html
Normal file
@ -0,0 +1,20 @@
|
||||
{% load i18n humanize %}
|
||||
<div class="form-row">
|
||||
<div class="col col-sm-3">
|
||||
<label for='id_followup_from'>{% trans "Date (From)" %}</label>
|
||||
</div>
|
||||
<div class="col col-sm-3">
|
||||
<input type='text' name='followup_from' value='{{ query_params.filtering.followup__gte }}' id='id_followup_from' />
|
||||
</div>
|
||||
<div class="col col-sm-2">
|
||||
<label for='id_followup_to'>{% trans "Date (To)" %}</label>
|
||||
</div>
|
||||
<div class="col col-sm-3">
|
||||
<input type='text' name='followup_to' value='{{ query_params.filtering.followup__lte }}' id='id_followup_to' />
|
||||
</div>
|
||||
<div class="col col-sm-1">
|
||||
<button class='float-right filterBuilderRemove btn btn-danger btn-sm'><i class="fas fa-trash-alt"></i></button>
|
||||
</div>
|
||||
|
||||
<p class='filterHelp'>{% trans "Use YYYY-MM-DD date format, eg 2018-01-30. This only searches when the last followup occured" %}</p>
|
||||
</div>
|
@ -76,6 +76,7 @@
|
||||
<th>{% trans "Due Date" %}</th>
|
||||
<th>{% trans "Owner" %}</th>
|
||||
<th>{% trans "Submitter" %}</th>
|
||||
<th>{% trans "Last Followup" %}</th>
|
||||
{% if helpdesk_settings.HELPDESK_ENABLE_TIME_SPENT_ON_TICKET %}<th>{% trans "Time Spent" %}</th>{% endif %}
|
||||
{% if helpdesk_settings.HELPDESK_KB_ENABLED %}<th>{% trans "KB item" %}</th>{% endif %}
|
||||
</tr>
|
||||
@ -188,6 +189,9 @@
|
||||
<option id="filterBuilderSelect-KBItems" value="KBItems"{% if query_params.filtering.kbitem__in or query_params.filtering_null.kbitem__isnull %} disabled{% endif %}>
|
||||
{% trans "Knowledge base items" %}
|
||||
</option>
|
||||
<option id="filterBuilderSelect-Followup" value="Followup"{% if query_params.filtering.followup__gte or query_params.filtering.followup__lte %} disabled{% endif %}>
|
||||
{% trans "Last Followup" %}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
@ -224,6 +228,10 @@
|
||||
id="filterBoxKBItems">
|
||||
{% include 'helpdesk/filters/kbitems.html' %}
|
||||
</li>
|
||||
<li class="list-group-item filterBox{% if query_params.filtering.followup__gte or query_params.filtering.followup__lte %} filterBoxShow{% endif %}"
|
||||
id='filterBoxFollowupDates'>
|
||||
{% include 'helpdesk/filters/followupdates.html' %}
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<input class="btn btn-primary btn-sm" type='submit' value='{% trans "Apply Filters" %}'/>
|
||||
</li>
|
||||
@ -415,6 +423,15 @@
|
||||
}
|
||||
},
|
||||
{data: "submitter"},
|
||||
{
|
||||
data: "last_followup",
|
||||
render: function (data, type, row, meta) {
|
||||
if (data && data !== "None") {
|
||||
return data;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
},
|
||||
{% if helpdesk_settings.HELPDESK_ENABLE_TIME_SPENT_ON_TICKET %}
|
||||
{data: "time_spent", "visible": false},
|
||||
{% endif %}
|
||||
|
@ -1025,12 +1025,14 @@ def ticket_list(request):
|
||||
('assigned_to', 'assigned_to__id__in'),
|
||||
('status', 'status__in'),
|
||||
('kbitem', 'kbitem__in'),
|
||||
('last_followup', 'last_followup__in'),
|
||||
]
|
||||
filter_null_params = dict([
|
||||
('queue', 'queue__id__isnull'),
|
||||
('assigned_to', 'assigned_to__id__isnull'),
|
||||
('status', 'status__isnull'),
|
||||
('kbitem', 'kbitem__isnull'),
|
||||
('last_followup', 'last_followup__isnull'),
|
||||
])
|
||||
for param, filter_command in filter_in_params:
|
||||
if request.GET.get(param) is not None:
|
||||
@ -1061,6 +1063,14 @@ def ticket_list(request):
|
||||
if date_to:
|
||||
query_params['filtering']['created__lte'] = date_to
|
||||
|
||||
followup_from = request.GET.get('followup_from')
|
||||
if followup_from:
|
||||
query_params['filtering']['followup__gte'] = followup_from
|
||||
|
||||
followup_to = request.GET.get('followup_to')
|
||||
if followup_to:
|
||||
query_params['filtering']['followup__lte'] = followup_to
|
||||
|
||||
# KEYWORD SEARCHING
|
||||
q = request.GET.get('q', '')
|
||||
context['query'] = q
|
||||
@ -1068,7 +1078,7 @@ def ticket_list(request):
|
||||
|
||||
# SORTING
|
||||
sort = request.GET.get('sort', None)
|
||||
if sort not in ('status', 'assigned_to', 'created', 'title', 'queue', 'priority', 'kbitem'):
|
||||
if sort not in ('status', 'assigned_to', 'created', 'title', 'queue', 'priority', 'last_followup', 'kbitem'):
|
||||
sort = 'created'
|
||||
query_params['sorting'] = sort
|
||||
|
||||
@ -1158,6 +1168,7 @@ def datatables_ticket_list(request, query):
|
||||
"""
|
||||
query = Query(HelpdeskUser(request.user), base64query=query)
|
||||
result = query.get_datatables_context(**request.query_params)
|
||||
print(result)
|
||||
return JsonResponse(result, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user