UPDATE
This commit is contained in:
@@ -7,7 +7,7 @@ from django.db import migrations, models
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("sensor_catalog", "0002_sensorcatalog_supported_power_sources"),
|
||||
("device_hub", "0001_initial"),
|
||||
("farm_hub", "0002_seed_default_catalog"),
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@ class Migration(migrations.Migration):
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name="farm_sensors",
|
||||
to="sensor_catalog.sensorcatalog",
|
||||
to="device_hub.sensorcatalog",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("device_hub", "0001_initial"),
|
||||
("farm_hub", "0009_farmhub_irrigation_method_fields"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.SeparateDatabaseAndState(
|
||||
database_operations=[],
|
||||
state_operations=[
|
||||
migrations.DeleteModel(name="FarmSensor"),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -2,7 +2,6 @@ import uuid as uuid_lib
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from sensor_catalog.models import SensorCatalog
|
||||
|
||||
|
||||
class FarmType(models.Model):
|
||||
@@ -123,33 +122,3 @@ class FarmHub(models.Model):
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.farm_uuid})"
|
||||
|
||||
|
||||
class FarmSensor(models.Model):
|
||||
uuid = models.UUIDField(default=uuid_lib.uuid4, unique=True, editable=False, db_index=True)
|
||||
farm = models.ForeignKey(
|
||||
FarmHub,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="sensors",
|
||||
)
|
||||
sensor_catalog = models.ForeignKey(
|
||||
SensorCatalog,
|
||||
on_delete=models.PROTECT,
|
||||
related_name="farm_sensors",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
physical_device_uuid = models.UUIDField(default=uuid_lib.uuid4, unique=True, db_index=True)
|
||||
name = models.CharField(max_length=255)
|
||||
sensor_type = models.CharField(max_length=255, blank=True, default="")
|
||||
is_active = models.BooleanField(default=True)
|
||||
specifications = models.JSONField(default=dict, blank=True)
|
||||
power_source = models.JSONField(default=dict, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "farm_sensors"
|
||||
ordering = ["-created_at"]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.uuid})"
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ import uuid
|
||||
from django.db import transaction
|
||||
|
||||
from account.seeds import seed_admin_user
|
||||
from sensor_catalog.management import seed_sensor_catalog
|
||||
from sensor_catalog.models import SensorCatalog
|
||||
from device_hub.catalog_seed import seed_sensor_catalog
|
||||
from device_hub.models import SensorCatalog
|
||||
|
||||
from .catalog import CATALOG_SEED_DATA
|
||||
from .models import FarmHub, FarmType, Product
|
||||
|
||||
@@ -3,10 +3,10 @@ from access_control.models import SubscriptionPlan
|
||||
from access_control.serializers import SubscriptionPlanSerializer
|
||||
from access_control.catalog import GOLD_PLAN_CODE
|
||||
from access_control.services import get_effective_subscription_plan
|
||||
from device_hub.models import FarmSensor, SensorCatalog
|
||||
|
||||
from .models import FarmHub, FarmSensor, FarmType, Product
|
||||
from .models import FarmHub, FarmType, Product
|
||||
from .services import normalize_farm_boundary_input
|
||||
from sensor_catalog.models import SensorCatalog
|
||||
|
||||
|
||||
class FarmTypeSerializer(serializers.ModelSerializer):
|
||||
|
||||
@@ -11,6 +11,7 @@ from crop_zoning.services import (
|
||||
)
|
||||
from external_api_adapter import request as external_api_request
|
||||
from external_api_adapter.exceptions import ExternalAPIRequestError
|
||||
from plants.services import push_plants_to_ai
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -65,6 +66,7 @@ def sync_farm_data(
|
||||
plant_ids=None,
|
||||
irrigation_method_id=None,
|
||||
):
|
||||
push_plants_to_ai()
|
||||
request_payload = {
|
||||
"farm_uuid": str(farm.farm_uuid),
|
||||
"farm_boundary": _extract_boundary_geometry(area_feature, farm=farm),
|
||||
|
||||
+1
-1
@@ -7,12 +7,12 @@ from access_control.models import AccessFeature, AccessRule, FarmAccessProfile,
|
||||
from access_control.services import build_farm_access_profile
|
||||
from access_control.views import FarmAccessProfileView
|
||||
from crop_zoning.models import CropArea
|
||||
from device_hub.models import SensorCatalog
|
||||
from external_api_adapter.adapter import AdapterResponse
|
||||
from farm_hub.models import FarmHub, FarmType, Product
|
||||
from farm_hub.serializers import FarmHubSerializer
|
||||
from farm_hub.seeds import seed_admin_farm
|
||||
from farm_hub.views import FarmDetailView, FarmListCreateView, FarmTypeListView, FarmTypeProductsView
|
||||
from sensor_catalog.models import SensorCatalog
|
||||
|
||||
|
||||
AREA_GEOJSON = {
|
||||
|
||||
Reference in New Issue
Block a user