dj11: replace deprecated symbols (#22682)

This commit is contained in:
Benjamin Dauvergne 2018-03-27 13:13:44 +02:00
parent 2db8756f48
commit 7846a6ab5b
2 changed files with 7 additions and 7 deletions

View File

@ -1,11 +1,11 @@
from django.core.management.base import NoArgsCommand
from django.core.management.base import BaseCommand
from fargo.fargo.utils import cleanup
class Command(NoArgsCommand):
class Command(BaseCommand):
help = 'Clean expired models'
def handle_noargs(self, **options):
def handle(self, *args, **options):
cleanup()

View File

@ -2,7 +2,7 @@ import hashlib
from django.utils.timezone import utc
from django.utils.encoding import smart_bytes
from django.db import models
from django.apps import apps
try:
import magic
@ -42,6 +42,7 @@ def get_mime_type(path):
mime_type = None
return mime_type
def cleanup_model(model, n=None):
manager = getattr(model, 'objects', None)
if hasattr(manager, 'cleanup'):
@ -49,6 +50,5 @@ def cleanup_model(model, n=None):
def cleanup(n=None):
for app in models.get_apps():
for model in models.get_models(app):
cleanup_model(model, n=n)
for model in apps.get_models():
cleanup_model(model, n=n)