Skip to content

Commit 56dcd9c

Browse files
authored
Library Grouping Fields (#2064) (#2065)
1 parent f31e05e commit 56dcd9c

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

libraries/admin.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,32 @@ def generate_report(self):
301301
generate_library_report.delay(self.request.GET)
302302

303303

304+
class TierFilter(admin.SimpleListFilter):
305+
title = "tier"
306+
parameter_name = "tier"
307+
308+
def lookups(self, request, model_admin):
309+
from libraries.models import Tier
310+
311+
choices = [
312+
("unassigned", "Unassigned"),
313+
]
314+
choices.extend([(tier.value, tier.label) for tier in Tier])
315+
return choices
316+
317+
def queryset(self, request, queryset):
318+
if self.value() == "unassigned":
319+
return queryset.filter(tier__isnull=True)
320+
elif self.value() is not None:
321+
return queryset.filter(tier=self.value())
322+
return queryset
323+
324+
304325
@admin.register(Library)
305326
class LibraryAdmin(admin.ModelAdmin):
306-
list_display = ["name", "key", "github_url", "view_stats"]
327+
list_display = ["name", "key", "tier", "github_url", "view_stats"]
307328
search_fields = ["name", "description"]
308-
list_filter = ["categories"]
329+
list_filter = [TierFilter, "categories"]
309330
ordering = ["name"]
310331
change_list_template = "admin/library_change_list.html"
311332
inlines = [LibraryVersionInline]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 5.2.8 on 2026-02-03 19:44
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("libraries", "0036_releasereport_locked"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="library",
15+
name="tier",
16+
field=models.IntegerField(
17+
blank=True,
18+
choices=[
19+
(10, "Flagship"),
20+
(20, "Core"),
21+
(30, "Deprecated"),
22+
(40, "Legacy"),
23+
],
24+
help_text="The tier classification for this library",
25+
null=True,
26+
),
27+
),
28+
]

libraries/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ def __str__(self):
174174
return self.sha
175175

176176

177+
class Tier(models.IntegerChoices):
178+
FLAGSHIP = 10, "Flagship"
179+
CORE = 20, "Core"
180+
DEPRECATED = 30, "Deprecated"
181+
LEGACY = 40, "Legacy"
182+
183+
177184
class Library(models.Model):
178185
"""
179186
Model to represent component Libraries of Boost
@@ -241,6 +248,12 @@ class Library(models.Model):
241248
data = models.JSONField(
242249
default=dict, help_text="Contains the libraries.json for this library"
243250
)
251+
tier = models.IntegerField(
252+
choices=Tier,
253+
blank=True,
254+
null=True,
255+
help_text="The tier classification for this library",
256+
)
244257

245258
class Meta:
246259
verbose_name_plural = "Libraries"

0 commit comments

Comments
 (0)