Skip to content

Commit

Permalink
🐛 Request page: Use local time for timeline key calculation
Browse files Browse the repository at this point in the history
Fixes sentry issue 30819
  • Loading branch information
pajowu committed Oct 21, 2024
1 parent 2efa1b7 commit 762b0c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions froide/foirequest/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,11 @@ def messages_by_month(self):
due_date = self.due_date
has_overdue_messages = False
for msg in self.messages:
key = str(msg.timestamp)[:7]
local_msg_timestamp = timezone.localtime(msg.timestamp)
key = local_msg_timestamp.strftime("%Y-%m")
if key not in groups:
groups[key] = {
"date": msg.timestamp.replace(
"date": local_msg_timestamp.replace(
day=1, hour=0, minute=0, second=0, microsecond=0
),
"messages": [],
Expand Down
16 changes: 8 additions & 8 deletions froide/foirequest/templates/foirequest/body/timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<div class="alpha-timeline__wrap">
{% for group in object.messages_by_month %}
<div class="alpha-timeline__item {% if group.show_overdue_message %}alpha-timeline__item--overdue{% endif %} {% if forloop.last %}alpha-timeline__item--last{% endif %}"
data-key="{{ group.date|date:'Y-m' }}">
data-key="{{ group.start_date|date:'Y-m' }}">
<a href="#{{ group.first_message_id }}"
class="alpha-timeline__link text-decoration-none">
<div class="alpha-timeline__month">{{ group.date|date:'F Y' }}</div>
<div class="alpha-timeline__month">{{ group.start_date|date:'F Y' }}</div>
<div>
{% spaceless %}
{% blocktrans count counter=group.messages|length %}
One Message
{% plural %}
{{ counter }} Messages
{% endblocktrans %}
One Message
{% plural %}
{{ counter }} Messages
{% endblocktrans %}
{% if not group.show_overdue_message and group.indicate_overdue %}
({% trans 'overdue' %})
({% trans "overdue" %})
{% endif %}
{% endspaceless %}
</div>
Expand All @@ -35,7 +35,7 @@
<a href="#"
class="text-decoration-none alpha-timeline__scroll-end-link js-trigger-scroll-to-end">
<i class="fa fa-long-arrow-down" aria-hidden="true"></i>
{% trans 'Scroll to end' %}
{% trans "Scroll to end" %}
</a>
{% endwith %}
{% endwith %}
Expand Down

0 comments on commit 762b0c3

Please sign in to comment.