~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to scripts/close-account.py

  • Committer: Jeroen Vermeulen
  • Date: 2011-09-26 06:30:07 UTC
  • mto: This revision was merged to the branch mainline in revision 14049.
  • Revision ID: jeroen.vermeulen@canonical.com-20110926063007-1fb5eelnidpnra9a
Fix lots of lint in recently-changed files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    cur = con.cursor()
28
28
    cur.execute("""
29
29
        SELECT Person.id, Person.account, name, teamowner
30
 
        FROM Person LEFT OUTER JOIN EmailAddress
31
 
            ON Person.id = EmailAddress.person
32
 
        WHERE name=%(username)s or lower(email)=lower(%(username)s)
 
30
        FROM Person
 
31
        LEFT OUTER JOIN EmailAddress ON Person.id = EmailAddress.person
 
32
        WHERE name = %(username)s OR lower(email) = lower(%(username)s)
33
33
        """, vars())
34
34
    try:
35
35
        person_id, account_id, username, teamowner = cur.fetchone()
64
64
    unknown_rationale = PersonCreationRationale.UNKNOWN.value
65
65
    cur.execute("""
66
66
        UPDATE Person
67
 
        SET displayname='Removed by request',
68
 
            name=%(new_name)s, language=NULL, account=NULL,
69
 
            homepage_content=NULL, icon=NULL, mugshot=NULL,
70
 
            hide_email_addresses=TRUE, registrant=NULL, logo=NULL,
71
 
            creation_rationale=%(unknown_rationale)s, creation_comment=NULL
72
 
        WHERE id=%(person_id)s
 
67
        SET
 
68
            displayname = 'Removed by request',
 
69
            name=%(new_name)s,
 
70
            language = NULL,
 
71
            account = NULL,
 
72
            homepage_content = NULL,
 
73
            icon = NULL,
 
74
            mugshot = NULL,
 
75
            hide_email_addresses = TRUE,
 
76
            registrant = NULL,
 
77
            logo = NULL,
 
78
            creation_rationale = %(unknown_rationale)s,
 
79
            creation_comment = NULL
 
80
        WHERE id = %(person_id)s
73
81
        """, vars())
74
82
 
75
83
    # Remove the Account. We don't set the status to deactivated,
87
95
    # Reassign their bugs
88
96
    table_notification('BugTask')
89
97
    cur.execute("""
90
 
        UPDATE BugTask SET assignee=NULL WHERE assignee=%(person_id)s
 
98
        UPDATE BugTask SET assignee = NULL WHERE assignee = %(person_id)s
91
99
        """, vars())
92
100
 
93
101
    # Reassign questions assigned to the user, and close all their questions
165
173
 
166
174
    return True
167
175
 
 
176
 
168
177
def main():
169
178
    parser = OptionParser(
170
179
            '%prog [options] (username|email) [...]'
198
207
            con.rollback()
199
208
        return 1
200
209
 
 
210
 
201
211
if __name__ == '__main__':
202
212
    sys.exit(main())