Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
reclean the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Mar 1, 2014
1 parent 694b60c commit fb11512
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions gittip/models/participant.py
Expand Up @@ -1013,21 +1013,22 @@ def delete_elsewhere(self, platform, user_id):
"""
user_id = unicode(user_id)
with self.db.get_cursor() as c:
ACCOUNTS = "SELECT platform, user_id FROM elsewhere WHERE participant=%s AND platform IN %s"
accounts = c.all(ACCOUNTS, (self.username, AccountElsewhere.signin_platforms_names))
accounts = c.all("""
SELECT platform, user_id
FROM elsewhere
WHERE participant=%s
AND platform IN %s
""", (self.username, AccountElsewhere.signin_platforms_names))
assert len(accounts) > 0
if len(accounts) == 1 and accounts[0].platform == platform and accounts[0].user_id == user_id:
if len(accounts) == 1 and accounts[0] == (platform, user_id):
raise LastElsewhere()
d = c.all("""
c.one("""
DELETE FROM elsewhere
WHERE participant=%s
AND platform=%s
AND user_id=%s
RETURNING participant
""", (self.username, platform, user_id))
assert len(d) <= 1
if len(d) == 0:
raise NonexistingElsewhere()
""", (self.username, platform, user_id), default=NonexistingElsewhere)
add_event(c, 'participant', dict(id=self.id, action='disconnect', values=dict(platform=platform, user_id=user_id)))


Expand Down

0 comments on commit fb11512

Please sign in to comment.