def process_response(self, request, response):
if not self.is_cms_request(request):
return response
from django.utils.cache import add_never_cache_headers
if ((hasattr(request, 'toolbar') and request.toolbar.edit_mode) or
not all(ph.cache_placeholder
for ph in getattr(request, 'placeholders', ()))):
add_never_cache_headers(response)
if hasattr(request, 'user') and request.user.is_staff and response.status_code != 500:
try:
pk = LogEntry.objects.filter(
user=request.user,
action_flag__in=(ADDITION, CHANGE)
).only('pk').order_by('-pk')[0].pk
if hasattr(request, 'cms_latest_entry') and request.cms_latest_entry != pk:
log = LogEntry.objects.filter(user=request.user, action_flag__in=(ADDITION, CHANGE))[0]
request.session['cms_log_latest'] = log.pk
# If there were no LogEntries, just don't touch the session.
# Note that in the case of a user logging-in as another user,
# request may have a cms_latest_entry attribute, but there are no
# LogEntries for request.user.
except IndexError:
pass
return response
评论列表
文章目录