##// END OF EJS Templates
Simplify paginator page list building and unified it between different views
Simplify paginator page list building and unified it between different views

File last commit:

r2043:492247e6 default
r2061:b31844e6 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))