Files
ShooterHub/apps/common/serializer_helpers.py
2026-04-02 11:24:30 +02:00

23 lines
564 B
Python

"""Shared serializer helper functions used across multiple apps."""
def ammo_detail(ammo):
if ammo is None:
return None
cal = ammo.caliber
return {
'id': ammo.id, 'brand': ammo.brand, 'name': ammo.name,
'caliber_detail': {'id': cal.id, 'name': cal.name} if cal else None,
}
def batch_detail(batch):
if batch is None:
return None
return {
'id': batch.id,
'recipe_name': batch.recipe.name,
'powder': str(batch.powder),
'powder_charge_gr': str(batch.powder_charge_gr),
}