Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes compatibility between django 3.2 and 4.2 for next planned execution in admin #9

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.2]

### Fixed

- Fixes compatibility between django 3.2 and 4.2 for next planned execution in admin

## [1.1.1]

### Fixed

- Use custom css to fix external depenceny upload restriction

## [1.1.0]

### Added
Expand All @@ -16,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial setup.

[Unreleased]: https://github.com/anexia/django-future-tasks/compare/1.0.0...HEAD
[Unreleased]: https://github.com/anexia/django-future-tasks/compare/1.1.2...HEAD
[1.1.2]: https://github.com/anexia/django-future-tasks/releases/tag/1.1.2
[1.1.1]: https://github.com/anexia/django-future-tasks/releases/tag/1.1.1
[1.1.0]: https://github.com/anexia/django-future-tasks/releases/tag/1.1.0
[1.0.0]: https://github.com/anexia/django-future-tasks/releases/tag/1.0.0
22 changes: 7 additions & 15 deletions django_future_tasks/models.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import datetime
import uuid

import croniter
from cron_descriptor import (
CasingTypeEnum,
DescriptionTypeEnum,
ExpressionDescriptor,
Options,
)
from cron_descriptor import CasingTypeEnum, ExpressionDescriptor
from cronfield.models import CronField
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import JSONField, Q
from django.utils import timezone
from django.utils.dateformat import format
from django.utils.timezone import utc
from django.utils.translation import gettext_lazy as _


Expand Down Expand Up @@ -97,9 +91,9 @@ class PeriodicFutureTask(models.Model):
)

def next_planned_execution(self):
now = datetime.datetime.now()
next_planned_execution = utc.localize(
croniter.croniter(self.cron_string, now).get_next(datetime.datetime)
now = timezone.now()
next_planned_execution = croniter.croniter(self.cron_string, now).get_next(
timezone.datetime
)
if (
not self.is_active
Expand All @@ -111,15 +105,13 @@ def next_planned_execution(self):
or (
self.end_time is not None
and self.end_time
< utc.localize(
croniter.croniter(self.cron_string, now).get_next(datetime.datetime)
)
< croniter.croniter(self.cron_string, now).get_next(timezone.datetime)
)
):
return None

return format(
next_planned_execution,
timezone.template_localtime(next_planned_execution),
settings.DATETIME_FORMAT,
)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="django-future-tasks",
version=os.getenv("PACKAGE_VERSION", "1.1.0").replace("refs/tags/", ""),
version=os.getenv("PACKAGE_VERSION", "1.1.2").replace("refs/tags/", ""),
packages=find_packages(),
include_package_data=True,
install_requires=[
Expand Down
2 changes: 1 addition & 1 deletion tests/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"
TIME_ZONE = "Europe/Vienna"

USE_I18N = True

Expand Down
Loading