new migrations in apps.epic & apps.lyric apps; new Token fields of latter articulate upon Room model helper fns of former; new FTs, ITs & UTs capture new behavior accordingly; new template partial content in templates/apps/gameboard
This commit is contained in:
@@ -5,6 +5,7 @@ from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
@@ -79,6 +80,11 @@ class Token(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="tokens")
|
||||
token_type = models.CharField(max_length=8, choices=TOKEN_TYPE_CHOICES)
|
||||
expires_at = models.DateTimeField(null=True, blank=True)
|
||||
current_room = models.ForeignKey(
|
||||
"epic.Room", null=True, blank=True,
|
||||
on_delete=models.SET_NULL, related_name="coin_tokens"
|
||||
)
|
||||
next_ready_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
def tooltip_name(self):
|
||||
return self.get_token_type_display()
|
||||
@@ -92,10 +98,18 @@ class Token(models.Model):
|
||||
|
||||
def tooltip_expiry(self):
|
||||
if self.token_type == self.COIN:
|
||||
if self.next_ready_at:
|
||||
return f"Ready {self.next_ready_at.strftime('%Y-%m-%d')}"
|
||||
return "no expiry"
|
||||
if self.expires_at:
|
||||
return f"Expires {self.expires_at.strftime('%Y-%m-%d')}"
|
||||
return ""
|
||||
|
||||
def tooltip_room_html(self):
|
||||
if not self.current_room_id:
|
||||
return ""
|
||||
url = reverse("epic:gatekeeper", kwargs={"room_id": self.current_room_id})
|
||||
return f'<a href="{url}">{self.current_room.name}</a>'
|
||||
|
||||
def tooltip_shoptalk(self):
|
||||
if self.token_type == self.COIN:
|
||||
|
||||
Reference in New Issue
Block a user