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

Add Django 4 compatibility #2

Merged
merged 8 commits into from
May 17, 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
4 changes: 2 additions & 2 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9]
django_version: [~=2.2.0, ~=3.2.0]
python-version: [3.8, 3.9, '3.10', 3.11]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required due to actions/runner#1989

django_version: [~=3.2.0, ~=4.2.0]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
30 changes: 6 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,16 @@ os: linux
language: python
jobs:
include:
- python: "2.7"
env: DJANGO=1.11.* DJANGO_SETTINGS_MODULE='settings_sqllite'
- python: "2.7"
env: DJANGO=1.11.* DJANGO_SETTINGS_MODULE='settings_postgres'
- python: "3.8"
env: DJANGO=3.2.* DJANGO_SETTINGS_MODULE='settings_sqllite'
- python: "3.8"
env: DJANGO=3.2.* DJANGO_SETTINGS_MODULE='settings_postgres'
services:
- postgresql
before_script:
- psql -c 'create database travis_test;' -U postgres
- python: "2.7"
env: DJANGO=1.11.* DJANGO_SETTINGS_MODULE='settings_mysql'
services:
- mysql
before_script:
- mysql -e 'create database travis_test;'
- python: "3.7"
env: DJANGO=1.11.* DJANGO_SETTINGS_MODULE='settings_sqllite'
- python: "3.7"
env: DJANGO=2.0.* DJANGO_SETTINGS_MODULE='settings_sqllite'
- python: "3.7"
env: DJANGO=3.0.* DJANGO_SETTINGS_MODULE='settings_sqllite'
- python: "3.7"
env: DJANGO=3.0.* DJANGO_SETTINGS_MODULE='settings_postgres'
services:
- postgresql
before_script:
- psql -c 'create database travis_test;' -U postgres
- python: "3.7"
env: DJANGO=3.0.* DJANGO_SETTINGS_MODULE='settings_mysql'
- python: "3.8"
env: DJANGO=3.2.* DJANGO_SETTINGS_MODULE='settings_mysql'
services:
- mysql
before_script:
Expand Down
Empty file removed demo/demo/__init__.py
Empty file.
42 changes: 0 additions & 42 deletions demo/demo/cron.py

This file was deleted.

130 changes: 0 additions & 130 deletions demo/demo/settings.py

This file was deleted.

22 changes: 0 additions & 22 deletions demo/demo/urls.py

This file was deleted.

16 changes: 0 additions & 16 deletions demo/demo/wsgi.py

This file was deleted.

10 changes: 0 additions & 10 deletions demo/manage.py

This file was deleted.

2 changes: 0 additions & 2 deletions demo/requirements.txt

This file was deleted.

4 changes: 2 additions & 2 deletions django_cron/backends/lock/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

class DatabaseLock(DjangoCronJobLock):
"""
Locking cron jobs with database. Its good when you have not parallel run and want to make sure 2 jobs won't be
Locking cron jobs with database. It's good when you have not parallel run and want to make sure 2 jobs won't be
Copy link

@rob-s-s rob-s-s May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"have not parallel run" doesn't read right? I'm not sure exactly what it means.

Suggested change
Locking cron jobs with database. It's good when you have not parallel run and want to make sure 2 jobs won't be
Locking cron jobs with database. It's good when you have not run cron jobs in parallel and want to make sure 2 jobs won't be

fired at the same time - which may happened when job execution is longer that job interval.
"""

@transaction.atomic
def lock(self):
lock, created = CronJobLock.objects.get_or_create(job_name=self.job_name)
lock, created = CronJobLock.objects.select_for_update().get_or_create(job_name=self.job_name)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably isn't needed for us, but good future proofing, resolves an issue listed here

if lock.locked:
return False
else:
Expand Down
4 changes: 2 additions & 2 deletions django_cron/cron.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf import settings

from django_common.helper import send_mail
from django.core.mail import send_mail
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes this issue


from django_cron import CronJobBase, Schedule, get_class
from django_cron.models import CronJobLog
Expand Down Expand Up @@ -97,5 +97,5 @@ def get_send_mail_kwargs(self, cron_cls, failed_jobs):
return dict(
subject=subject, message=message,
from_email=self.config['CRON_FAILURE_FROM_EMAIL'],
recipient_emails=self.config['CRON_FAILURE_EMAIL_RECIPIENTS']
recipient_list=self.config['CRON_FAILURE_EMAIL_RECIPIENTS']
)
2 changes: 1 addition & 1 deletion django_cron/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,5 +480,5 @@ def test_uses_send_mail(self, mock_send_mail):
self.assertIn('ERROR!!!', kwargs['subject'])
self.assertEquals('from@email.com', kwargs['from_email'])
self.assertEquals(
['foo@bar.com', 'x@y.com'], kwargs['recipient_emails']
['foo@bar.com', 'x@y.com'], kwargs['recipient_list']
)
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
# built documents.
#
# The short X.Y version.
version = '0.6'
version = '0.7'
# The full version, including alpha/beta/rc tags.
release = '0.6.1a1'
release = '0.7.1a1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='django-cron',
version='0.6.1a1',
version='0.7.1a1',
author='Sumit Chachra',
author_email='chachra@tivix.com',
url='http://github.com/tivix/django-cron',
Expand All @@ -29,7 +29,7 @@
long_description=long_description,
keywords='django cron',
zip_safe=False,
install_requires=['Django>=2.2,<4', 'django-common-helpers>=0.6.4'],
install_requires=['Django>=3.2,<5', 'django-common-helpers>=0.6.4'],
test_suite='runtests.runtests',
include_package_data=True,
classifiers=[
Expand Down
Loading