Skip to content

Commit

Permalink
Enable django-allauth and its social providers
Browse files Browse the repository at this point in the history
Enabling these Django applications will introduce some new migrations to
be run, so we keep this in its own standalone commit.
  • Loading branch information
DavidCain committed Aug 27, 2022
1 parent 53af0ed commit 5fde6bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ws/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'auth_user_user_permissions': ('user_id',),
'account_emailaddress': ('user_id',),
'django_admin_log': ('user_id',),
'socialaccount_socialaccount': ('user_id',),
'ws_participant': ('user_id',),
}

Expand Down Expand Up @@ -146,7 +147,7 @@ def _update_lotteryinfo(cursor, old_pk, new_pk):
cursor.execute(sql, {'old_pk': old_pk, 'new_pk': new_pk})


def _migrate_user(old_pk, new_pk):
def _migrate_user(old_pk: int, new_pk: int) -> None:
"""Copy over any email addresses and groups from the old user."""
cursor = connections['default'].cursor()

Expand Down Expand Up @@ -225,6 +226,6 @@ def _migrate_participant(old_pk, new_pk):


def merge_participants(old, new):
with transaction.atomic(): # Rollback if FK migration fails
with transaction.atomic(): # Roll back if FK migration fails
_migrate_user(old.user_id, new.user_id)
_migrate_participant(old.pk, new.pk)
2 changes: 2 additions & 0 deletions ws/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
'phonenumber_field',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'crispy_forms',
'pipeline',
'ws.apps.TripsConfig',
Expand Down
1 change: 1 addition & 0 deletions ws/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_check_fk_tables_missing_fk(self):
'auth_user_groups': 'user_id',
'account_emailaddress': 'user_id',
# 'django_admin_log': 'user_id',
'socialaccount_socialaccount': ('user_id',),
'ws_participant': 'user_id',
}
with self.assertRaises(ValueError) as err:
Expand Down

0 comments on commit 5fde6bc

Please sign in to comment.