1
0
Fork 0
mirror of https://github.com/Findus23/RPGnotes.git synced 2024-09-19 15:43:45 +02:00
RPGnotes/notes/models/ingameday.py

29 lines
797 B
Python
Raw Normal View History

2021-08-28 19:52:07 +02:00
from django.contrib.humanize.templatetags.humanize import ordinal
from django.db import models
from django.urls import reverse
from simple_history.models import HistoricalRecords
2021-08-29 00:20:02 +02:00
from notes.models import Session, DescriptionModel
2021-08-28 19:52:07 +02:00
class IngameDay(DescriptionModel):
day = models.PositiveIntegerField()
sessions = models.ManyToManyField(Session, related_name="ingame_days")
created = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)
history = HistoricalRecords()
class Meta:
ordering = ["-day"]
def get_absolute_url(self):
2021-08-29 00:20:02 +02:00
return reverse('daydetail', args=[self.day])
2021-08-28 19:52:07 +02:00
@property
def prettyname(self):
return ordinal(self.day) + " day"
def __str__(self):
return self.prettyname