Skip to content

Commit 4333be4

Browse files
committed
feat(tool-picker): add tool_owners field on tool model
- Add tool_owner M2M field on the Tool model - Update seed data
1 parent bc9dffe commit 4333be4

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

apps/tool_picker/admin.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class CheckboxQuestionBulkAdmin(UserResourceAdmin, admin.ModelAdmin): # type: i
145145
)
146146

147147
@typing.override
148-
def get_queryset(self, request): # type: ignore[reportMissingTypeArgument]
148+
def get_queryset(self, request: typing.Any):
149149
"""Only show checkbox questions."""
150150
qs = super().get_queryset(request)
151151
return qs.filter(question_type=QuestionTypeEnum.CHECKBOX)
@@ -256,13 +256,26 @@ class ToolAdmin(UserResourceAdmin, admin.ModelAdmin): # type: ignore[reportMiss
256256
"video_link",
257257
"tool_link",
258258
"tool_sectors",
259-
"display_categories",
259+
"tool_owners",
260260
"tool_features",
261261
"logo",
262262
),
263263
},
264264
),
265265
)
266+
autocomplete_fields = ("tool_sectors", "tool_owners", "tool_features")
267+
268+
@typing.override
269+
def get_queryset(self, request: typing.Any):
270+
return (
271+
super()
272+
.get_queryset(request)
273+
.prefetch_related(
274+
"tool_sectors",
275+
"tool_owners",
276+
"tool_features",
277+
)
278+
)
266279

267280
inlines = [ToolAnswerOrdinalInline, ToolAnswerCheckboxInline]
268281

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 5.2.9 on 2026-02-10 11:09
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('tool_picker', '0003_toolfeature_sector_tool_tool_sectors_and_more'),
11+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='tool',
17+
name='tool_owners',
18+
field=models.ManyToManyField(blank=True, related_name='tool_owners', to=settings.AUTH_USER_MODEL),
19+
),
20+
]

apps/tool_picker/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class Tool(UserResource):
148148
)
149149
tool_sectors = models.ManyToManyField(Sector, related_name="tool_sectors", blank=True)
150150
tool_features = models.ManyToManyField(ToolFeature, related_name="tool_features", blank=True)
151+
tool_owners = models.ManyToManyField(User, related_name="tool_owners", blank=True)
151152

152153
class Meta(UserResource.Meta):
153154
ordering = ["catalog", "name"]

seed-data/db_seed.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,9 @@
862862
46,
863863
47,
864864
48
865+
],
866+
"tool_owners": [
867+
8
865868
]
866869
}
867870
},
@@ -925,6 +928,9 @@
925928
46,
926929
47,
927930
48
931+
],
932+
"tool_owners": [
933+
8
928934
]
929935
}
930936
},
@@ -988,6 +994,9 @@
988994
46,
989995
47,
990996
48
997+
],
998+
"tool_owners": [
999+
8
9911000
]
9921001
}
9931002
},
@@ -1051,6 +1060,9 @@
10511060
46,
10521061
47,
10531062
48
1063+
],
1064+
"tool_owners": [
1065+
8
10541066
]
10551067
}
10561068
},

0 commit comments

Comments
 (0)