Skip to content

Commit ad62c78

Browse files
committed
Add last modified date to TestCase and TestPlan
Add updated_at field (auto_now) to both models with migrations. Show last modified date in detail view sidebars and search result tables. Expose updated_at via RPC API filter and update responses.
1 parent 25518e5 commit ad62c78

File tree

12 files changed

+66
-0
lines changed

12 files changed

+66
-0
lines changed

tcms/rpc/api/testcase.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def filter(query=None): # pylint: disable=redefined-builtin
277277
.values(
278278
"id",
279279
"create_date",
280+
"updated_at",
280281
"is_automated",
281282
"script",
282283
"arguments",
@@ -382,6 +383,7 @@ def update(case_id, values):
382383
result = model_to_dict(test_case, exclude=["component", "plan", "tag"])
383384
# b/c date may be None and model_to_dict() doesn't return it
384385
result["create_date"] = test_case.create_date
386+
result["updated_at"] = test_case.updated_at
385387

386388
# additional information
387389
result["case_status__name"] = test_case.case_status.name

tcms/rpc/api/testplan.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def filter(query=None): # pylint: disable=redefined-builtin
9494
"name",
9595
"text",
9696
"create_date",
97+
"updated_at",
9798
"is_active",
9899
"extra_link",
99100
"product_version",
@@ -182,6 +183,7 @@ def update(plan_id, values):
182183
# b/c value is set in the DB directly and if None
183184
# model_to_dict() will not return it
184185
result["create_date"] = test_plan.create_date
186+
result["updated_at"] = test_plan.updated_at
185187
return result
186188

187189
raise ValueError(list(form.errors.items()))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 5.2.11 on 2026-02-17 15:36
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('testcases', '0023_alter_category_ordering'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='historicaltestcase',
15+
name='updated_at',
16+
field=models.DateTimeField(blank=True, editable=False, null=True),
17+
),
18+
migrations.AddField(
19+
model_name='testcase',
20+
name='updated_at',
21+
field=models.DateTimeField(auto_now=True, null=True),
22+
),
23+
]

tcms/testcases/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class TestCase(models.Model, UrlMixin):
5151
history = KiwiHistoricalRecords()
5252

5353
create_date = models.DateTimeField(auto_now_add=True)
54+
updated_at = models.DateTimeField(auto_now=True, null=True, blank=True)
5455
is_automated = models.BooleanField(default=False)
5556
script = models.TextField(blank=True, null=True)
5657
arguments = models.TextField(blank=True, null=True)

tcms/testcases/static/testcases/js/search.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export function pageTestcasesSearchReadyHandler () {
157157
}
158158
},
159159
{ data: 'create_date' },
160+
{ data: 'updated_at' },
160161
{ data: 'category__name' },
161162
{ data: 'component_names' },
162163
{ data: 'priority__value' },

tcms/testcases/templates/testcases/get.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ <h2 class="card-pf-title kiwi-text-align-left">
6969
<span class="fa fa-calendar"></span>{{ object.create_date }}
7070
</h2>
7171

72+
<h2 class="card-pf-title kiwi-text-align-left">
73+
<span class="fa fa-pencil"></span>{% trans 'Last modified' %}:
74+
{{ object.updated_at|default:"-" }}
75+
</h2>
76+
7277
<h2 class="card-pf-title kiwi-text-align-left">
7378
<span class="fa fa-clock-o"></span>{% trans 'Setup duration' %}:
7479
{{ object.setup_duration|default:"-" }}

tcms/testcases/templates/testcases/search.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
<th>{% trans "ID" %}</th>
166166
<th>{% trans "Summary" %}</th>
167167
<th>{% trans "Created on" %}</th>
168+
<th>{% trans "Last modified" %}</th>
168169
<th>{% trans "Category" %}</th>
169170
<th>{% trans "Component" %}</th>
170171
<th>{% trans "Priority" %}</th>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 5.2.11 on 2026-02-18 01:17
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('testplans', '0010_alter_historicaltestplan_options_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='historicaltestplan',
15+
name='updated_at',
16+
field=models.DateTimeField(blank=True, editable=False, null=True),
17+
),
18+
migrations.AddField(
19+
model_name='testplan',
20+
name='updated_at',
21+
field=models.DateTimeField(auto_now=True, null=True),
22+
),
23+
]

tcms/testplans/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class TestPlan(TreeNode, UrlMixin):
3232
name = models.CharField(max_length=255, db_index=True)
3333
text = models.TextField(blank=True)
3434
create_date = models.DateTimeField(auto_now_add=True)
35+
updated_at = models.DateTimeField(auto_now=True, null=True, blank=True)
3536
is_active = models.BooleanField(default=True, db_index=True)
3637
extra_link = models.CharField(max_length=1024, default=None, blank=True, null=True)
3738

tcms/testplans/static/testplans/js/search.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export function pageTestplansSearchReadyHandler () {
117117
}
118118
},
119119
{ data: 'create_date' },
120+
{ data: 'updated_at' },
120121
{ data: 'product__name' },
121122
{ data: 'product_version__value' },
122123
{ data: 'type__name' },

0 commit comments

Comments
 (0)