Skip to content

Commit

Permalink
Remove superseded ExtendedQuerySet as it's functionality is built int…
Browse files Browse the repository at this point in the history
…o Django since 1.7 (#563)

* get rid of outdated model managers as update_or_create is provided by django since 1.7

* fix line length

* fix docstring
  • Loading branch information
lociii authored Oct 13, 2022
1 parent d65d0c6 commit 626c2a0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 40 deletions.
30 changes: 0 additions & 30 deletions django_celery_beat/managers.py

This file was deleted.

6 changes: 2 additions & 4 deletions django_celery_beat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from . import managers, validators
from . import querysets, validators
from .tzcrontab import TzAwareCrontab
from .utils import make_aware, now
from .clockedschedule import clocked
Expand Down Expand Up @@ -369,8 +369,6 @@ class PeriodicTasks(models.Model):
ident = models.SmallIntegerField(default=1, primary_key=True, unique=True)
last_update = models.DateTimeField(null=False)

objects = managers.ExtendedManager()

@classmethod
def changed(cls, instance, **kwargs):
if not instance.no_changes:
Expand Down Expand Up @@ -540,7 +538,7 @@ class PeriodicTask(models.Model):
'Detailed description about the details of this Periodic Task'),
)

objects = managers.PeriodicTaskManager()
objects = querysets.PeriodicTaskQuerySet.as_manager()
no_changes = False

class Meta:
Expand Down
9 changes: 9 additions & 0 deletions django_celery_beat/querysets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Model querysets."""
from django.db import models


class PeriodicTaskQuerySet(models.QuerySet):
"""QuerySet for PeriodicTask."""

def enabled(self):
return self.filter(enabled=True)
5 changes: 3 additions & 2 deletions django_celery_beat/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ def to_model_schedule(cls, schedule):

@classmethod
def from_entry(cls, name, app=None, **entry):
return cls(PeriodicTask._default_manager.update_or_create(
obj, created = PeriodicTask._default_manager.update_or_create(
name=name, defaults=cls._unpack_fields(**entry),
), app=app)
)
return cls(obj, app=app)

@classmethod
def _unpack_fields(cls, schedule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
=====================================================
``django_celery_beat.managers``
``django_celery_beat.querysets``
=====================================================

.. contents::
:local:
.. currentmodule:: django_celery_beat.managers
.. currentmodule:: django_celery_beat.querysets

.. automodule:: django_celery_beat.managers
.. automodule:: django_celery_beat.querysets
:members:
:undoc-members:
2 changes: 1 addition & 1 deletion docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
django-celery-beat
django-celery-beat.models
django-celery-beat.tzcrontab
django-celery-beat.managers
django-celery-beat.querysets
django-celery-beat.schedulers
django-celery-beat.admin
django-celery-beat.utils
Expand Down

0 comments on commit 626c2a0

Please sign in to comment.