forked from extern/django-helpdesk
Merge pull request #881 from Benbb96/fix-errors-on-master
Fix errors on 0.3.x branch especially relating to django 3.x
This commit is contained in:
commit
c9e0a51d78
@ -56,7 +56,7 @@ MIDDLEWARE = [
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'demodesk.config.urls'
|
||||
ROOT_URLCONF = 'demo.demodesk.config.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
@ -75,7 +75,7 @@ TEMPLATES = [
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'demodesk.config.wsgi.application'
|
||||
WSGI_APPLICATION = 'demo.demodesk.config.wsgi.application'
|
||||
|
||||
|
||||
# django-helpdesk configuration settings
|
||||
|
@ -752,7 +752,7 @@ class Ticket(models.Model):
|
||||
User = get_user_model()
|
||||
try:
|
||||
return User.objects.get(email=self.submitter_email)
|
||||
except User.DoesNotExist:
|
||||
except (User.DoesNotExist, User.MultipleObjectsReturned):
|
||||
return None
|
||||
|
||||
class Meta:
|
||||
|
@ -219,5 +219,4 @@ class __Query__:
|
||||
'hour': date.hour,
|
||||
'minute': date.minute,
|
||||
'second': date.second,
|
||||
'second': date.second,
|
||||
}
|
||||
|
@ -32,28 +32,30 @@ class DatatablesTicketSerializer(serializers.ModelSerializer):
|
||||
'time_spent', 'kbitem')
|
||||
|
||||
def get_queue(self, obj):
|
||||
return ({"title": obj.queue.title, "id": obj.queue.id})
|
||||
return {"title": obj.queue.title, "id": obj.queue.id}
|
||||
|
||||
def get_ticket(self, obj):
|
||||
return (str(obj.id) + " " + obj.ticket)
|
||||
return str(obj.id) + " " + obj.ticket
|
||||
|
||||
def get_status(self, obj):
|
||||
return (obj.get_status)
|
||||
return obj.get_status
|
||||
|
||||
def get_created(self, obj):
|
||||
return (humanize.naturaltime(obj.created))
|
||||
return humanize.naturaltime(obj.created)
|
||||
|
||||
def get_due_date(self, obj):
|
||||
return (humanize.naturaltime(obj.due_date))
|
||||
return humanize.naturaltime(obj.due_date)
|
||||
|
||||
def get_assigned_to(self, obj):
|
||||
if obj.assigned_to:
|
||||
if obj.assigned_to.get_full_name():
|
||||
return (obj.assigned_to.get_full_name())
|
||||
return obj.assigned_to.get_full_name()
|
||||
elif obj.assigned_to.email:
|
||||
return obj.assigned_to.email
|
||||
else:
|
||||
return (obj.assigned_to.email)
|
||||
return obj.assigned_to.username
|
||||
else:
|
||||
return ("None")
|
||||
return "None"
|
||||
|
||||
def get_submitter(self, obj):
|
||||
return obj.submitter_email
|
||||
@ -62,7 +64,7 @@ class DatatablesTicketSerializer(serializers.ModelSerializer):
|
||||
return format_time_spent(obj.time_spent)
|
||||
|
||||
def get_row_class(self, obj):
|
||||
return (obj.get_priority_css_class)
|
||||
return obj.get_priority_css_class
|
||||
|
||||
def get_kbitem(self, obj):
|
||||
return obj.kbitem.title if obj.kbitem else ""
|
||||
|
@ -9,7 +9,6 @@ views/staff.py - The bulk of the application - provides most business logic and
|
||||
from copy import deepcopy
|
||||
import json
|
||||
|
||||
from django import VERSION as DJANGO_VERSION
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
@ -20,19 +19,15 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from django.db.models import Q
|
||||
from django.http import HttpResponseRedirect, Http404, HttpResponse, JsonResponse
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.utils.dates import MONTHS_3
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.html import escape
|
||||
from django import forms
|
||||
from django.utils import timezone
|
||||
from django.views.generic.edit import FormView, UpdateView
|
||||
|
||||
from helpdesk.query import (
|
||||
get_query_class,
|
||||
query_to_dict,
|
||||
query_to_base64,
|
||||
query_from_base64,
|
||||
apply_query,
|
||||
)
|
||||
|
||||
from helpdesk.user import HelpdeskUser
|
||||
@ -45,12 +40,11 @@ from helpdesk.forms import (
|
||||
TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm, TicketCCForm,
|
||||
TicketCCEmailForm, TicketCCUserForm, EditFollowUpForm, TicketDependencyForm
|
||||
)
|
||||
from helpdesk.decorators import staff_member_required, superuser_required
|
||||
from helpdesk.decorators import superuser_required
|
||||
from helpdesk.lib import (
|
||||
safe_template_context,
|
||||
process_attachments,
|
||||
queue_template_context,
|
||||
format_time_spent,
|
||||
)
|
||||
from helpdesk.models import (
|
||||
Ticket, Queue, FollowUp, TicketChange, PreSetReply, FollowUpAttachment, SavedSearch,
|
||||
@ -61,8 +55,7 @@ import helpdesk.views.abstract_views as abstract_views
|
||||
from helpdesk.views.permissions import MustBeStaffMixin
|
||||
from ..lib import format_time_spent
|
||||
|
||||
from rest_framework import viewsets, status
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
from rest_framework.decorators import api_view
|
||||
|
||||
from datetime import date, datetime, timedelta
|
||||
@ -105,6 +98,14 @@ def dashboard(request):
|
||||
showing ticket counts by queue/status, and a list of unassigned tickets
|
||||
with options for them to 'Take' ownership of said tickets.
|
||||
"""
|
||||
# user settings num tickets per page
|
||||
tickets_per_page = request.user.usersettings_helpdesk.tickets_per_page or 25
|
||||
|
||||
# page vars for the three ticket tables
|
||||
user_tickets_page = request.GET.get(_('ut_page'), 1)
|
||||
user_tickets_closed_resolved_page = request.GET.get(_('utcr_page'), 1)
|
||||
all_tickets_reported_by_current_user_page = request.GET.get(_('atrbcu_page'), 1)
|
||||
|
||||
huser = HelpdeskUser(request.user)
|
||||
active_tickets = Ticket.objects.select_related('queue').exclude(
|
||||
status__in=[Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS],
|
||||
@ -448,7 +449,7 @@ def subscribe_to_ticket_updates(ticket, user=None, email=None, can_view=True, ca
|
||||
return ticketcc
|
||||
|
||||
|
||||
def subscribe_staff_member_to_ticket(ticket, user, email=''):
|
||||
def subscribe_staff_member_to_ticket(ticket, user, email='', can_view=True, can_update=False):
|
||||
"""used in view_ticket() and update_ticket()"""
|
||||
return subscribe_to_ticket_updates(ticket=ticket, user=user, email=email, can_view=can_view, can_update=can_update)
|
||||
|
||||
@ -828,7 +829,7 @@ def mass_update(request):
|
||||
'submitter': ('closed_submitter', context),
|
||||
'ticket_cc': ('closed_cc', context),
|
||||
}
|
||||
if ticket.assigned_to and ticket.assigned_to.usersettings_helpdesk.email_on_ticket_change:
|
||||
if t.assigned_to and t.assigned_to.usersettings_helpdesk.email_on_ticket_change:
|
||||
roles['assigned_to'] = ('closed_owner', context),
|
||||
|
||||
messages_sent_to.update(t.send(
|
||||
@ -1010,10 +1011,10 @@ def load_saved_query(request, query_params=None):
|
||||
|
||||
if request.GET.get('saved_query', None):
|
||||
try:
|
||||
saved_query = SavedSearch.objects.get(pk=request.GET.get('saved_query'))
|
||||
except SavedSearch.DoesNotExist:
|
||||
raise QueryLoadError()
|
||||
if not (saved_query.shared or saved_query.user == request.user):
|
||||
saved_query = SavedSearch.objects.get(
|
||||
Q(pk=request.GET.get('saved_query')) & (Q(shared=True) | Q(user=request.user))
|
||||
)
|
||||
except (SavedSearch.DoesNotExist, ValueError):
|
||||
raise QueryLoadError()
|
||||
|
||||
try:
|
||||
@ -1217,17 +1218,11 @@ def run_report(request, report):
|
||||
except QueryLoadError:
|
||||
return HttpResponseRedirect(reverse('helpdesk:report_index'))
|
||||
|
||||
if request.GET.get('saved_query', None):
|
||||
report_queryset = apply_query(report_queryset, query_params)
|
||||
|
||||
from collections import defaultdict
|
||||
summarytable = defaultdict(int)
|
||||
# a second table for more complex queries
|
||||
summarytable2 = defaultdict(int)
|
||||
|
||||
def month_name(m):
|
||||
MONTHS_3[m].title()
|
||||
|
||||
first_ticket = Ticket.objects.all().order_by('created')[0]
|
||||
first_month = first_ticket.created.month
|
||||
first_year = first_ticket.created.year
|
||||
|
Loading…
Reference in New Issue
Block a user