NewsBlur-viq/apps/profile/middleware.py

14 lines
486 B
Python
Raw Normal View History

import datetime
class LastSeenMiddleware(object):
def process_response(self, request, response):
2010-07-06 19:01:25 -04:00
if (request.path == '/'
and not request.is_ajax()
and hasattr(request, 'user')
and request.user.is_authenticated()):
request.user.profile.last_seen_on = datetime.datetime.now()
request.user.profile.last_seen_ip = request.META['REMOTE_ADDR']
request.user.profile.save()
return response