mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-13 10:21:05 +01:00
Fix datetime/timezone handling in Django <1.4; update management commands to be timezone-aware
This commit is contained in:
parent
30bce8c27e
commit
53273e3794
@ -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
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
)
|
||||
|
@ -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,
|
||||
)
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user