First commit of claude's rework in django + vanillajs fronted
This commit is contained in:
22
apps/common/serializer_helpers.py
Normal file
22
apps/common/serializer_helpers.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""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),
|
||||
}
|
||||
Reference in New Issue
Block a user