gremmie@1: """ bgneal@37: This file contains the core Models used in gpp gremmie@1: """ bgneal@239: import datetime bgneal@239: bgneal@227: from django.db import models bgneal@239: from django.contrib.auth.models import User gremmie@1: bgneal@227: bgneal@227: class UserLastVisit(models.Model): bgneal@227: """ bgneal@227: This model represents timestamps indicating a user's last visit to the bgneal@227: site. bgneal@227: """ bgneal@239: user = models.ForeignKey(User, unique=True) bgneal@227: last_visit = models.DateTimeField(db_index=True) bgneal@227: bgneal@227: bgneal@227: class AnonLastVisit(models.Model): bgneal@227: """ bgneal@227: This model represents timestamps for the last visit from non-authenticated bgneal@227: users. bgneal@227: """ bgneal@227: ip = models.CharField(max_length=16, db_index=True, unique=True) bgneal@227: last_visit = models.DateTimeField(db_index=True) bgneal@227: bgneal@239: bgneal@239: class Statistic(models.Model): bgneal@239: """ bgneal@239: This model keeps track of site statistics. Currently, the only statistic bgneal@239: is the maximum number of users online. This stat is computed by a mgmt. bgneal@239: command that is run on a cron job to peek at the previous two models. bgneal@239: """ bgneal@239: max_users = models.IntegerField() bgneal@239: max_users_date = models.DateTimeField() bgneal@239: max_anon_users = models.IntegerField() bgneal@239: max_anon_users_date = models.DateTimeField() bgneal@239: bgneal@239: def __unicode__(self): bgneal@239: return u'%d users on %s' % (self.max_users, bgneal@239: self.max_users_date.strftime('%Y-%m-%d %H:%M:%S')) bgneal@239: