comparison gpp/forums/models.py @ 164:f7a6b8fe4556

Implement #46, add a forums stat feature like phpBB.
author Brian Neal <bgneal@gmail.com>
date Mon, 28 Dec 2009 16:52:42 +0000
parents 48621ba5c385
children cf9f9d4c4d54
comparison
equal deleted inserted replaced
163:4f07047e0a40 164:f7a6b8fe4556
335 self.touch() 335 self.touch()
336 super(TopicLastVisit, self).save(*args, **kwargs) 336 super(TopicLastVisit, self).save(*args, **kwargs)
337 337
338 def touch(self): 338 def touch(self):
339 self.last_visit = datetime.datetime.now() 339 self.last_visit = datetime.datetime.now()
340
341
342 class Statistic(models.Model):
343 """
344 This model keeps track of forum statistics. Currently, the only statistic
345 is the maximum number of users online. This stat is computed by a mgmt.
346 command that is run on a cron job to peek at the "users_online" dict
347 that is maintained in cache by the forums middleware.
348 """
349 max_users = models.IntegerField()
350 max_users_date = models.DateTimeField()
351
352 def __unicode__(self):
353 return u'%d users on %s' % (self.max_users,
354 self.max_users_date.strftime('%Y-%m-%d %H:%M:%S'))
355
356 def save(self, *args, **kwargs):
357 self.max_users_date = datetime.datetime.now()
358 super(Statistic, self).save(*args, **kwargs)