Skip to content

Commit fe8c163

Browse files
ihalaij1murhum1
authored andcommitted
Clarify times and time zones related to course updates and builds
Fixes #1128
1 parent b9e620f commit fe8c163

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

edit_course/templates/edit_course/build_log.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% load i18n %}
2+
{% load editcourse %}
23

34
{% if error %}
45
<div class="alert clearfix alert-danger" role="alert">{{ error }}</div>
@@ -11,7 +12,7 @@
1112
</tr>
1213
<tr>
1314
<td>{% translate "BUILD_INITIATED_AT" %}</td>
14-
<td>{{ request_time }}</td>
15+
<td>{{ request_time|make_timezone_aware }}</td>
1516
</tr>
1617
{% if not updated %}
1718
<tr class="warning">
@@ -21,7 +22,7 @@
2122
{% else %}
2223
<tr>
2324
<td>{% translate "BUILD_FINISHED" %}</td>
24-
<td>{{ updated_time }}</td>
25+
<td>{{ updated_time|make_timezone_aware }}</td>
2526
</tr>
2627
{% endif %}
2728
</tbody>

edit_course/templatetags/editcourse.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from datetime import datetime
2+
13
from django import template
24
from django.urls import reverse
5+
from django.utils import timezone
36

47
from course.models import CourseInstance
58

@@ -56,3 +59,15 @@ def createurl(model_object, model_name):
5659
model_name,
5760
parent_id=model_object.id,
5861
))
62+
63+
64+
@register.filter
65+
def make_timezone_aware(utc_time_str):
66+
try:
67+
# Parse the Zulu date and time string into a naive datetime object
68+
naive_datetime = datetime.strptime(utc_time_str, "%Y-%m-%dT%H:%M:%S.%fZ")
69+
# Convert it to a timezone-aware datetime object
70+
aware_datetime = timezone.make_aware(naive_datetime, timezone.utc)
71+
return aware_datetime
72+
except ValueError:
73+
return utc_time_str # Return the original string if parsing fails

locale/en/LC_MESSAGES/django.po

+3-3
Original file line numberDiff line numberDiff line change
@@ -2601,11 +2601,11 @@ msgstr ""
26012601

26022602
#: edit_course/templates/edit_course/build_log.html
26032603
msgid "BUILD_INITIATED_BY"
2604-
msgstr "Build initated by"
2604+
msgstr "Build initiated by"
26052605

26062606
#: edit_course/templates/edit_course/build_log.html
26072607
msgid "BUILD_INITIATED_AT"
2608-
msgstr "Build initated at"
2608+
msgstr "Build initiated at"
26092609

26102610
#: edit_course/templates/edit_course/build_log.html
26112611
msgid "BUILD_FINISHED"
@@ -2678,7 +2678,7 @@ msgstr "Retrieve latest build log"
26782678

26792679
#: edit_course/templates/edit_course/edit_content.html
26802680
msgid "PREV_MODIFICATION_OF_COURSE_INSTANCE_TIME"
2681-
msgstr "Previous modification of this course instance took place at"
2681+
msgstr "This course was previously built or the course settings were modified on"
26822682

26832683
#: edit_course/templates/edit_course/edit_content.html
26842684
msgid "EXERCISE_CATEGORIES"

locale/fi/LC_MESSAGES/django.po

+1-1
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,7 @@ msgstr "Hae uusin käännösloki"
26952695

26962696
#: edit_course/templates/edit_course/edit_content.html
26972697
msgid "PREV_MODIFICATION_OF_COURSE_INSTANCE_TIME"
2698-
msgstr "Kurssia on viimeksi muokattu"
2698+
msgstr "Tämä kurssi on viimeksi käännetty tai kurssin asetuksia on muokattu"
26992699

27002700
#: edit_course/templates/edit_course/edit_content.html
27012701
msgid "EXERCISE_CATEGORIES"

0 commit comments

Comments
 (0)