Add sensor_data app to Django settings and URL routing
- Included sensor_data in the INSTALLED_APPS of settings.py. - Added URL path for sensor_data in urls.py to enable API access.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
# Generated by Django 5.2.11 on 2026-02-27 09:47
|
||||
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('soil_data', '0002_soildepthdata_refactor'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SensorDataHistory',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('uuid_sensor', models.UUIDField(help_text='شناسه سنسور')),
|
||||
('location_id', models.IntegerField(help_text='location_id از soil_data')),
|
||||
('soil_moisture', models.FloatField(blank=True, null=True)),
|
||||
('soil_temperature', models.FloatField(blank=True, null=True)),
|
||||
('soil_ph', models.FloatField(blank=True, null=True)),
|
||||
('electrical_conductivity', models.FloatField(blank=True, null=True)),
|
||||
('nitrogen', models.FloatField(blank=True, null=True)),
|
||||
('phosphorus', models.FloatField(blank=True, null=True)),
|
||||
('potassium', models.FloatField(blank=True, null=True)),
|
||||
('recorded_at', models.DateTimeField(auto_now_add=True, help_text='زمان ثبت در تاریخچه')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'تاریخچه داده سنسور',
|
||||
'verbose_name_plural': 'تاریخچه داده\u200cهای سنسور',
|
||||
'ordering': ['-recorded_at'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SensorParameter',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('code', models.CharField(db_index=True, help_text='کد یکتا (مثلاً soil_moisture)', max_length=64, unique=True)),
|
||||
('name_fa', models.CharField(help_text='نام فارسی', max_length=128)),
|
||||
('unit', models.CharField(blank=True, help_text='واحد اندازه\u200cگیری', max_length=32)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'پارامتر سنسور',
|
||||
'verbose_name_plural': 'پارامترهای سنسور',
|
||||
'ordering': ['code'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SensorData',
|
||||
fields=[
|
||||
('uuid_sensor', models.UUIDField(default=uuid.uuid4, editable=False, help_text='شناسه یکتای سنسور', primary_key=True, serialize=False)),
|
||||
('soil_moisture', models.FloatField(blank=True, help_text='رطوبت خاک', null=True)),
|
||||
('soil_temperature', models.FloatField(blank=True, help_text='دما خاک', null=True)),
|
||||
('soil_ph', models.FloatField(blank=True, help_text='pH خاک', null=True)),
|
||||
('electrical_conductivity', models.FloatField(blank=True, help_text='هدایت الکتریکی', null=True)),
|
||||
('nitrogen', models.FloatField(blank=True, help_text='ازت (N)', null=True)),
|
||||
('phosphorus', models.FloatField(blank=True, help_text='فسفر', null=True)),
|
||||
('potassium', models.FloatField(blank=True, help_text='پتاسیم', null=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('location', models.ForeignKey(db_column='location_id', help_text='همان location_id در soil_data', on_delete=django.db.models.deletion.CASCADE, related_name='sensor_data', to='soil_data.soillocation')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'داده سنسور',
|
||||
'verbose_name_plural': 'داده\u200cهای سنسور',
|
||||
'ordering': ['-updated_at'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ParameterUpdateLog',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('action', models.CharField(choices=[('added', 'اضافه شده'), ('modified', 'ویرایش شده')], max_length=16)),
|
||||
('updated_at', models.DateTimeField(auto_now_add=True)),
|
||||
('parameter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='update_logs', to='sensor_data.sensorparameter')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'لاگ آپدیت پارامتر',
|
||||
'verbose_name_plural': 'لاگ آپدیت پارامترها',
|
||||
'ordering': ['-updated_at'],
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,13 @@
|
||||
# Generated by Django 5.2.11 on 2026-02-27 09:48
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('sensor_data', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
||||
Reference in New Issue
Block a user