##// END OF EJS Templates
Merged in bodqhrohro/neboard-1/bodqhrohro/pillow-now-requires-zlib-too-1522164393285 (pull request #27)...
Merged in bodqhrohro/neboard-1/bodqhrohro/pillow-now-requires-zlib-too-1522164393285 (pull request #27) Pillow now requires zlib too Approved-by: Bohdan Horbyeshko <bodqhrohro@yandex.ru>

File last commit:

r2043:492247e6 default
r2097:5ab4630b merge default
Show More
cleansettings.py
27 lines | 749 B | text/x-python | PythonLexer
from importlib import import_module
from django.core.management import BaseCommand
from django.db import transaction
from django.conf import settings
from boards.models.user import UserSettings
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
__author__ = 'neko259'
class Command(BaseCommand):
help = 'Remove user settings that do not have their sessions.'
@transaction.atomic
def handle(self, *args, **options):
count = 0
for setting in UserSettings.objects.all():
session = SessionStore(session_key=setting.session_key)
if session.is_empty():
setting.delete()
count += 1
print('Removed {} empty setting objects.'.format(count))