Skip to content

Commit cb62265

Browse files
Merge pull request GhostManager#758 from GhostManager/copilot/fix-projects-sorting-issue
Fix execution window sorting for non-English locales and use user's date format preference
2 parents a92b20e + 4aa681e commit cb62265

File tree

7 files changed

+26
-11
lines changed

7 files changed

+26
-11
lines changed

ghostwriter/rolodex/templates/rolodex/client_detail.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ <h4>Client Projects</h4>
258258
<td class="align-middle text-left"><span class="blurry">REDACTED</span></td>
259259
{% endif %}
260260
<td class="align-middle text-left">{{ project.project_type }}</td>
261-
<td class="align-middle text-left">{{ project.start_date|date:"d M Y" }}
262-
– {{ project.end_date|date:"d M Y" }}</td>
261+
<td class="align-middle text-left" data-text="{{ project.start_date|date:"Y-m-d" }}">{{ project.start_date|date:"DATE_FORMAT" }}
262+
– {{ project.end_date|date:"DATE_FORMAT" }}</td>
263263

264264
<td class="align-middle">
265265
<div class="d-flex justify-content-center">

ghostwriter/rolodex/templates/rolodex/project_detail.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ <h4>Project Team Assignments</h4>
174174
</a>
175175
</td>
176176
<td class="align-middle text-left">{{ operator.role }}</td>
177-
<td class="align-middle text-left">{{ operator.start_date|date:"d M Y" }} –
178-
<br/> {{ operator.end_date|date:"d M Y" }}</td>
177+
<td class="align-middle text-left" data-text="{{ operator.start_date|date:"Y-m-d" }}">{{ operator.start_date|date:"DATE_FORMAT" }} –
178+
<br/> {{ operator.end_date|date:"DATE_FORMAT" }}</td>
179179
<td class="text-justify align-middle text-left">{{ operator.note|bleach }}</td>
180180
{% if request.user|is_privileged %}
181181
<td class="align-middle">
@@ -720,7 +720,7 @@ <h4>Domains</h4>
720720
</span>
721721
</td>
722722
<td class="align-middle text-left">{{ domain.activity_type }}</td>
723-
<td class="align-middle text-left">{{ domain.start_date|date:"d M Y" }} – <br/>{{ domain.end_date|date:"d M Y" }}
723+
<td class="align-middle text-left" data-text="{{ domain.start_date|date:"Y-m-d" }}">{{ domain.start_date|date:"DATE_FORMAT" }} – <br/>{{ domain.end_date|date:"DATE_FORMAT" }}
724724
</td>
725725

726726
<td class="align-middle">

ghostwriter/rolodex/templates/rolodex/project_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<td class="align-middle text-left"><a class="clickable" href="{{ project.get_absolute_url }}">{{ project.codename }}</a>
5050
</td>
5151
<td class="align-middle text-left">{{ project.project_type }}</td>
52-
<td class="align-middle text-left">{{ project.start_date|date:"d M Y" }} – {{ project.end_date|date:"d M Y" }}</td>
52+
<td class="align-middle text-left" data-text="{{ project.start_date|date:"Y-m-d" }}">{{ project.start_date|date:"DATE_FORMAT" }} – {{ project.end_date|date:"DATE_FORMAT" }}</td>
5353
<td class="align-middle">
5454
<div class="d-flex justify-content-center">
5555
<span

ghostwriter/rolodex/tests/test_views.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,21 @@ def test_codename_filtering(self):
807807
self.assertEqual(response.status_code, 200)
808808
self.assertEqual(len(response.context["filter"].qs), 1)
809809

810+
def test_date_sort_attribute_in_template(self):
811+
"""Test that execution window cells have data-text attribute for locale-independent sorting."""
812+
response = self.client_mgr.get(self.uri)
813+
self.assertEqual(response.status_code, 200)
814+
815+
# Check that the response contains data-text attribute with ISO date format
816+
content = response.content.decode('utf-8')
817+
self.assertIn('data-text="', content, "data-text attribute should be present in the template")
818+
819+
# Verify each project in the queryset has its start_date in the data-text attribute
820+
for project in response.context["filter"].qs:
821+
expected_sort_value = project.start_date.strftime("%Y-%m-%d")
822+
self.assertIn(f'data-text="{expected_sort_value}"', content,
823+
f"Project {project.codename} should have data-text attribute with ISO date {expected_sort_value}")
824+
810825

811826
class AssignProjectContactViewTests(TestCase):
812827
"""Collection of tests for :view:`rolodex.AssignProjectContact`."""

ghostwriter/shepherd/templates/shepherd/domain_detail.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ <h4>Domain History</h4>
290290
{% endif %}
291291
</td>
292292
<td class="align-middle text-left">{{ checkout.activity_type }}</td>
293-
<td class="align-middle text-left">{{ checkout.start_date|date:"d M Y" }}
294-
– {{ checkout.end_date|date:"d M Y" }}</td>
293+
<td class="align-middle text-left" data-text="{{ checkout.start_date|date:"Y-m-d" }}">{{ checkout.start_date|date:"DATE_FORMAT" }}
294+
– {{ checkout.end_date|date:"DATE_FORMAT" }}</td>
295295
<td class="align-middle text-left">
296296
{% if checkout.project|has_access:request.user %}
297297
<div class="d-flex justify-content-center">

ghostwriter/shepherd/templates/shepherd/server_detail.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ <h4>Server History</h4>
155155
</td>
156156
<td class="align-middle text-left">{{ checkout.activity_type }}</td>
157157
<td class="align-middle text-left">{{ checkout.server_role }}</td>
158-
<td class="align-middle text-left">{{ checkout.start_date|date:"d M Y" }}
159-
- {{ checkout.end_date|date:"d M Y" }}</td>
158+
<td class="align-middle text-left" data-text="{{ checkout.start_date|date:"Y-m-d" }}">{{ checkout.start_date|date:"DATE_FORMAT" }}
159+
- {{ checkout.end_date|date:"DATE_FORMAT" }}</td>
160160
<td class="align-middle">
161161
{% if checkout.project|has_access:request.user %}
162162
<div class="d-flex justify-content-center">

ghostwriter/users/templates/users/profile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ <h4 class="icon assignment-icon pt-4">Active Project Assignments</h4>
124124
<tr id="assignment_{{ assignment.id }}">
125125
<td class="align-middle text-left"><a class="clickable" href="{{ assignment.project.get_absolute_url }}">{{ assignment.project.codename|bleach }}</a>
126126
<td class="align-middle text-left">{{ assignment.role }}</td>
127-
<td class="align-middle text-left">{{ assignment.start_date|date:"d M Y" }} – {{ assignment.end_date|date:"d M Y" }}</td>
127+
<td class="align-middle text-left" data-text="{{ assignment.start_date|date:"Y-m-d" }}">{{ assignment.start_date|date:"DATE_FORMAT" }} – {{ assignment.end_date|date:"DATE_FORMAT" }}</td>
128128
</tr>
129129
{% endif %}
130130
{% endfor %}

0 commit comments

Comments
 (0)