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
|
||||
|
||||
|
||||
def natural_sort_key(name):
|
||||
"""Extract numeric part from compute plan name for natural sorting"""
|
||||
match = re.search(r"compute-std-(\d+)", name)
|
||||
return int(match.group(1)) if match else 0
|
||||
def natural_sort_key(obj):
|
||||
"""Extract numeric parts for natural sorting (works for any plan name)"""
|
||||
name = obj.name if hasattr(obj, 'name') else str(obj)
|
||||
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):
|
||||
|
@ -150,7 +151,7 @@ def pricelist(request):
|
|||
key=lambda p: (
|
||||
p.group.order if p.group else 999,
|
||||
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