From 5e8294b1c0e97d89530d1392283032fc233808d2 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 15 Apr 2015 14:59:42 +0530 Subject: [PATCH] function to merge two users --- pandora/user/models.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pandora/user/models.py b/pandora/user/models.py index 5c66e521..75f8b583 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -381,3 +381,22 @@ def has_capability(user, capability): level = user.get_profile().get_level() return level in settings.CONFIG['capabilities'][capability] \ and settings.CONFIG['capabilities'][capability][level] + + +def merge_users(old, new): + old.annotations.all().update(user=new) + old.edits.all().update(user=new) + old.entities.all().update(user=new) + old.events.all().update(user=new) + old.files.all().update(user=new) + old.items.all().update(user=new) + old.lits.all().update(user=new) + old.places.all().update(user=new) + old.subscribed_edits.all().update(user=new) + old.subscribed_lists.all().update(user=new) + old.subscribed_texts.all().update(user=new) + old.texts.all().update(user=new) + old.volumes.all().update(user=new) + old.log_set.all().update(user=new) + old.changelog.all().update(user=new) + old.logentry_set.all().update(user=new)