| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 1 | from django.core.management.base import BaseCommand, CommandError |
| 2 | from sf_user.models import CustomSession |
| 3 | |
| 4 | |
| 5 | class Command(BaseCommand): |
| 6 | help = 'Clean Users Sessions' |
| 7 | |
| 8 | #def add_arguments(self, parser): |
| 9 | # parser.add_argument('poll_id', nargs='+', type=int) |
| 10 | |
| 11 | def handle(self, *args, **options): |
| 12 | try: |
| 13 | CustomSession.objects.all().delete() |
| 14 | except Exception: |
| 15 | raise CommandError('Error unable to clean users sessions') |
| 16 | |
| 17 | self.stdout.write(self.style.SUCCESS('Successfully cleaned users sessions')) |