Add an ExpireManager to share common code around expiration of models (refs #5639)

This commit is contained in:
Benjamin Dauvergne 2014-10-06 14:46:57 +02:00
parent 1d6a4d9e15
commit d5675f2540
1 changed files with 4 additions and 0 deletions

View File

@ -48,6 +48,10 @@ class AuthenticationEventManager(models.Manager):
3600*24*7)
self.filter(when__lt=now()-timedelta(seconds=expire)).delete()
class ExpireManager(models.Manager):
def cleanup(self):
self.filter(created__lt=now()-timedelta(days=7)).delete()
LOCAL_PROVIDER_URN = 'urn:oid:1.3.6.1.4.1.36560.1.1:local-provider'
LOCAL_USER_URN = 'urn:oid:1.3.6.1.4.1.36560.1.1:local-user'
LOCAL_SERVICE_URN = 'urn:oid:1.3.6.1.4.1.36560.1.1:local-service'