dr.botzo/dr_botzo/seen/models.py

28 lines
823 B
Python

from django.db import models
from django.utils import timezone
class SeenNick(models.Model):
"""Track when a nick was seen in any channel."""
nick = models.CharField(max_length=64)
channel = models.CharField(max_length=64)
host = models.CharField(max_length=255)
seen_time = models.DateTimeField(default=timezone.now)
what = models.TextField()
class Meta:
ordering = ['-seen_time',]
unique_together = ('nick', 'channel')
def __unicode__(self):
"""String representation of a seen nick."""
local_time = timezone.localtime(self.seen_time)
return u"{0:s} seen in {1:s} at {2:s}".format(self.nick, self.channel,
local_time.strftime('%Y-%m-%d %H:%M:%S %Z'))
# vi:tabstop=4:expandtab:autoindent