diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 04e43605..a2cc2cfc 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -14,7 +14,10 @@ from django.forms import extras from django.conf import settings from django.contrib.auth.models import User from django.utils.translation import ugettext as _ -from django.utils import timezone +try: + from django.utils import timezone +except importError: + from datetime import datetime as timezone from helpdesk.lib import send_templated_mail, safe_template_context from helpdesk.models import Ticket, Queue, FollowUp, Attachment, IgnoreEmail, TicketCC, CustomField, TicketCustomFieldValue, TicketDependency diff --git a/helpdesk/management/commands/create_escalation_exclusions.py b/helpdesk/management/commands/create_escalation_exclusions.py index 63e56202..84907880 100644 --- a/helpdesk/management/commands/create_escalation_exclusions.py +++ b/helpdesk/management/commands/create_escalation_exclusions.py @@ -9,7 +9,7 @@ scripts/create_escalation_exclusion.py - Easy way to routinely add particular escalation should take place. """ -from datetime import datetime, timedelta, date +from datetime import timedelta, date import getopt from optparse import make_option import sys diff --git a/helpdesk/management/commands/escalate_tickets.py b/helpdesk/management/commands/escalate_tickets.py index b6050061..37558f95 100644 --- a/helpdesk/management/commands/escalate_tickets.py +++ b/helpdesk/management/commands/escalate_tickets.py @@ -8,7 +8,7 @@ scripts/escalate_tickets.py - Easy way to escalate tickets based on their age, designed to be run from Cron or similar. """ -from datetime import datetime, timedelta, date +from datetime import timedelta, date import getopt from optparse import make_option import sys @@ -17,6 +17,11 @@ from django.core.management.base import BaseCommand, CommandError from django.db.models import Q from django.utils.translation import ugettext as _ +try: + from django.utils import timezone +except ImportError: + from datetime import datetime as timezone + from helpdesk.models import Queue, Ticket, FollowUp, EscalationExclusion, TicketChange from helpdesk.lib import send_templated_mail, safe_template_context @@ -95,7 +100,7 @@ def escalate_tickets(queues, verbose): | Q(last_escalation__isnull=True, created__lte=req_last_escl_date) ): - t.last_escalation = datetime.now() + t.last_escalation = timezone.now() t.priority -= 1 t.save() @@ -138,7 +143,7 @@ def escalate_tickets(queues, verbose): f = FollowUp( ticket = t, title = 'Ticket Escalated', - date=datetime.now(), + date=timezone.now(), public=True, comment=_('Ticket escalated after %s days' % q.escalate_days), ) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index 730d3cbc..373d76aa 100644 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -16,7 +16,7 @@ import mimetypes import poplib import re -from datetime import datetime, timedelta +from datetime import timedelta from email.header import decode_header from email.Utils import parseaddr, collapse_rfc2231_value from optparse import make_option @@ -27,6 +27,11 @@ from django.db.models import Q from django.utils.translation import ugettext as _ from helpdesk import settings +try: + from django.utils import timezone +except ImportError: + from datetime import datetime as timezone + from helpdesk.lib import send_templated_mail, safe_template_context from helpdesk.models import Queue, Ticket, FollowUp, Attachment, IgnoreEmail @@ -56,7 +61,7 @@ def process_email(quiet=False): allow_email_submission=True): if not q.email_box_last_check: - q.email_box_last_check = datetime.now()-timedelta(minutes=30) + q.email_box_last_check = timezone.now()-timedelta(minutes=30) if not q.email_box_interval: q.email_box_interval = 0 @@ -64,12 +69,12 @@ def process_email(quiet=False): queue_time_delta = timedelta(minutes=q.email_box_interval) - if (q.email_box_last_check + queue_time_delta) > datetime.now(): + if (q.email_box_last_check + queue_time_delta) > timezone.now(): continue process_queue(q, quiet=quiet) - q.email_box_last_check = datetime.now() + q.email_box_last_check = timezone.now() q.save() @@ -215,7 +220,7 @@ def ticket_from_message(message, queue, quiet): 'type': 'text/html', }) - now = datetime.now() + now = timezone.now() if ticket: try: @@ -254,7 +259,7 @@ def ticket_from_message(message, queue, quiet): f = FollowUp( ticket = t, title = _('E-Mail Received from %(sender_email)s' % {'sender_email': sender_email}), - date = datetime.now(), + date = timezone.now(), public = True, comment = body, ) diff --git a/helpdesk/models.py b/helpdesk/models.py index ceb67d9d..5f914638 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -11,7 +11,12 @@ from django.contrib.auth.models import User from django.db import models from django.conf import settings from django.utils.translation import ugettext_lazy as _, ugettext -from django.utils import timezone + +try: + from django.utils import timezone +except importError: + from datetime import datetime as timezone + from helpdesk.settings import HAS_TAG_SUPPORT if HAS_TAG_SUPPORT: diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 27a87b83..a6b40e31 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -24,9 +24,13 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import loader, Context, RequestContext from django.utils.translation import ugettext as _ from django.utils.html import escape -from django.utils import timezone from django import forms +try: + from django.utils import timezone +except importError: + from datetime import datetime as timezone + from helpdesk.forms import TicketForm, UserSettingsForm, EmailIgnoreForm, EditTicketForm, TicketCCForm, EditFollowUpForm, TicketDependencyForm from helpdesk.lib import send_templated_mail, query_to_dict, apply_query, safe_template_context from helpdesk.models import Ticket, Queue, FollowUp, TicketChange, PreSetReply, Attachment, SavedSearch, IgnoreEmail, TicketCC, TicketDependency