Removed caching for dev machines

This commit is contained in:
Piotr Mitros
2012-03-10 20:13:03 -05:00
parent a8c2c3c5b4
commit a2c4010b8f
3 changed files with 13 additions and 1 deletions

View File

@@ -151,7 +151,13 @@ def user_groups(user):
# TODO: Rewrite in Django
key = 'user_group_names_{user.id}'.format(user=user)
cache_expiration = 60 * 60 # one hour
group_names = cache.get(fasthash(key))
# Kill caching on dev machines -- we switch groups a lot
if "dev" not in setting.DEFAULT_GROUPS:
group_names = cache.get(fasthash(key))
else:
group_names = None
if group_names is None:
group_names = [u.name for u in UserTestGroup.objects.filter(users=user)]
cache.set(fasthash(key), group_names, cache_expiration)

View File

@@ -6,6 +6,7 @@ import tempfile
import djcelery
# from settings2.askbotsettings import LIVESETTINGS_OPTIONS
DEFAULT_GROUPS = []
# Configuration option for when we want to grab server error pages
STATIC_GRAB = False

View File

@@ -103,3 +103,8 @@ def add_user_to_group(group, user):
utg = UserTestGroup.objects.get(name = group)
utg.users.add(User.objects.get(username = user))
utg.save()
def remove_user_from_group(group, user):
utg = UserTestGroup.objects.get(name = group)
utg.users.add(User.objects.get(username = user))
utg.save()