annotate gpp/core/models.py @ 231:a2d388ed106e

Guard against the request object not having a user attribute in my Who's online middleware. This can happen if a redirect is issued before the authentication middleware gets to run.
author Brian Neal <bgneal@gmail.com>
date Wed, 14 Jul 2010 02:35:39 +0000
parents 423c39ee44e0
children dcc929973bba
rev   line source
gremmie@1 1 """
bgneal@37 2 This file contains the core Models used in gpp
gremmie@1 3 """
bgneal@227 4 from django.db import models
bgneal@227 5 from django.contrib import auth
gremmie@1 6
bgneal@227 7
bgneal@227 8 class UserLastVisit(models.Model):
bgneal@227 9 """
bgneal@227 10 This model represents timestamps indicating a user's last visit to the
bgneal@227 11 site.
bgneal@227 12 """
bgneal@227 13 user = models.ForeignKey(auth.models.User, unique=True)
bgneal@227 14 last_visit = models.DateTimeField(db_index=True)
bgneal@227 15
bgneal@227 16
bgneal@227 17 class AnonLastVisit(models.Model):
bgneal@227 18 """
bgneal@227 19 This model represents timestamps for the last visit from non-authenticated
bgneal@227 20 users.
bgneal@227 21 """
bgneal@227 22 ip = models.CharField(max_length=16, db_index=True, unique=True)
bgneal@227 23 last_visit = models.DateTimeField(db_index=True)
bgneal@227 24