1. Robot Mirror
  2. bugs.python.org


martin.v.loewis  committed 0f4f7df

Move email updating to reactor.

  • Participants
  • Parent commits 89e7d6a
  • Branches default

Comments (0)

Files changed (2)

File detectors/rietveldreactor.py

View file
  • Ignore whitespace
               (nodeid, username, email))
 def update_django_user(db, cl, nodeid, oldvalues):
+    user = nodeid
     if 'username' in oldvalues:
         newname = cl.get(nodeid, 'username')
         c = db.cursor
-        c.execute("update auth_user set username=%s where id=%s", (newname, nodeid))
+        c.execute("update auth_user set username=%s where id=%s", (newname, user))
+    if 'address' in oldvalues:
+        old = oldvalues['address'].decode('ascii')
+        new = cl.get(nodeid, 'address').decode('ascii')
+        c = db.cursor
+        c.execute('update auth_user set email=%s where id=%s', (new, user))
+        c.execute('update codereview_account set email=%s where id=%s', (new, user))
+        # find issues where user is on nosy
+        c.execute('select nodeid,cc from issue_nosy, codereview_issue '
+                  'where linkid=%s and nodeid=id', (user,))
+        for issue, cc in c.fetchall():
+            cc = cPickle.loads(base64.decodestring(cc))
+            try:
+                cc[cc.index(old)] = new
+            except ValueError:
+                cc.append(new)
+            cc = base64.encodestring(cPickle.dumps(cc))
+            c.execute('update codereview_issue set cc=%s where id=%s', (cc, user))
 def update_issue_cc(db, cl, nodeid, oldvalues):
     if 'nosy' not in oldvalues:

File scripts/update_email.py

View file
  • Ignore whitespace
-# cron job to update rietveld tables when the email address changes
+# Update rietveld tables when the email address changes
 # this updates auth_user.email, codereview_account.email 
 # and codereview_issue.cc, based on the nosy list s
 # it does not update codereview_issue.reviewers, since it would be
 # is something that has to be filled out separately in Rietveld.
 # It also does not update codereview_message, since these have already
 # been sent with the email addresses recorded in the database.
+# This script is now part of rietveldreactor
 import sys, os, base64, cPickle
 import roundup.instance