Make all model .created_date properties resolve to TIME_ZONE time zone. Resolve #3522.
This commit is contained in:
parent
be8c024465
commit
7b299f2cad
9 changed files with 81 additions and 116 deletions
|
|
@ -13,8 +13,8 @@ game world, policy info, rules and similar.
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.text import slugify
|
||||
|
||||
from evennia.help.manager import HelpEntryManager
|
||||
from evennia.locks.lockhandler import LockHandler
|
||||
from evennia.typeclasses.models import AliasHandler, Tag, TagHandler
|
||||
|
|
@ -79,7 +79,8 @@ class HelpEntry(SharedMemoryModel):
|
|||
help_text="tags on this object. Tags are simple string markers to "
|
||||
"identify, group and alias objects.",
|
||||
)
|
||||
# Creation date. This is not changed once the object is created.
|
||||
# Creation date. This is not changed once the object is created. This is in UTC,
|
||||
# use the property date_created to get it in local time.
|
||||
db_date_created = models.DateTimeField("creation date", editable=False, auto_now=True)
|
||||
|
||||
# Database manager
|
||||
|
|
@ -100,6 +101,11 @@ class HelpEntry(SharedMemoryModel):
|
|||
def aliases(self):
|
||||
return AliasHandler(self)
|
||||
|
||||
@property
|
||||
def date_created(self):
|
||||
"""Return the field in localized time based on settings.TIME_ZONE."""
|
||||
return timezone.localtime(self.db_date_created)
|
||||
|
||||
class Meta:
|
||||
"Define Django meta options"
|
||||
verbose_name = "Help Entry"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue