function to merge two users

This commit is contained in:
j 2015-04-15 14:59:42 +05:30
parent 6793c165b3
commit 5e8294b1c0

View file

@ -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)