Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/d2d-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobynance committed Oct 14, 2022
2 parents ac02565 + 62de79d commit 1054bc8
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 39 deletions.
4 changes: 2 additions & 2 deletions chroniker/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms
from django.conf import settings
from django.conf.urls import url
from django.urls import re_path as url
from django.contrib import admin
from django.core.management import get_commands
from django.urls import reverse, NoReverseMatch
Expand All @@ -14,7 +14,7 @@
from django.utils.formats import get_format
from django.utils.html import format_html
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from chroniker.models import Job, Log, JobDependency, Monitor
from chroniker import utils
Expand Down
2 changes: 1 addition & 1 deletion chroniker/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

YEARLY = 'YEARLY'
MONTHLY = 'MONTHLY'
Expand Down
2 changes: 1 addition & 1 deletion chroniker/management/commands/cronserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from django.core.management.base import BaseCommand
from django.core.management import call_command
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

logger = logging.getLogger('chroniker.commands.cronserver')

Expand Down
8 changes: 4 additions & 4 deletions chroniker/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from django.utils.encoding import smart_str
from django.utils.safestring import mark_safe
from django.utils.timesince import timeuntil
from django.utils.translation import ungettext, ugettext, ugettext_lazy as _
from django.utils.translation import ngettext, gettext, gettext_lazy as _
from django.core.exceptions import ValidationError
from django.utils.html import format_html
from toposort import toposort_flatten
Expand Down Expand Up @@ -752,7 +752,7 @@ def get_timeuntil(self):
"""
Returns a string representing the time until the next
time this Job will be run (actually, the "string" returned
is really an instance of ``ugettext_lazy``).
is really an instance of ``gettext_lazy``).
>>> job = Job(next_run=timezone.now())
>>> job.get_timeuntil().translate('en')
Expand All @@ -772,8 +772,8 @@ def get_timeuntil(self):
return _('due')
if delta.seconds < 60:
# Adapted from django.utils.timesince
count = lambda n: ungettext('second', 'seconds', n)
return ugettext('%(number)d %(type)s') % {'number': delta.seconds, 'type': count(delta.seconds)}
count = lambda n: ngettext('second', 'seconds', n)
return gettext('%(number)d %(type)s') % {'number': delta.seconds, 'type': count(delta.seconds)}
return timeuntil(self.next_run)

get_timeuntil.short_description = _('time until next run')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'admin/change_form.html' %}
{#{% load url from future %}#}
{% load i18n admin_urls admin_static admin_modify %}
{% load i18n admin_urls static admin_modify %}

{% block breadcrumbs %}
<div class="breadcrumbs">
Expand Down
9 changes: 4 additions & 5 deletions chroniker/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ def testTimezone(self):
settings.USE_TZ = True

def testTimezone2(self):
# NOTE: This test started failing as a result of D2D change WEB-2636.
# After this change, USE_TZ=False is no longer supported. Test has been changed
# to reflect the new behavior. -VV 2022-06-03
tz = zoneinfo.gettz(settings.TIME_ZONE)
_USE_TZ = settings.USE_TZ
settings.USE_TZ = False
Expand All @@ -402,11 +405,7 @@ def testTimezone2(self):
self.assertTrue(timezone.is_naive(next_run))
with self.assertRaises(ValueError):
#astimezone() cannot be applied to a naive datetime
timezone.make_naive(j.next_run, timezone=tz)
j.save()

response = client.get('/admin/chroniker/job/')
self.assertEqual(response.status_code, 200)
response = client.get('/admin/chroniker/job/')

finally:
settings.USE_TZ = _USE_TZ
Expand Down
21 changes: 2 additions & 19 deletions chroniker/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
try:
# Removed in Django 1.6
from django.conf.urls.defaults import url, include
except ImportError:
from django.conf.urls import url, include

try:
# Relocated in Django 1.6
from django.conf.urls.defaults import patterns
except ImportError:
# Completely removed in Django 1.10
try:
from django.conf.urls import patterns
except ImportError:
patterns = None
from django.urls import re_path as url, include

from django.core.exceptions import ImproperlyConfigured
from django.contrib import admin
Expand All @@ -29,7 +15,4 @@
url(r'^admin/', admin.site.urls),
]

if patterns is None:
urlpatterns = _patterns
else:
urlpatterns = patterns('', *_patterns)
urlpatterns = _patterns
2 changes: 1 addition & 1 deletion requirements-min-django.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Django>=2.0
Django>=2.2
11 changes: 6 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[tox]
envlist = py{36,37}-django{21},py{36,37}-django{30}
envlist = py{38,39}-django{22},py{38,39,310}-django{32}
recreate = True

[testenv]
basepython =
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/requirements-test.txt
django21: Django>=2.1,<2.2
django30: Django>=3.0,<3.1
django22: Django>=2.2,<2.3
django32: Django>=3.2,<3.3
commands = django-admin.py test --traceback --settings=chroniker.tests.settings chroniker.tests.tests.JobTestCase{env:TESTNAME:}

0 comments on commit 1054bc8

Please sign in to comment.