2018-04-29 01:28:09 +02:00
|
|
|
# coding: utf-8
|
|
|
|
from django.core.management.base import BaseCommand
|
2018-04-24 00:19:42 +02:00
|
|
|
|
|
|
|
from allauth_ens.adapter import install_longterm_adapter
|
|
|
|
|
2018-04-29 01:28:09 +02:00
|
|
|
|
2018-04-24 00:19:42 +02:00
|
|
|
class Command(BaseCommand):
|
2018-04-29 01:28:09 +02:00
|
|
|
help = 'Manages the transition from an older django_cas' \
|
|
|
|
'or an allauth_ens installation without ' \
|
|
|
|
'LongTermClipperAccountAdapter'
|
2018-04-24 00:19:42 +02:00
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument(
|
|
|
|
'--fake',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
2018-04-29 01:28:09 +02:00
|
|
|
help=('Does not save the models created/updated,'
|
|
|
|
'only shows the list'),
|
2018-04-24 00:19:42 +02:00
|
|
|
)
|
|
|
|
pass
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
logs = install_longterm_adapter(options.get("fake", False))
|
2018-04-29 01:28:09 +02:00
|
|
|
self.stdout.write("Social accounts created : %d"
|
|
|
|
% len(logs["created"]))
|
|
|
|
self.stdout.write(" ".join(("%s -> %s" % s) for s in logs["created"]))
|
|
|
|
self.stdout.write("Social accounts displaced : %d"
|
|
|
|
% len(logs["updated"]))
|
|
|
|
self.stdout.write(" ".join(("%s -> %s" % s) for s in logs["updated"]))
|
|
|
|
self.stdout.write("User accounts unmodified : %d"
|
|
|
|
% len(logs["unmodified"]))
|
2018-04-24 00:19:42 +02:00
|
|
|
self.stdout.write(" ".join(logs["unmodified"]))
|
|
|
|
|
2018-04-29 01:28:09 +02:00
|
|
|
self.stdout.write(self.style.SUCCESS(
|
|
|
|
"LongTermClipper migration successful"))
|