Skip to content

Commit

Permalink
Merge pull request #29 from adepue/master
Browse files Browse the repository at this point in the history
Use correct Manager structure
  • Loading branch information
Adam DePue committed Dec 5, 2015
2 parents a7f338d + 465d12c commit dd6277c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run_tests(self):

setup(
name='django-livefield',
version='2.3.0',
version='2.3.1',
description='Convenient soft-deletion support for Django models',
long_description=(
open('README.rst').read() + '\n\n' +
Expand Down
13 changes: 6 additions & 7 deletions src/livefield/gis/managers.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
from django.db import models

from .querysets import LiveGeoQuerySet


LiveGeoManagerBase = models.Manager.from_queryset(LiveGeoQuerySet)


class LiveGeoManager(LiveGeoManagerBase):
class LiveGeoManagerBase(models.Manager):
# To also use this manager for FK lookups, see
# https://docs.djangoproject.com/en/1.6/topics/db/managers/#manager-types.

def __init__(self, include_soft_deleted=False, *args, **kwargs):
self.include_soft_deleted = include_soft_deleted
super(LiveGeoManager, self).__init__(*args, **kwargs) # pylint: disable=super-on-old-class
super(LiveGeoManagerBase, self).__init__(*args, **kwargs) # pylint: disable=super-on-old-class

def get_queryset(self):
qs = super(LiveGeoManager, self).get_queryset() # pylint: disable=super-on-old-class
qs = super(LiveGeoManagerBase, self).get_queryset() # pylint: disable=super-on-old-class
if not self.include_soft_deleted:
return qs.live()
return qs


LiveGeoManager = LiveGeoManagerBase.from_queryset(LiveGeoQuerySet)
12 changes: 6 additions & 6 deletions src/livefield/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
from .querysets import LiveQuerySet


LiveManagerBase = models.Manager.from_queryset(LiveQuerySet)


class LiveManager(LiveManagerBase):
class LiveManagerBase(models.Manager):
# To also use this manager for FK lookups, see
# https://docs.djangoproject.com/en/1.6/topics/db/managers/#manager-types.

def __init__(self, include_soft_deleted=False, *args, **kwargs):
self.include_soft_deleted = include_soft_deleted
super(LiveManager, self).__init__(*args, **kwargs) # pylint: disable=super-on-old-class
super(LiveManagerBase, self).__init__(*args, **kwargs) # pylint: disable=super-on-old-class

def get_queryset(self):
qs = super(LiveManager, self).get_queryset() # pylint: disable=super-on-old-class
qs = super(LiveManagerBase, self).get_queryset() # pylint: disable=super-on-old-class
if not self.include_soft_deleted:
return qs.live()
return qs


LiveManager = LiveManagerBase.from_queryset(LiveQuerySet)

0 comments on commit dd6277c

Please sign in to comment.