summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2019-10-04 01:57:30 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2019-10-04 01:57:30 +0200
commit2685a08098a789f2b8c5a560a7ce2ebd228ab980 (patch)
tree7200fa3aa5d70153d53a48408408e5f1b67024a9
parent184bf5693ffbd8a5cecb3175a16a129b15741568 (diff)
downloadarchweb-2685a08098a789f2b8c5a560a7ce2ebd228ab980.tar.gz
archweb-2685a08098a789f2b8c5a560a7ce2ebd228ab980.zip
devel/views: Invalidate template fragment cache on profile update
Closes #166. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
-rw-r--r--devel/views.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/devel/views.py b/devel/views.py
index 96bd4a10..96acb720 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -9,6 +9,8 @@ from django.contrib.auth.decorators import (login_required,
user_passes_test)
from django.contrib.auth.models import Group, User
from django.contrib.contenttypes.models import ContentType
+from django.core.cache import cache
+from django.core.cache.utils import make_template_fragment_key
from django.db import transaction
from django.db.models import Count, Max
from django.http import Http404, HttpResponseRedirect
@@ -171,6 +173,12 @@ def change_profile(request):
with transaction.atomic():
request.user.save()
profile_form.save()
+
+ # Invalidate userlist.html template cache fragment.
+ for group in request.user.groups.all():
+ key = make_template_fragment_key('dev-tu-profiles', [group.name])
+ cache.delete(key)
+
return HttpResponseRedirect('/devel/')
else:
form = ProfileForm(initial={'email': request.user.email})