@@ -0,0 +1,1172 @@
+from __future__ import print_function%0Aimport os%0Aimport sys%0Aos.environ%5B'DJANGO_SETTINGS_MODULE'%5D = 'astrometry.net.settings'%0Ap = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))%0Asys.path.append(p)%0A%0Afrom astrometry.net.models import *%0Afrom log import *%0Afrom django.contrib.auth.models import User%0A%0Aimport django%0Adjango.setup()%0A%0A%0Ausers = User.objects.filter(email__contains='godard')%0Aprint(users.count(), 'Users match')%0Abestuser = None%0Anmax = 0%0Afor u in users:%0A    nsub = u.submissions.count()%0A    print('  User', u.id, 'has', nsub, 'Submissions')%0A    if nsub %3E nmax:%0A        bestuser = u%0A        nmax = nsub%0A%0Afrom social.apps.django_app.default.models import UserSocialAuth%0A%0Asocs = %7B%7D%0Afor u in users:%0A    soc = UserSocialAuth.objects.filter(user=u)%0A    print('  User', u.id, 'has', soc.count(), 'social auths', %5Bs.id for s in soc%5D)%0A    for s in soc:%0A        socs%5Bs.id%5D = s%0A%0Aif len(socs) == 1:%0A    # Make the single social auth -%3E the User with the most submissions.%0A    soc = socs.values()%5B0%5D%0A    olduser = soc.user%0A    print(%22Social auth's OLD user:%22, olduser.id, olduser)%0A    print('Updating to', bestuser.id, bestuser)%0A    #soc.user = bestuser%0A    #soc.save()%0A

add script for making a user's new Social auth point to an existing User account