Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f8f2bb

Browse files
committed
fixing unsubscribe_expired
1 parent 6da0813 commit 8f8f2bb

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

subscription/models.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,7 @@ def __user_get_active_subscription(user):
105105
return None
106106
auth.models.User.add_to_class('get_active_subscription',__user_get_active_subscription)
107107

108-
class UserSubscriptionManager(models.Manager):
109-
def unsubscribe_expired(self):
110-
"""Unsubscribes all users whose subscription has expired.
111-
112-
Loops through all UserSubscription objects with `expires' field
113-
earlier than datetime.date.today() and forces correct group
114-
membership.
115-
116-
Run this on a cronjob, every X minutes/hours/days.
117-
"""
118-
for us in self.objects.get(expires__lt=datetime.date.today()):
119-
us.fix()
120-
121-
class ActiveUSManager(UserSubscriptionManager):
108+
class ActiveUSManager(models.Manager):
122109
"""Custom Manager for UserSubscription that returns only live US objects."""
123110
def get_query_set(self):
124111
return super(ActiveUSManager, self).get_query_set().filter(active=True)
@@ -284,3 +271,15 @@ def __unicode__(self):
284271
if self.expired():
285272
rv += u' (expired)'
286273
return rv
274+
275+
def unsubscribe_expired():
276+
"""Unsubscribes all users whose subscription has expired.
277+
278+
Loops through all UserSubscription objects with `expires' field
279+
earlier than datetime.date.today() and forces correct group
280+
membership.
281+
282+
Run this on a cronjob, every X minutes/hours/days.
283+
"""
284+
for us in UserSubscription.objects.filter(expires__lt=datetime.date.today()):
285+
us.fix()

0 commit comments

Comments
 (0)