Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jelle van der Waa
Archweb
Commits
767feb12
Unverified
Commit
767feb12
authored
Oct 04, 2019
by
Jelle van der Waa
🚧
Committed by
GitHub
Oct 04, 2019
Browse files
Merge pull request #242 from kyrias/invalidate-profile-update
devel/views: Invalidate template fragment cache on profile update
parents
184bf569
2685a080
Changes
1
Hide whitespace changes
Inline
Side-by-side
devel/views.py
View file @
767feb12
...
...
@@ -9,6 +9,8 @@
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
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment