diff --git a/apps/livestock/migrations/0012_livestocktype_weight_type.py b/apps/livestock/migrations/0012_livestocktype_weight_type.py new file mode 100644 index 0000000..bf87837 --- /dev/null +++ b/apps/livestock/migrations/0012_livestocktype_weight_type.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0 on 2025-07-14 08:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('livestock', '0011_remove_livestock_age_by_day_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='livestocktype', + name='weight_type', + field=models.CharField(choices=[('L', 'Light'), ('H', 'Heavy')], max_length=50, null=True), + ), + ] diff --git a/apps/livestock/models.py b/apps/livestock/models.py index 9b16286..4efc1a5 100644 --- a/apps/livestock/models.py +++ b/apps/livestock/models.py @@ -18,6 +18,15 @@ class LiveStockSpecies(BaseModel): # noqa class LiveStockType(BaseModel): # noqa """ types like sheep, cow, camel, etc """ name = models.CharField(max_length=50) + weight_types = ( + ('L', 'Light'), + ('H', 'Heavy') + ) + weight_type = models.CharField( + choices=weight_types, + max_length=50, + null=True + ) def __str__(self): return f'{self.name}' diff --git a/apps/livestock/web/api/v1/serializers.py b/apps/livestock/web/api/v1/serializers.py index 0e718d9..3645f1a 100644 --- a/apps/livestock/web/api/v1/serializers.py +++ b/apps/livestock/web/api/v1/serializers.py @@ -9,7 +9,8 @@ class LiveStockTypeSerializer(serializers.ModelSerializer): model = livestock_models.LiveStockType fields = [ 'id', - 'name' + 'name', + 'weight_type' ] diff --git a/apps/product/web/api/v1/viewsets/product_api.py b/apps/product/web/api/v1/viewsets/product_api.py index 0d1a72f..64c26a9 100644 --- a/apps/product/web/api/v1/viewsets/product_api.py +++ b/apps/product/web/api/v1/viewsets/product_api.py @@ -9,6 +9,8 @@ from rest_framework import status from django.db import transaction from django.db.models import Q from datetime import datetime +from asgiref.sync import sync_to_async, async_to_sync +from django.http import JsonResponse def trash(queryset, pk): # noqa