summaryrefslogtreecommitdiff
path: root/devel/utils.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-02-07 00:46:21 -0600
committerDan McGee <dan@archlinux.org>2012-02-07 00:46:21 -0600
commitf0a858aab6691438eeec9094c2d46d95b5ddb306 (patch)
treec0f3d7d49f58c5a05a5342a54ae62f4e26c2a43d /devel/utils.py
parentd7d01e3c592a68226edc7dfd435913b0f0781ddd (diff)
Make rematch command do a bit more
Now that we have a few objects that can potentially link back to developers, allow flag requests to also be rematched. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel/utils.py')
-rw-r--r--devel/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/devel/utils.py b/devel/utils.py
index 62b12cd5..ec035d13 100644
--- a/devel/utils.py
+++ b/devel/utils.py
@@ -48,6 +48,7 @@ class UserFinder(object):
def __init__(self):
self.cache = {}
self.username_cache = {}
+ self.email_cache = {}
@staticmethod
def user_email(name, email):
@@ -110,6 +111,7 @@ class UserFinder(object):
pass
self.cache[userstring] = user
+ self.email_cache[email] = user
return user
def find_by_username(self, username):
@@ -126,8 +128,27 @@ class UserFinder(object):
self.username_cache[username] = user
return user
+ def find_by_email(self, email):
+ if not email:
+ return None
+ if email in self.email_cache:
+ return self.email_cache[email]
+
+ user = None
+ try:
+ user = self.user_email(None, email)
+ except User.DoesNotExist:
+ try:
+ user = self.profile_email(None, email)
+ except User.DoesNotExist:
+ pass
+
+ self.email_cache[email] = user
+ return user
+
def clear_cache(self):
self.cache = {}
self.username_cache = {}
+ self.email_cache = {}
# vim: set ts=4 sw=4 et: