Skip to content

Commit

Permalink
feat: adapt for django 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Srynetix committed Apr 11, 2024
1 parent 3c811da commit 99bf386
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

.. image:: https://user-images.githubusercontent.com/26336/59113881-917c5180-890b-11e9-9863-f5a98d0e235e.png

:Version: 4.1.0sc
:Version: 4.2.0sc
:Web: http://celeryproject.org/
:Download: http://pypi.python.org/pypi/django-celery/
:Source: http://github.com/celery/django-celery/
Expand Down Expand Up @@ -126,7 +126,7 @@ Mailing list
------------

For discussions about the usage, development, and future of celery,
please join the `celery-users`_ mailing list.
please join the `celery-users`_ mailing list.

.. _`celery-users`: http://groups.google.com/group/celery-users/

Expand Down
2 changes: 1 addition & 1 deletion djcelery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import sys

VERSION = (4, 1, 0)
VERSION = (4, 2, 0)
__version__ = '.'.join(map(str, VERSION[0:3])) + ''.join(VERSION[3:])
__author__ = 'Ask Solem'
__contact__ = '[email protected]'
Expand Down
9 changes: 3 additions & 6 deletions djcelery/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.forms.widgets import Select
from django.shortcuts import render
from django.utils.html import escape, format_html, mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from celery import current_app
from celery import states
Expand All @@ -27,10 +27,7 @@
from .humanize import naturaldate
from .utils import is_database_scheduler, make_aware

try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text # noqa
from django.utils.encoding import force_str


TASK_STATE_COLORS = {states.SUCCESS: 'green',
Expand Down Expand Up @@ -192,7 +189,7 @@ def rate_limit_tasks(self, request, queryset):
context = {
'title': _('Rate limit selection'),
'queryset': queryset,
'object_name': force_text(opts.verbose_name),
'object_name': force_str(opts.verbose_name),
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
'opts': opts,
'app_label': app_label,
Expand Down
18 changes: 9 additions & 9 deletions djcelery/humanize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

from datetime import datetime

from django.utils.translation import ungettext, ugettext as _
from django.utils.translation import ngettext, gettext as _
from .utils import now


def pluralize_year(n):
return ungettext(_('{num} year ago'), _('{num} years ago'), n)
return ngettext(_('{num} year ago'), _('{num} years ago'), n)


def pluralize_month(n):
return ungettext(_('{num} month ago'), _('{num} months ago'), n)
return ngettext(_('{num} month ago'), _('{num} months ago'), n)


def pluralize_week(n):
return ungettext(_('{num} week ago'), _('{num} weeks ago'), n)
return ngettext(_('{num} week ago'), _('{num} weeks ago'), n)


def pluralize_day(n):
return ungettext(_('{num} day ago'), _('{num} days ago'), n)
return ngettext(_('{num} day ago'), _('{num} days ago'), n)


OLDER_CHUNKS = (
Expand All @@ -32,7 +32,7 @@ def pluralize_day(n):

def _un(singular__plural, n=None):
singular, plural = singular__plural
return ungettext(singular, plural, n)
return ngettext(singular, plural, n)


def naturaldate(date, include_seconds=False):
Expand All @@ -58,19 +58,19 @@ def naturaldate(date, include_seconds=False):
if days == 0:
if hours == 0:
if minutes > 0:
return ungettext(
return ngettext(
_('{minutes} minute ago'),
_('{minutes} minutes ago'), minutes
).format(minutes=minutes)
else:
if include_seconds and seconds:
return ungettext(
return ngettext(
_('{seconds} second ago'),
_('{seconds} seconds ago'), seconds
).format(seconds=seconds)
return _('just now')
else:
return ungettext(
return ngettext(
_('{hours} hour ago'), _('{hours} hours ago'), hours
).format(hours=hours)

Expand Down
2 changes: 1 addition & 1 deletion djcelery/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.core.exceptions import MultipleObjectsReturned, ValidationError
from django.db import models
from django.db.models import signals
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.conf import settings

from celery import schedules
Expand Down
7 changes: 2 additions & 5 deletions djcelery/picklefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@

from django.db import models

try:
from django.utils.encoding import force_text
except ImportError:
from django.utils.encoding import force_unicode as force_text # noqa
from django.utils.encoding import force_str

DEFAULT_PROTOCOL = 2

Expand Down Expand Up @@ -101,7 +98,7 @@ def from_db_value(self, value, expression, connection, context = None):

def get_db_prep_value(self, value, **kwargs):
if value is not None and not isinstance(value, PickledObject):
return force_text(encode(value, self.compress, self.protocol))
return force_str(encode(value, self.compress, self.protocol))
return value

def value_to_string(self, obj):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ all_files = 1
upload-dir = docs/.build/html

[bdist_rpm]
requires = celery >= 3.1.15, < 4.0
requires = celery >= 3.1.15
django >= 1.8

[flake8]
Expand Down

0 comments on commit 99bf386

Please sign in to comment.