Permalink
Browse files

invalidate all users when added to whitelist (bug 752700)

  • Loading branch information...
1 parent 28ba64a commit 7318a158462ce1ed54f473b4c4b9df352ef44ba3 @cvan cvan committed May 7, 2012
Showing with 4 additions and 14 deletions.
  1. +3 −8 apps/access/models.py
  2. +1 −6 apps/access/tests.py
View
11 apps/access/models.py
@@ -34,15 +34,10 @@ def accesswhitelist_post_save(sender, instance, **kw):
if not kw.get('raw') and instance.email:
from amo.utils import chunked
from users.models import UserProfile
- # Invalidate all users whose emails strictly match.
- for user in UserProfile.objects.filter(email=instance.email):
- user.save()
- # Invalidate all users whose emails match the whitelisted patterns.
- users = UserProfile.objects.filter(notes='__market__')
- for chunk in chunked(users, 150):
+ # Invalidate all users with market emails.
+ for chunk in chunked(UserProfile.objects.all(), 150):
for user in chunk:
- if AccessWhitelist.matches(user.email):
- user.save()
+ user.save()
class Group(amo.models.ModelBase):
View
7 apps/access/tests.py
@@ -268,11 +268,6 @@ def test_post_save_invalidate_marketplace_users(self):
eq_(amo.tests.close_to_now(u.modified), True)
def test_post_save_skip_amo_users(self):
- a = AccessWhitelist.objects.create(email='regular@mozilla.*')
- u = UserProfile.objects.get(email='regular@mozilla.com')
- eq_(amo.tests.close_to_now(u.modified), False)
-
- u.update(notes='__market__')
- a.save()
+ AccessWhitelist.objects.create(email='regular@mozilla.*')
u = UserProfile.objects.get(email='regular@mozilla.com')
eq_(amo.tests.close_to_now(u.modified), True)

0 comments on commit 7318a15

Please sign in to comment.