mirror of
https://github.com/boostorg/website-v2.git
synced 2026-02-22 16:02:09 +00:00
@@ -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]
|
||||
|
||||
28
libraries/migrations/0037_library_tier.py
Normal file
28
libraries/migrations/0037_library_tier.py
Normal 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,
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user