Skip to content

Commit d93fc95

Browse files
committed
- release 7.3.2
- fixed migration failing when adjustment requests are referencing a delete usage event or area access record (displaying a warning instead)
1 parent cd72d69 commit d93fc95

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

NEMO/migrations/0129_adjustmentrequest_original_end_and_more.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Generated by Django 4.2.24 on 2025-09-29 19:46
2+
from logging import getLogger
23

34
import django.db.models.deletion
45
from django.db import migrations, models
@@ -8,34 +9,39 @@ def set_adj_request_original_item_data(apps, schema_editor):
89
AdjustmentRequest = apps.get_model("NEMO", "AdjustmentRequest")
910
for adj in AdjustmentRequest.objects.filter(item_type__isnull=False, item_id__isnull=False):
1011
model = apps.get_model(adj.item_type.app_label, adj.item_type.model)
11-
item = model.objects.get(pk=adj.item_id)
12-
if item:
13-
updated = False
14-
tool_id = getattr(item, "tool_id", None)
15-
area_id = getattr(item, "area_id", None)
16-
if tool_id:
17-
adj.item_tool_id = tool_id
18-
updated = True
19-
if area_id:
20-
adj.item_area_id = area_id
21-
updated = True
22-
if adj.status == 0:
23-
for att in ["start", "end", "quantity", "project_id"]:
24-
item_att = getattr(item, att, None)
25-
if item_att:
26-
setattr(adj, f"original_{att}", item_att)
27-
updated = True
28-
if updated:
29-
adj.save(
30-
update_fields=[
31-
"item_tool_id",
32-
"item_area_id",
33-
"original_start",
34-
"original_end",
35-
"original_quantity",
36-
"original_project_id",
37-
]
38-
)
12+
try:
13+
item = model.objects.get(pk=adj.item_id)
14+
if item:
15+
updated = False
16+
tool_id = getattr(item, "tool_id", None)
17+
area_id = getattr(item, "area_id", None)
18+
if tool_id:
19+
adj.item_tool_id = tool_id
20+
updated = True
21+
if area_id:
22+
adj.item_area_id = area_id
23+
updated = True
24+
if adj.status == 0:
25+
for att in ["start", "end", "quantity", "project_id"]:
26+
item_att = getattr(item, att, None)
27+
if item_att:
28+
setattr(adj, f"original_{att}", item_att)
29+
updated = True
30+
if updated:
31+
adj.save(
32+
update_fields=[
33+
"item_tool_id",
34+
"item_area_id",
35+
"original_start",
36+
"original_end",
37+
"original_quantity",
38+
"original_project_id",
39+
]
40+
)
41+
except model.DoesNotExist:
42+
getLogger(__name__).warning(
43+
f"Adjustment request {adj.id} references non-existent {adj.item_type.model} ({adj.item_type}) with ID {adj.item_id}"
44+
)
3945

4046

4147
class Migration(migrations.Migration):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "NEMO"
3-
version = "7.3.1"
3+
version = "7.3.2"
44
description = "NEMO is a laboratory logistics web application. Use it to schedule reservations, control tool access, track maintenance issues, and more."
55
keywords = ["NEMO"]
66
readme = "README.md"

0 commit comments

Comments
 (0)