hooks.py 1.0 KB

12345678910111213141516171819202122232425
  1. # Copyright 2013 The Distro Tracker Developers
  2. # See the COPYRIGHT file at the top-level directory of this distribution and
  3. # at http://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 http://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. from __future__ import unicode_literals
  11. from distro_tracker.accounts.models import User
  12. def post_merge(initial_user, merge_with):
  13. """
  14. When two user accounts are joined by :mod:`django_email_accounts`,
  15. move the teams owned by the account to be deleted to the new merged
  16. account.
  17. """
  18. # Convert to our custom user object to be able to use our own methods
  19. initial_user = User.objects.get(pk=initial_user.pk)
  20. merge_with = User.objects.get(pk=merge_with.pk)
  21. merge_with.owned_teams.all().update(owner=initial_user)