bring back plan natural sorting - really
This commit is contained in:
parent
e9e8d24685
commit
96b667dd75
1 changed files with 6 additions and 5 deletions
|
@ -7,10 +7,11 @@ from django.contrib.admin.views.decorators import staff_member_required
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
def natural_sort_key(name):
|
def natural_sort_key(obj):
|
||||||
"""Extract numeric part from compute plan name for natural sorting"""
|
"""Extract numeric parts for natural sorting (works for any plan name)"""
|
||||||
match = re.search(r"compute-std-(\d+)", name)
|
name = obj.name if hasattr(obj, 'name') else str(obj)
|
||||||
return int(match.group(1)) if match else 0
|
parts = re.split(r"(\d+)", name)
|
||||||
|
return [int(part) if part.isdigit() else part for part in parts]
|
||||||
|
|
||||||
|
|
||||||
def get_external_price_comparisons(plan, appcat_price, currency, service_level):
|
def get_external_price_comparisons(plan, appcat_price, currency, service_level):
|
||||||
|
@ -150,7 +151,7 @@ def pricelist(request):
|
||||||
key=lambda p: (
|
key=lambda p: (
|
||||||
p.group.order if p.group else 999,
|
p.group.order if p.group else 999,
|
||||||
p.group.name if p.group else "ZZZ",
|
p.group.name if p.group else "ZZZ",
|
||||||
natural_sort_key(p.name),
|
natural_sort_key(p),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue