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 Apr 18, 2024
1 parent f412262 commit 5d4c0bd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
5 changes: 3 additions & 2 deletions froide/foirequest/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,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
52 changes: 25 additions & 27 deletions froide/foirequest/templates/foirequest/body/timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,37 @@
<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 %}
{% if not group.show_overdue_message and group.indicate_overdue %}
({% trans 'overdue' %})
{% endif %}
{% endspaceless %}
One Message {% plural %} {{ counter }} Messages {% endblocktrans %} {%
if not group.show_overdue_message and group.indicate_overdue %} ({% trans "overdue" %})
{% endif %}
{% endspaceless %}
</div>
{% if group.show_overdue_message %}
<div class="alpha-timeline__overdue-time">
{% blocktranslate with ago=object.due_date|relativetime %}Deadline
expired {{ ago }}{% endblocktranslate %}
</div>
{% if group.show_overdue_message %}
<div class="alpha-timeline__overdue-time">
{% blocktranslate with ago=object.due_date|relativetime %}Deadline expired {{ ago }}{% endblocktranslate %}
</div>
{% endif %}
</a>
</div>
{% endfor %}
</div>
{% with object.get_messages_by_month|last as last_month %}
{% with last_month.messages|last as last_message %}
<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' %}
{% endif %}
</a>
{% endwith %}
{% endwith %}
</div>
{% endfor %}
</div>
{% with object.get_messages_by_month|last as last_month %}
{% with
last_month.messages|last as last_message %}
<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" %}
</a>
{% endwith %}
{% endwith %}
</div>
{% endblock foirequest_timeline %}

0 comments on commit 5d4c0bd

Please sign in to comment.