Show comment posted time in the event's local time
This commit is contained in:
parent
6291ff26e9
commit
3f4677a976
2 changed files with 12 additions and 1 deletions
|
@ -106,6 +106,13 @@ class Event(models.Model):
|
||||||
else:
|
else:
|
||||||
return settings.TIME_ZONE
|
return settings.TIME_ZONE
|
||||||
|
|
||||||
|
def localize_datetime(self, val):
|
||||||
|
if val is not None:
|
||||||
|
event_tz = pytz.timezone(self.tz)
|
||||||
|
return timezone.make_naive(val.astimezone(event_tz), event_tz)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def local_start_time(self, val=None):
|
def local_start_time(self, val=None):
|
||||||
if val is not None:
|
if val is not None:
|
||||||
|
@ -290,6 +297,10 @@ class EventComment(MPTTModel):
|
||||||
status = models.SmallIntegerField(choices=STATUSES, default=APPROVED, db_index=True)
|
status = models.SmallIntegerField(choices=STATUSES, default=APPROVED, db_index=True)
|
||||||
parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True, on_delete=models.SET_NULL)
|
parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True, on_delete=models.SET_NULL)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def local_created_time(self):
|
||||||
|
return self.event.localize_datetime(self.created_time)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s at %s' % (self.author, self.created_time)
|
return '%s at %s' % (self.author, self.created_time)
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@
|
||||||
<span class="gt-profile-badges">{% for badge in node.author.user.account.badges.all %}<img class="mr-0 gt-profile-badge" src="{{badge.img_url}}" title="{{badge.name}}" width="16px" height="16px">{% endfor %}</span>
|
<span class="gt-profile-badges">{% for badge in node.author.user.account.badges.all %}<img class="mr-0 gt-profile-badge" src="{{badge.img_url}}" title="{{badge.name}}" width="16px" height="16px">{% endfor %}</span>
|
||||||
<a href="{% url 'show-profile' node.author.id %}" title="{{node.author}}'s profile">{{node.author}}</a>
|
<a href="{% url 'show-profile' node.author.id %}" title="{{node.author}}'s profile">{{node.author}}</a>
|
||||||
</div>
|
</div>
|
||||||
<span>{{ node.created_time }}</span>
|
<span>{{ node.local_created_time }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
Loading…
Reference in a new issue