1# Copyright 2013 The Distro Tracker Developers
2# See the COPYRIGHT file at the top-level directory of this distribution and
3# at https://deb.li/DTAuthors
4#
5# This file is part of Distro Tracker. It is subject to the license terms
6# in the LICENSE file found in the top-level directory of this
7# distribution and at https://deb.li/DTLicense. No part of Distro Tracker,
8# including this file, may be copied, modified, propagated, or distributed
9# except according to the terms contained in the LICENSE file.
10"""Functions that Distro-Tracker hooks into django_email_accounts."""
12from distro_tracker.accounts.models import User
15def post_merge(initial_user, merge_with):
16 """
17 When two user accounts are joined by :mod:`django_email_accounts`,
18 move the teams owned by the account to be deleted to the new merged
19 account.
20 """
21 # Convert to our custom user object to be able to use our own methods
22 initial_user = User.objects.get(pk=initial_user.pk)
23 merge_with = User.objects.get(pk=merge_with.pk)
25 merge_with.owned_teams.all().update(owner=initial_user)