From 7fd83095b0ada85722c3a1cfc78728287666f3bc Mon Sep 17 00:00:00 2001 From: Zbynek Winkler Date: Sun, 12 Jan 2014 19:36:57 +0100 Subject: [PATCH] Make take_over idempotent (fixes #617). --- gittip/models/__init__.py | 24 +----------------------- gittip/models/_mixin_elsewhere.py | 4 ++++ 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/gittip/models/__init__.py b/gittip/models/__init__.py index 31a241284c..e2714abc28 100644 --- a/gittip/models/__init__.py +++ b/gittip/models/__init__.py @@ -108,29 +108,7 @@ def _check_orphans(self): where not exists (select * from elsewhere where elsewhere.participant=username) and not exists (select * from absorptions where archived_as=username) """) - known = set(( - "4c46cc22afdd", - "82b0d81fe9e8", - "6b6527ac6c02", - "cbde8c31c11c", - "bcfc65158eaf", - "31d54a0c19ae", - "afbddadaac3c", - "a78c4e42bb93", - "42eb93b3ab89", - "b1bc5e47fe8e", - "3ac515cc8da6", - "14a79340c40d", - "14d60c6884e7", - "0c783dee50ed", - "e2020536ef6d", - "60a5099d49c7", - "64f4f959b322", - "0bdf90d51786", - "880ac6873f7f" - )) - real = set(orphans) - known - assert len(real) == 0, "missing elsewheres: {}".format(list(real)) + assert len(orphans) == 0, "missing elsewheres: {}".format(list(orphans)) def _check_orphans_no_tips(self): """ diff --git a/gittip/models/_mixin_elsewhere.py b/gittip/models/_mixin_elsewhere.py index a2d66109d3..51c19d6aa5 100644 --- a/gittip/models/_mixin_elsewhere.py +++ b/gittip/models/_mixin_elsewhere.py @@ -269,6 +269,10 @@ def take_over(self, account_elsewhere, have_confirmation=False): other_username = rec.participant + if self.username == other_username: + # this is a no op - trying to take over itself + return + # Make sure we have user confirmation if needed. # ==============================================