dr.botzo/seen/models.py

26 lines
780 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 __str__(self):
"""String representation of a seen nick."""
local_time = timezone.localtime(self.seen_time)
return "{0:s} seen in {1:s} at {2:s}".format(self.nick, self.channel,
local_time.strftime('%Y-%m-%d %H:%M:%S %Z'))