Library Grouping Fields (#2064) (#2065)

This commit is contained in:
daveoconnor
2026-02-10 12:35:17 -08:00
committed by GitHub
parent f31e05e8e7
commit 56dcd9cf40
3 changed files with 64 additions and 2 deletions

View File

@@ -301,11 +301,32 @@ class LibraryReportView(ReleaseReportView):
generate_library_report.delay(self.request.GET)
class TierFilter(admin.SimpleListFilter):
title = "tier"
parameter_name = "tier"
def lookups(self, request, model_admin):
from libraries.models import Tier
choices = [
("unassigned", "Unassigned"),
]
choices.extend([(tier.value, tier.label) for tier in Tier])
return choices
def queryset(self, request, queryset):
if self.value() == "unassigned":
return queryset.filter(tier__isnull=True)
elif self.value() is not None:
return queryset.filter(tier=self.value())
return queryset
@admin.register(Library)
class LibraryAdmin(admin.ModelAdmin):
list_display = ["name", "key", "github_url", "view_stats"]
list_display = ["name", "key", "tier", "github_url", "view_stats"]
search_fields = ["name", "description"]
list_filter = ["categories"]
list_filter = [TierFilter, "categories"]
ordering = ["name"]
change_list_template = "admin/library_change_list.html"
inlines = [LibraryVersionInline]

View File

@@ -0,0 +1,28 @@
# Generated by Django 5.2.8 on 2026-02-03 19:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("libraries", "0036_releasereport_locked"),
]
operations = [
migrations.AddField(
model_name="library",
name="tier",
field=models.IntegerField(
blank=True,
choices=[
(10, "Flagship"),
(20, "Core"),
(30, "Deprecated"),
(40, "Legacy"),
],
help_text="The tier classification for this library",
null=True,
),
),
]

View File

@@ -174,6 +174,13 @@ class Commit(models.Model):
return self.sha
class Tier(models.IntegerChoices):
FLAGSHIP = 10, "Flagship"
CORE = 20, "Core"
DEPRECATED = 30, "Deprecated"
LEGACY = 40, "Legacy"
class Library(models.Model):
"""
Model to represent component Libraries of Boost
@@ -241,6 +248,12 @@ class Library(models.Model):
data = models.JSONField(
default=dict, help_text="Contains the libraries.json for this library"
)
tier = models.IntegerField(
choices=Tier,
blank=True,
null=True,
help_text="The tier classification for this library",
)
class Meta:
verbose_name_plural = "Libraries"