initial work on comparison
This commit is contained in:
parent
06b4cba4bc
commit
4cffe5a9e3
6 changed files with 358 additions and 2 deletions
|
@ -22,6 +22,7 @@ from ..models import (
|
|||
VSHNAppCatUnitRate,
|
||||
ProgressiveDiscountModel,
|
||||
DiscountTier,
|
||||
ExternalPricePlans,
|
||||
)
|
||||
|
||||
|
||||
|
@ -308,3 +309,33 @@ class StoragePlanAdmin(ImportExportModelAdmin):
|
|||
return format_html("<br>".join([f"{p.amount} {p.currency}" for p in prices]))
|
||||
|
||||
display_prices.short_description = "Prices (Amount Currency)"
|
||||
|
||||
|
||||
@admin.register(ExternalPricePlans)
|
||||
class ExternalPricePlansAdmin(admin.ModelAdmin):
|
||||
"""Admin configuration for ExternalPricePlans model"""
|
||||
|
||||
list_display = (
|
||||
"plan_name",
|
||||
"cloud_provider",
|
||||
"service",
|
||||
"currency",
|
||||
"amount",
|
||||
"display_compare_to_count",
|
||||
"date_retrieved",
|
||||
)
|
||||
list_filter = ("cloud_provider", "service", "currency", "term")
|
||||
search_fields = ("plan_name", "cloud_provider__name", "service__name")
|
||||
ordering = ("cloud_provider", "service", "plan_name")
|
||||
|
||||
# Configure many-to-many field display
|
||||
filter_horizontal = ("compare_to",)
|
||||
|
||||
def display_compare_to_count(self, obj):
|
||||
"""Display count of compute plans this external price compares to"""
|
||||
count = obj.compare_to.count()
|
||||
if count == 0:
|
||||
return "No comparisons"
|
||||
return f"{count} plan{'s' if count != 1 else ''}"
|
||||
|
||||
display_compare_to_count.short_description = "Compare To"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue