annotate gpp/core/models.py @ 302:94bd52dada89

Fixing #10; Adding a colophon flatpage.
author Brian Neal <bgneal@gmail.com>
date Sat, 15 Jan 2011 20:27:37 +0000
parents dcc929973bba
children 3fe60148f75c
rev   line source
gremmie@1 1 """
bgneal@37 2 This file contains the core Models used in gpp
gremmie@1 3 """
bgneal@239 4 import datetime
bgneal@239 5
bgneal@227 6 from django.db import models
bgneal@239 7 from django.contrib.auth.models import User
gremmie@1 8
bgneal@227 9
bgneal@227 10 class UserLastVisit(models.Model):
bgneal@227 11 """
bgneal@227 12 This model represents timestamps indicating a user's last visit to the
bgneal@227 13 site.
bgneal@227 14 """
bgneal@239 15 user = models.ForeignKey(User, unique=True)
bgneal@227 16 last_visit = models.DateTimeField(db_index=True)
bgneal@227 17
bgneal@227 18
bgneal@227 19 class AnonLastVisit(models.Model):
bgneal@227 20 """
bgneal@227 21 This model represents timestamps for the last visit from non-authenticated
bgneal@227 22 users.
bgneal@227 23 """
bgneal@227 24 ip = models.CharField(max_length=16, db_index=True, unique=True)
bgneal@227 25 last_visit = models.DateTimeField(db_index=True)
bgneal@227 26
bgneal@239 27
bgneal@239 28 class Statistic(models.Model):
bgneal@239 29 """
bgneal@239 30 This model keeps track of site statistics. Currently, the only statistic
bgneal@239 31 is the maximum number of users online. This stat is computed by a mgmt.
bgneal@239 32 command that is run on a cron job to peek at the previous two models.
bgneal@239 33 """
bgneal@239 34 max_users = models.IntegerField()
bgneal@239 35 max_users_date = models.DateTimeField()
bgneal@239 36 max_anon_users = models.IntegerField()
bgneal@239 37 max_anon_users_date = models.DateTimeField()
bgneal@239 38
bgneal@239 39 def __unicode__(self):
bgneal@239 40 return u'%d users on %s' % (self.max_users,
bgneal@239 41 self.max_users_date.strftime('%Y-%m-%d %H:%M:%S'))
bgneal@239 42