Fixed cave order

This commit is contained in:
expo 2012-08-05 19:26:24 +02:00
parent 0785455bac
commit 2208f0748b

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:
if y.kataster_number:
return 1
else:
return numericalcmp(x.unofficial_number, y.unofficial_number)
def caveindex(request):
caves = Cave.objects.all()