comparison gpp/core/models.py @ 423:3fe60148f75c

Fixing #203; use Redis for who's online function.
author Brian Neal <bgneal@gmail.com>
date Sat, 23 Apr 2011 19:19:38 +0000
parents dcc929973bba
children
comparison
equal deleted inserted replaced
422:6309814cd6f7 423:3fe60148f75c
3 """ 3 """
4 import datetime 4 import datetime
5 5
6 from django.db import models 6 from django.db import models
7 from django.contrib.auth.models import User 7 from django.contrib.auth.models import User
8
9
10 class UserLastVisit(models.Model):
11 """
12 This model represents timestamps indicating a user's last visit to the
13 site.
14 """
15 user = models.ForeignKey(User, unique=True)
16 last_visit = models.DateTimeField(db_index=True)
17
18
19 class AnonLastVisit(models.Model):
20 """
21 This model represents timestamps for the last visit from non-authenticated
22 users.
23 """
24 ip = models.CharField(max_length=16, db_index=True, unique=True)
25 last_visit = models.DateTimeField(db_index=True)
26 8
27 9
28 class Statistic(models.Model): 10 class Statistic(models.Model):
29 """ 11 """
30 This model keeps track of site statistics. Currently, the only statistic 12 This model keeps track of site statistics. Currently, the only statistic
35 max_users_date = models.DateTimeField() 17 max_users_date = models.DateTimeField()
36 max_anon_users = models.IntegerField() 18 max_anon_users = models.IntegerField()
37 max_anon_users_date = models.DateTimeField() 19 max_anon_users_date = models.DateTimeField()
38 20
39 def __unicode__(self): 21 def __unicode__(self):
40 return u'%d users on %s' % (self.max_users, 22 return u'%d users on %s' % (self.max_users,
41 self.max_users_date.strftime('%Y-%m-%d %H:%M:%S')) 23 self.max_users_date.strftime('%Y-%m-%d %H:%M:%S'))
42 24