improved the way we get the last package id_number

This commit is contained in:
Arron Schaar 2012-02-13 13:55:18 -08:00
Родитель 3b29304931
Коммит 5b19120dac
1 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -2381,10 +2381,12 @@ def _get_next_id_number():
"""
get the highest id number and increment it
"""
all_packages_ids = [int(x.id_number) for x in Package.objects.all()]
all_packages_ids.sort()
return str(all_packages_ids[-1] + 1) \
if all_packages_ids else str(settings.MINIMUM_PACKAGE_ID)
last_id = Package.objects.order_by('-id')[0].id_number
if last_id:
return str(int(last_id) + 1)
else:
return str(settings.MINIMUM_PACKAGE_ID)
# Catching Signals