2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Fixed cave order

This commit is contained in:
expo 2012-08-05 19:26:24 +02:00
parent 9654e5da1c
commit ed1d273e03

View File

@ -21,14 +21,26 @@ def getCave(cave_id):
cave = Cave.objects.get(unofficial_number=cave_id)
return cave
def pad5(x):
return "0" * (5 -len(x.group(0))) + x.group(0)
def padnumber(x):
return re.sub("\d+", pad5, x)
def numericalcmp(x, y):
return cmp(padnumber(x), padnumber(y))
def caveCmp(x, y):
if x.kataster_number:
if y.kataster_number:
return cmp(x.kataster_number, y.kataster_number)
return numericalcmp(x.kataster_number, y.kataster_number)
else:
return -1
else:
return 1
if y.kataster_number:
return 1
else:
return numericalcmp(x.unofficial_number, y.unofficial_number)
def caveindex(request):
caves = Cave.objects.all()