Docs: начальная структура проекта

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-25 14:59:46 +00:00
commit 1669c12182
56 changed files with 2085 additions and 0 deletions

12
app/documents/services.py Normal file
View File

@@ -0,0 +1,12 @@
from django.db.models import Max
def next_number(model_class, field_name="number"):
"""Следующий номер по порядку (максимум + 1). Для числоподобных строк."""
agg = model_class.objects.aggregate(m=Max(field_name))
current = agg["m"]
if current is None:
return "1"
try:
return str(int(current) + 1)
except (ValueError, TypeError):
return "1"