dr.botzo/countdown/models.py
Brian S. Stephan a03c69258f use per-server IrcChannel for reminders
this makes it so that if we have multiple bot instances running, they
will only pay attention to the countdown items for their current server
2021-04-25 21:04:11 -05:00

28 lines
1.0 KiB
Python

"""Countdown item models."""
from django.db import models
from django.utils import timezone
class CountdownItem(models.Model):
"""Track points in time."""
name = models.CharField(max_length=64, default='')
at_time = models.DateTimeField()
is_reminder = models.BooleanField(default=False)
sent_reminder = models.BooleanField(default=False)
reminder_message = models.TextField(default="")
reminder_target = models.CharField(max_length=64, blank=True, default='')
reminder_target_new = models.ForeignKey('ircbot.IrcChannel', null=True, blank=True,
default=None, on_delete=models.CASCADE)
recurring_period = models.CharField(max_length=64, blank=True, default='')
recurring_until = models.DateTimeField(null=True, blank=True, default=None)
created_time = models.DateTimeField(auto_now_add=True)
def __str__(self):
"""Summarize object."""
return "{0:s} @ {1:s}".format(self.name, timezone.localtime(self.at_time).strftime('%Y-%m-%d %H:%M:%S %Z'))