Skip to content

Commit

Permalink
Clarify times and time zones related to course updates and builds
Browse files Browse the repository at this point in the history
Fixes #1128
  • Loading branch information
ihalaij1 authored and murhum1 committed Jan 24, 2025
1 parent b9e620f commit fe8c163
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
5 changes: 3 additions & 2 deletions edit_course/templates/edit_course/build_log.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load i18n %}
{% load editcourse %}

{% if error %}
<div class="alert clearfix alert-danger" role="alert">{{ error }}</div>
Expand All @@ -11,7 +12,7 @@
</tr>
<tr>
<td>{% translate "BUILD_INITIATED_AT" %}</td>
<td>{{ request_time }}</td>
<td>{{ request_time|make_timezone_aware }}</td>
</tr>
{% if not updated %}
<tr class="warning">
Expand All @@ -21,7 +22,7 @@
{% else %}
<tr>
<td>{% translate "BUILD_FINISHED" %}</td>
<td>{{ updated_time }}</td>
<td>{{ updated_time|make_timezone_aware }}</td>
</tr>
{% endif %}
</tbody>
Expand Down
15 changes: 15 additions & 0 deletions edit_course/templatetags/editcourse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from datetime import datetime

from django import template
from django.urls import reverse
from django.utils import timezone

from course.models import CourseInstance

Expand Down Expand Up @@ -56,3 +59,15 @@ def createurl(model_object, model_name):
model_name,
parent_id=model_object.id,
))


@register.filter
def make_timezone_aware(utc_time_str):
try:
# Parse the Zulu date and time string into a naive datetime object
naive_datetime = datetime.strptime(utc_time_str, "%Y-%m-%dT%H:%M:%S.%fZ")
# Convert it to a timezone-aware datetime object
aware_datetime = timezone.make_aware(naive_datetime, timezone.utc)
return aware_datetime
except ValueError:
return utc_time_str # Return the original string if parsing fails
6 changes: 3 additions & 3 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2601,11 +2601,11 @@ msgstr ""

#: edit_course/templates/edit_course/build_log.html
msgid "BUILD_INITIATED_BY"
msgstr "Build initated by"
msgstr "Build initiated by"

#: edit_course/templates/edit_course/build_log.html
msgid "BUILD_INITIATED_AT"
msgstr "Build initated at"
msgstr "Build initiated at"

#: edit_course/templates/edit_course/build_log.html
msgid "BUILD_FINISHED"
Expand Down Expand Up @@ -2678,7 +2678,7 @@ msgstr "Retrieve latest build log"

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

#: edit_course/templates/edit_course/edit_content.html
msgid "EXERCISE_CATEGORIES"
Expand Down
2 changes: 1 addition & 1 deletion locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2695,7 +2695,7 @@ msgstr "Hae uusin käännösloki"

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

#: edit_course/templates/edit_course/edit_content.html
msgid "EXERCISE_CATEGORIES"
Expand Down

0 comments on commit fe8c163

Please sign in to comment.