Skip to content

Home Information - Your home, your data, organized.

Python

Started over with migrations. The tweaks on first time experience.

Anthony Cassandra0eeecf5a5945
diff --git a/src/hi/apps/collection/migrations/0001_initial.py b/src/hi/apps/collection/migrations/0001_initial.py
index f56b20d1..ef045f8c 100644
--- a/src/hi/apps/collection/migrations/0001_initial.py
+++ b/src/hi/apps/collection/migrations/0001_initial.py
@@ -1,7 +1,8 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:12
+# Generated by Django 4.2.15 on 2024-10-12 15:30
from django.db import migrations, models
import django.db.models.deletion
+import hi.apps.location.models
class Migration(migrations.Migration):
@@ -10,6 +11,7 @@ class Migration(migrations.Migration):
dependencies = [
("entity", "0001_initial"),
+ ("location", "0001_initial"),
]
operations = [
@@ -31,8 +33,8 @@ class Migration(migrations.Migration):
models.CharField(max_length=32, verbose_name="Collection Type"),
),
(
- "svg_path",
- models.TextField(blank=True, null=True, verbose_name="Path"),
+ "order_id",
+ models.PositiveIntegerField(default=0, verbose_name="Order Id"),
),
(
"created_datetime",
@@ -42,6 +44,167 @@ class Migration(migrations.Migration):
options={
"verbose_name": "Collection",
"verbose_name_plural": "Collections",
+ "ordering": ["order_id"],
+ },
+ bases=(models.Model, hi.apps.location.models.LocationItemModelMixin),
+ ),
+ migrations.CreateModel(
+ name="CollectionView",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "created_datetime",
+ models.DateTimeField(auto_now_add=True, verbose_name="Created"),
+ ),
+ (
+ "collection",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="collection_views",
+ to="collection.collection",
+ verbose_name="Collection",
+ ),
+ ),
+ (
+ "location_view",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="collection_views",
+ to="location.locationview",
+ verbose_name="Location",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Collection View",
+ "verbose_name_plural": "Collection Views",
+ },
+ ),
+ migrations.CreateModel(
+ name="CollectionPosition",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "svg_x",
+ models.DecimalField(
+ decimal_places=6, max_digits=12, verbose_name="X"
+ ),
+ ),
+ (
+ "svg_y",
+ models.DecimalField(
+ decimal_places=6, max_digits=12, verbose_name="Y"
+ ),
+ ),
+ (
+ "svg_scale",
+ models.DecimalField(
+ decimal_places=6,
+ default=1.0,
+ max_digits=12,
+ verbose_name="Scale",
+ ),
+ ),
+ (
+ "svg_rotate",
+ models.DecimalField(
+ decimal_places=6,
+ default=0.0,
+ max_digits=12,
+ verbose_name="Rotate",
+ ),
+ ),
+ (
+ "created_datetime",
+ models.DateTimeField(auto_now_add=True, verbose_name="Created"),
+ ),
+ (
+ "updated_datetime",
+ models.DateTimeField(auto_now=True, verbose_name="Updated"),
+ ),
+ (
+ "collection",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="positions",
+ to="collection.collection",
+ verbose_name="Collection",
+ ),
+ ),
+ (
+ "location",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="collection_positions",
+ to="location.location",
+ verbose_name="Location",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Collection Position",
+ "verbose_name_plural": "Collection Positions",
+ },
+ ),
+ migrations.CreateModel(
+ name="CollectionPath",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("svg_path", models.TextField(verbose_name="Path")),
+ (
+ "created_datetime",
+ models.DateTimeField(auto_now_add=True, verbose_name="Created"),
+ ),
+ (
+ "updated_datetime",
+ models.DateTimeField(auto_now=True, verbose_name="Updated"),
+ ),
+ (
+ "collection",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="paths",
+ to="collection.collection",
+ verbose_name="Collection",
+ ),
+ ),
+ (
+ "location",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="collection_paths",
+ to="location.location",
+ verbose_name="Location",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Collection Path",
+ "verbose_name_plural": "Collection Paths",
},
),
migrations.CreateModel(
@@ -68,6 +231,7 @@ class Migration(migrations.Migration):
"collection",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
+ related_name="entities",
to="collection.collection",
verbose_name="Collection",
),
@@ -76,19 +240,36 @@ class Migration(migrations.Migration):
"entity",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
+ related_name="collections",
to="entity.entity",
verbose_name="Entity",
),
),
],
options={
+ "verbose_name": "Collection Entity",
+ "verbose_name_plural": "Collection Entities",
"ordering": ["order_id"],
- "indexes": [
- models.Index(
- fields=["collection", "entity"],
- name="collection__collect_04e3d8_idx",
- )
- ],
},
),
+ migrations.AddConstraint(
+ model_name="collectionposition",
+ constraint=models.UniqueConstraint(
+ fields=("location", "collection"),
+ name="collection_position_location_entity",
+ ),
+ ),
+ migrations.AddConstraint(
+ model_name="collectionpath",
+ constraint=models.UniqueConstraint(
+ fields=("location", "collection"),
+ name="collection_path_location_collection",
+ ),
+ ),
+ migrations.AddIndex(
+ model_name="collectionentity",
+ index=models.Index(
+ fields=["collection", "entity"], name="collection__collect_04e3d8_idx"
+ ),
+ ),
]
diff --git a/src/hi/apps/collection/migrations/0002_remove_collection_svg_path_collectionview_and_more.py b/src/hi/apps/collection/migrations/0002_remove_collection_svg_path_collectionview_and_more.py
deleted file mode 100644
index 61ad4565..00000000
--- a/src/hi/apps/collection/migrations/0002_remove_collection_svg_path_collectionview_and_more.py
+++ /dev/null
@@ -1,135 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-28 02:14
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- (
- "location",
- "0003_locationview_view_type_str_alter_location_order_id_and_more",
- ),
- ("collection", "0001_initial"),
- ]
-
- operations = [
- migrations.RemoveField(
- model_name="collection",
- name="svg_path",
- ),
- migrations.CreateModel(
- name="CollectionView",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "collection",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="location_views",
- to="collection.collection",
- verbose_name="Collection",
- ),
- ),
- (
- "location_view",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="collections",
- to="location.locationview",
- verbose_name="Location",
- ),
- ),
- ],
- options={
- "verbose_name": "Collection View",
- "verbose_name_plural": "Collection Views",
- },
- ),
- migrations.CreateModel(
- name="CollectionPosition",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "svg_x",
- models.DecimalField(
- decimal_places=6, max_digits=12, verbose_name="X"
- ),
- ),
- (
- "svg_y",
- models.DecimalField(
- decimal_places=6, max_digits=12, verbose_name="Y"
- ),
- ),
- (
- "svg_scale",
- models.DecimalField(
- decimal_places=6,
- default=1.0,
- max_digits=12,
- verbose_name="Scale",
- ),
- ),
- (
- "svg_rotation",
- models.DecimalField(
- decimal_places=6,
- default=0.0,
- max_digits=12,
- verbose_name="Rotation",
- ),
- ),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "updated_datetime",
- models.DateTimeField(auto_now=True, verbose_name="Updated"),
- ),
- (
- "collection",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="positions",
- to="collection.collection",
- verbose_name="Collection",
- ),
- ),
- (
- "location",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="collection_positions",
- to="location.location",
- verbose_name="Location",
- ),
- ),
- ],
- options={
- "abstract": False,
- },
- ),
- ]
diff --git a/src/hi/apps/collection/migrations/0003_collectionview_order_id_and_more.py b/src/hi/apps/collection/migrations/0003_collectionview_order_id_and_more.py
deleted file mode 100644
index 5d8d2ac9..00000000
--- a/src/hi/apps/collection/migrations/0003_collectionview_order_id_and_more.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-28 14:02
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0005_entitypath_updated_datetime_and_more"),
- ("collection", "0002_remove_collection_svg_path_collectionview_and_more"),
- ]
-
- operations = [
- migrations.AddField(
- model_name="collectionview",
- name="order_id",
- field=models.PositiveIntegerField(default=0, verbose_name="Order Id"),
- ),
- migrations.AlterField(
- model_name="collectionentity",
- name="collection",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entities",
- to="collection.collection",
- verbose_name="Collection",
- ),
- ),
- migrations.AlterField(
- model_name="collectionentity",
- name="entity",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="collections",
- to="entity.entity",
- verbose_name="Entity",
- ),
- ),
- ]
diff --git a/src/hi/apps/collection/migrations/0004_alter_collectionentity_options_and_more.py b/src/hi/apps/collection/migrations/0004_alter_collectionentity_options_and_more.py
deleted file mode 100644
index bc7f4214..00000000
--- a/src/hi/apps/collection/migrations/0004_alter_collectionentity_options_and_more.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Generated by Django 4.2.15 on 2024-09-01 04:00
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0005_rename_svg_rotation_locationview_svg_rotate"),
- ("collection", "0003_collectionview_order_id_and_more"),
- ]
-
- operations = [
- migrations.AlterModelOptions(
- name="collectionentity",
- options={
- "ordering": ["order_id"],
- "verbose_name": "Collection Entity",
- "verbose_name_plural": "Collection Entities",
- },
- ),
- migrations.AlterModelOptions(
- name="collectionposition",
- options={
- "verbose_name": "Collection Position",
- "verbose_name_plural": "Collection Positions",
- },
- ),
- migrations.RenameField(
- model_name="collectionposition",
- old_name="svg_rotation",
- new_name="svg_rotate",
- ),
- migrations.AlterField(
- model_name="collectionview",
- name="collection",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="collection_views",
- to="collection.collection",
- verbose_name="Collection",
- ),
- ),
- migrations.AlterField(
- model_name="collectionview",
- name="location_view",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="collection_views",
- to="location.locationview",
- verbose_name="Location",
- ),
- ),
- migrations.AddConstraint(
- model_name="collectionposition",
- constraint=models.UniqueConstraint(
- fields=("location", "collection"),
- name="collection_position_location_entity",
- ),
- ),
- ]
diff --git a/src/hi/apps/collection/migrations/0005_alter_collectionposition_svg_rotate.py b/src/hi/apps/collection/migrations/0005_alter_collectionposition_svg_rotate.py
deleted file mode 100644
index c8fef5b6..00000000
--- a/src/hi/apps/collection/migrations/0005_alter_collectionposition_svg_rotate.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated by Django 4.2.15 on 2024-09-01 04:01
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("collection", "0004_alter_collectionentity_options_and_more"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="collectionposition",
- name="svg_rotate",
- field=models.DecimalField(
- decimal_places=6, default=0.0, max_digits=12, verbose_name="Rotate"
- ),
- ),
- ]
diff --git a/src/hi/apps/collection/migrations/0006_remove_collectionview_order_id_collection_order_id.py b/src/hi/apps/collection/migrations/0006_remove_collectionview_order_id_collection_order_id.py
deleted file mode 100644
index 289bdb52..00000000
--- a/src/hi/apps/collection/migrations/0006_remove_collectionview_order_id_collection_order_id.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-02 18:15
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("collection", "0005_alter_collectionposition_svg_rotate"),
- ]
-
- operations = [
- migrations.RemoveField(
- model_name="collectionview",
- name="order_id",
- ),
- migrations.AddField(
- model_name="collection",
- name="order_id",
- field=models.PositiveIntegerField(default=0, verbose_name="Order Id"),
- ),
- ]
diff --git a/src/hi/apps/collection/migrations/0007_collectionpath_and_more.py b/src/hi/apps/collection/migrations/0007_collectionpath_and_more.py
deleted file mode 100644
index 9bd94b4e..00000000
--- a/src/hi/apps/collection/migrations/0007_collectionpath_and_more.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-09 21:35
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0007_rename_view_type_str_locationview_location_view_type_str"),
- ("collection", "0006_remove_collectionview_order_id_collection_order_id"),
- ]
-
- operations = [
- migrations.CreateModel(
- name="CollectionPath",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- ("svg_path", models.TextField(verbose_name="Path")),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "updated_datetime",
- models.DateTimeField(auto_now=True, verbose_name="Updated"),
- ),
- (
- "collection",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="paths",
- to="collection.collection",
- verbose_name="Collection",
- ),
- ),
- (
- "location",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="collection_paths",
- to="location.location",
- verbose_name="Location",
- ),
- ),
- ],
- options={
- "verbose_name": "Collection Path",
- "verbose_name_plural": "Collection Paths",
- },
- ),
- migrations.AddConstraint(
- model_name="collectionpath",
- constraint=models.UniqueConstraint(
- fields=("location", "collection"),
- name="collection_path_location_collection",
- ),
- ),
- ]
diff --git a/src/hi/apps/collection/migrations/0008_alter_collection_options.py b/src/hi/apps/collection/migrations/0008_alter_collection_options.py
deleted file mode 100644
index 783dc2fc..00000000
--- a/src/hi/apps/collection/migrations/0008_alter_collection_options.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-11 15:38
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("collection", "0007_collectionpath_and_more"),
- ]
-
- operations = [
- migrations.AlterModelOptions(
- name="collection",
- options={
- "ordering": ["order_id"],
- "verbose_name": "Collection",
- "verbose_name_plural": "Collections",
- },
- ),
- ]
diff --git a/src/hi/apps/common/migrations/0001_initial.py b/src/hi/apps/common/migrations/0001_initial.py
index 361c4e97..436d707a 100644
--- a/src/hi/apps/common/migrations/0001_initial.py
+++ b/src/hi/apps/common/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:12
+# Generated by Django 4.2.15 on 2024-10-12 15:30
from django.db import migrations, models
@@ -24,6 +24,11 @@ class Migration(migrations.Migration):
),
("name", models.CharField(max_length=64, unique=True)),
("acquired_at", models.DateTimeField()),
+ ("initialized", models.BooleanField(default=False)),
],
+ options={
+ "verbose_name": "Database Lock",
+ "verbose_name_plural": "Database Locks",
+ },
),
]
diff --git a/src/hi/apps/common/migrations/0002_alter_databaselock_options.py b/src/hi/apps/common/migrations/0002_alter_databaselock_options.py
deleted file mode 100644
index 1a172a07..00000000
--- a/src/hi/apps/common/migrations/0002_alter_databaselock_options.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:28
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("common", "0001_initial"),
- ]
-
- operations = [
- migrations.AlterModelOptions(
- name="databaselock",
- options={
- "verbose_name": "Database Lock",
- "verbose_name_plural": "Database Locks",
- },
- ),
- ]
diff --git a/src/hi/apps/common/migrations/0003_databaselock_initialized.py b/src/hi/apps/common/migrations/0003_databaselock_initialized.py
deleted file mode 100644
index a980e4a1..00000000
--- a/src/hi/apps/common/migrations/0003_databaselock_initialized.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:38
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("common", "0002_alter_databaselock_options"),
- ]
-
- operations = [
- migrations.AddField(
- model_name="databaselock",
- name="initialized",
- field=models.BooleanField(default=False),
- ),
- ]
diff --git a/src/hi/apps/control/migrations/0001_initial.py b/src/hi/apps/control/migrations/0001_initial.py
index 276cc5a8..491e95e5 100644
--- a/src/hi/apps/control/migrations/0001_initial.py
+++ b/src/hi/apps/control/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:12
+# Generated by Django 4.2.15 on 2024-10-12 15:30
from django.db import migrations, models
import django.db.models.deletion
@@ -25,6 +25,24 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
+ (
+ "integration_type_str",
+ models.CharField(
+ blank=True,
+ max_length=32,
+ null=True,
+ verbose_name="Integration Type",
+ ),
+ ),
+ (
+ "integration_key",
+ models.CharField(
+ blank=True,
+ max_length=128,
+ null=True,
+ verbose_name="Integration Key",
+ ),
+ ),
("name", models.CharField(max_length=64, verbose_name="Name")),
(
"controller_type_str",
@@ -77,44 +95,4 @@ class Migration(migrations.Migration):
"verbose_name_plural": "Controller History",
},
),
- migrations.CreateModel(
- name="ControlledEntity",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "controller",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="+",
- to="control.controller",
- verbose_name="Controller",
- ),
- ),
- (
- "entity",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="controlled_by",
- to="entity.entity",
- verbose_name="Entity",
- ),
- ),
- ],
- options={
- "verbose_name": "Controlled Entity",
- "verbose_name_plural": "Controlled Entities",
- },
- ),
]
diff --git a/src/hi/apps/control/migrations/0002_controller_integration_id_and_more.py b/src/hi/apps/control/migrations/0002_controller_integration_id_and_more.py
deleted file mode 100644
index 4a365753..00000000
--- a/src/hi/apps/control/migrations/0002_controller_integration_id_and_more.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 22:27
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("control", "0001_initial"),
- ]
-
- operations = [
- migrations.AddField(
- model_name="controller",
- name="integration_id",
- field=models.CharField(
- blank=True, max_length=128, null=True, verbose_name="Integration Id"
- ),
- ),
- migrations.AddField(
- model_name="controller",
- name="integration_type_str",
- field=models.CharField(
- blank=True, max_length=32, null=True, verbose_name="Integration Type"
- ),
- ),
- ]
diff --git a/src/hi/apps/control/migrations/0003_rename_integration_id_controller_integration_key.py b/src/hi/apps/control/migrations/0003_rename_integration_id_controller_integration_key.py
deleted file mode 100644
index 27d33381..00000000
--- a/src/hi/apps/control/migrations/0003_rename_integration_id_controller_integration_key.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 23:55
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("control", "0002_controller_integration_id_and_more"),
- ]
-
- operations = [
- migrations.RenameField(
- model_name="controller",
- old_name="integration_id",
- new_name="integration_key",
- ),
- ]
diff --git a/src/hi/apps/control/migrations/0004_alter_controller_integration_key.py b/src/hi/apps/control/migrations/0004_alter_controller_integration_key.py
deleted file mode 100644
index 67df205e..00000000
--- a/src/hi/apps/control/migrations/0004_alter_controller_integration_key.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 23:56
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("control", "0003_rename_integration_id_controller_integration_key"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="controller",
- name="integration_key",
- field=models.CharField(
- blank=True, max_length=128, null=True, verbose_name="Integration Key"
- ),
- ),
- ]
diff --git a/src/hi/apps/control/migrations/0005_delete_controlledentity.py b/src/hi/apps/control/migrations/0005_delete_controlledentity.py
deleted file mode 100644
index c2414764..00000000
--- a/src/hi/apps/control/migrations/0005_delete_controlledentity.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-28 02:14
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("control", "0004_alter_controller_integration_key"),
- ]
-
- operations = [
- migrations.DeleteModel(
- name="ControlledEntity",
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0001_initial.py b/src/hi/apps/entity/migrations/0001_initial.py
index b75adc60..cf89694f 100644
--- a/src/hi/apps/entity/migrations/0001_initial.py
+++ b/src/hi/apps/entity/migrations/0001_initial.py
@@ -1,7 +1,8 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:12
+# Generated by Django 4.2.15 on 2024-10-12 15:30
from django.db import migrations, models
import django.db.models.deletion
+import hi.apps.location.models
class Migration(migrations.Migration):
@@ -9,10 +10,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
- (
- "location",
- "0003_locationview_view_type_str_alter_location_order_id_and_more",
- ),
+ ("location", "0001_initial"),
]
operations = [
@@ -28,10 +26,28 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
+ (
+ "integration_type_str",
+ models.CharField(
+ blank=True,
+ max_length=32,
+ null=True,
+ verbose_name="Integration Type",
+ ),
+ ),
+ (
+ "integration_key",
+ models.CharField(
+ blank=True,
+ max_length=128,
+ null=True,
+ verbose_name="Integration Key",
+ ),
+ ),
("name", models.CharField(max_length=64, verbose_name="Name")),
(
"entity_type_str",
- models.CharField(max_length=32, verbose_name="Type"),
+ models.CharField(max_length=32, verbose_name="Entity Type"),
),
(
"created_datetime",
@@ -42,6 +58,7 @@ class Migration(migrations.Migration):
"verbose_name": "Entity",
"verbose_name_plural": "Entities",
},
+ bases=(models.Model, hi.apps.location.models.LocationItemModelMixin),
),
migrations.CreateModel(
name="EntityState",
@@ -60,7 +77,10 @@ class Migration(migrations.Migration):
models.CharField(max_length=32, verbose_name="State Type"),
),
("name", models.CharField(max_length=64, verbose_name="Name")),
- ("value_range", models.TextField(verbose_name="Value Range")),
+ (
+ "value_range",
+ models.TextField(blank=True, null=True, verbose_name="Value Range"),
+ ),
(
"units",
models.CharField(
@@ -86,6 +106,86 @@ class Migration(migrations.Migration):
"verbose_name_plural": "Entity States",
},
),
+ migrations.CreateModel(
+ name="EntityView",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "created_datetime",
+ models.DateTimeField(auto_now_add=True, verbose_name="Created"),
+ ),
+ (
+ "entity",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="entity_views",
+ to="entity.entity",
+ verbose_name="Entity",
+ ),
+ ),
+ (
+ "location_view",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="entity_views",
+ to="location.locationview",
+ verbose_name="Location",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Entity View",
+ "verbose_name_plural": "Entity Views",
+ },
+ ),
+ migrations.CreateModel(
+ name="EntityStateDelegation",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "created_datetime",
+ models.DateTimeField(auto_now_add=True, verbose_name="Created"),
+ ),
+ (
+ "delegate_entity",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="entity_state_delegations",
+ to="entity.entity",
+ verbose_name="Deleage Entity",
+ ),
+ ),
+ (
+ "entity_state",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="entity_state_delegations",
+ to="entity.entitystate",
+ verbose_name="Entity State",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Entity State Delegation",
+ "verbose_name_plural": "Entity State Delegations",
+ },
+ ),
migrations.CreateModel(
name="EntityPosition",
fields=[
@@ -120,12 +220,12 @@ class Migration(migrations.Migration):
),
),
(
- "svg_rotation",
+ "svg_rotate",
models.DecimalField(
decimal_places=6,
default=0.0,
max_digits=12,
- verbose_name="Rotation",
+ verbose_name="Rotate",
),
),
(
@@ -149,7 +249,7 @@ class Migration(migrations.Migration):
"location",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
- related_name="positions",
+ related_name="entity_positions",
to="location.location",
verbose_name="Location",
),
@@ -158,12 +258,6 @@ class Migration(migrations.Migration):
options={
"verbose_name": "Entity Position",
"verbose_name_plural": "Entity Positions",
- "indexes": [
- models.Index(
- fields=["location", "entity"],
- name="entity_enti_locatio_0402a2_idx",
- )
- ],
},
),
migrations.CreateModel(
@@ -183,6 +277,10 @@ class Migration(migrations.Migration):
"created_datetime",
models.DateTimeField(auto_now_add=True, verbose_name="Created"),
),
+ (
+ "updated_datetime",
+ models.DateTimeField(auto_now=True, verbose_name="Updated"),
+ ),
(
"entity",
models.ForeignKey(
@@ -196,7 +294,7 @@ class Migration(migrations.Migration):
"location",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
- related_name="paths",
+ related_name="entity_paths",
to="location.location",
verbose_name="Location",
),
@@ -205,16 +303,10 @@ class Migration(migrations.Migration):
options={
"verbose_name": "Entity Path",
"verbose_name_plural": "Entity Paths",
- "indexes": [
- models.Index(
- fields=["location", "entity"],
- name="entity_enti_locatio_15cbf9_idx",
- )
- ],
},
),
migrations.CreateModel(
- name="Attribute",
+ name="EntityAttribute",
fields=[
(
"id",
@@ -266,11 +358,38 @@ class Migration(migrations.Migration):
options={
"verbose_name": "Attribute",
"verbose_name_plural": "Attributes",
- "indexes": [
- models.Index(
- fields=["name", "value"], name="entity_attr_name_820790_idx"
- )
- ],
},
),
+ migrations.AddConstraint(
+ model_name="entityview",
+ constraint=models.UniqueConstraint(
+ fields=("entity", "location_view"),
+ name="entity_view_entity_location_view",
+ ),
+ ),
+ migrations.AddConstraint(
+ model_name="entitystatedelegation",
+ constraint=models.UniqueConstraint(
+ fields=("delegate_entity", "entity_state"),
+ name="entity_state_delegation_uniqueness",
+ ),
+ ),
+ migrations.AddConstraint(
+ model_name="entityposition",
+ constraint=models.UniqueConstraint(
+ fields=("location", "entity"), name="entity_position_location_entity"
+ ),
+ ),
+ migrations.AddConstraint(
+ model_name="entitypath",
+ constraint=models.UniqueConstraint(
+ fields=("location", "entity"), name="entity_path_location_entity"
+ ),
+ ),
+ migrations.AddIndex(
+ model_name="entityattribute",
+ index=models.Index(
+ fields=["name", "value"], name="entity_enti_name_ca029b_idx"
+ ),
+ ),
]
diff --git a/src/hi/apps/entity/migrations/0002_entity_integration_id_entity_integration_type_str_and_more.py b/src/hi/apps/entity/migrations/0002_entity_integration_id_entity_integration_type_str_and_more.py
deleted file mode 100644
index b0b2628d..00000000
--- a/src/hi/apps/entity/migrations/0002_entity_integration_id_entity_integration_type_str_and_more.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 22:27
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0001_initial"),
- ]
-
- operations = [
- migrations.AddField(
- model_name="entity",
- name="integration_id",
- field=models.CharField(
- blank=True, max_length=128, null=True, verbose_name="Integration Id"
- ),
- ),
- migrations.AddField(
- model_name="entity",
- name="integration_type_str",
- field=models.CharField(
- blank=True, max_length=32, null=True, verbose_name="Integration Type"
- ),
- ),
- migrations.AlterField(
- model_name="entity",
- name="entity_type_str",
- field=models.CharField(max_length=32, verbose_name="Entity Type"),
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0003_rename_integration_id_entity_integration_key.py b/src/hi/apps/entity/migrations/0003_rename_integration_id_entity_integration_key.py
deleted file mode 100644
index e4d04942..00000000
--- a/src/hi/apps/entity/migrations/0003_rename_integration_id_entity_integration_key.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 23:55
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0002_entity_integration_id_entity_integration_type_str_and_more"),
- ]
-
- operations = [
- migrations.RenameField(
- model_name="entity",
- old_name="integration_id",
- new_name="integration_key",
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0004_alter_entity_integration_key.py b/src/hi/apps/entity/migrations/0004_alter_entity_integration_key.py
deleted file mode 100644
index 542b9e81..00000000
--- a/src/hi/apps/entity/migrations/0004_alter_entity_integration_key.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 23:56
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0003_rename_integration_id_entity_integration_key"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="entity",
- name="integration_key",
- field=models.CharField(
- blank=True, max_length=128, null=True, verbose_name="Integration Key"
- ),
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0005_entitypath_updated_datetime_and_more.py b/src/hi/apps/entity/migrations/0005_entitypath_updated_datetime_and_more.py
deleted file mode 100644
index 5b1ddbf7..00000000
--- a/src/hi/apps/entity/migrations/0005_entitypath_updated_datetime_and_more.py
+++ /dev/null
@@ -1,109 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-28 02:14
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- (
- "location",
- "0003_locationview_view_type_str_alter_location_order_id_and_more",
- ),
- ("entity", "0004_alter_entity_integration_key"),
- ]
-
- operations = [
- migrations.AddField(
- model_name="entitypath",
- name="updated_datetime",
- field=models.DateTimeField(auto_now=True, verbose_name="Updated"),
- ),
- migrations.AlterField(
- model_name="entityposition",
- name="location",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entity_positions",
- to="location.location",
- verbose_name="Location",
- ),
- ),
- migrations.CreateModel(
- name="ProxyState",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "entity",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="proxy_by_states",
- to="entity.entity",
- verbose_name="Entity",
- ),
- ),
- (
- "entity_state",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="proxy_for_entities",
- to="entity.entitystate",
- verbose_name="Entity State",
- ),
- ),
- ],
- ),
- migrations.CreateModel(
- name="EntityView",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "entity",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="location_views",
- to="entity.entity",
- verbose_name="Entity",
- ),
- ),
- (
- "location_view",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entities",
- to="location.locationview",
- verbose_name="Location",
- ),
- ),
- ],
- options={
- "verbose_name": "Entity View",
- "verbose_name_plural": "Entity Views",
- },
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0006_remove_entitypath_entity_enti_locatio_15cbf9_idx_and_more.py b/src/hi/apps/entity/migrations/0006_remove_entitypath_entity_enti_locatio_15cbf9_idx_and_more.py
deleted file mode 100644
index b152ee67..00000000
--- a/src/hi/apps/entity/migrations/0006_remove_entitypath_entity_enti_locatio_15cbf9_idx_and_more.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Generated by Django 4.2.15 on 2024-09-01 04:00
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0005_rename_svg_rotation_locationview_svg_rotate"),
- ("entity", "0005_entitypath_updated_datetime_and_more"),
- ]
-
- operations = [
- migrations.RemoveIndex(
- model_name="entitypath",
- name="entity_enti_locatio_15cbf9_idx",
- ),
- migrations.RemoveIndex(
- model_name="entityposition",
- name="entity_enti_locatio_0402a2_idx",
- ),
- migrations.RenameField(
- model_name="entityposition",
- old_name="svg_rotation",
- new_name="svg_rotate",
- ),
- migrations.AlterField(
- model_name="entitystate",
- name="value_range",
- field=models.TextField(blank=True, null=True, verbose_name="Value Range"),
- ),
- migrations.AlterField(
- model_name="entityview",
- name="entity",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entity_views",
- to="entity.entity",
- verbose_name="Entity",
- ),
- ),
- migrations.AlterField(
- model_name="entityview",
- name="location_view",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entity_views",
- to="location.locationview",
- verbose_name="Location",
- ),
- ),
- migrations.AddConstraint(
- model_name="entitypath",
- constraint=models.UniqueConstraint(
- fields=("location", "entity"), name="entity_path_location_entity"
- ),
- ),
- migrations.AddConstraint(
- model_name="entityposition",
- constraint=models.UniqueConstraint(
- fields=("location", "entity"), name="entity_position_location_entity"
- ),
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0007_alter_entityposition_svg_rotate.py b/src/hi/apps/entity/migrations/0007_alter_entityposition_svg_rotate.py
deleted file mode 100644
index 62397565..00000000
--- a/src/hi/apps/entity/migrations/0007_alter_entityposition_svg_rotate.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated by Django 4.2.15 on 2024-09-01 04:01
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0006_remove_entitypath_entity_enti_locatio_15cbf9_idx_and_more"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="entityposition",
- name="svg_rotate",
- field=models.DecimalField(
- decimal_places=6, default=0.0, max_digits=12, verbose_name="Rotate"
- ),
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0008_entityview_entity_view_entity_location_view.py b/src/hi/apps/entity/migrations/0008_entityview_entity_view_entity_location_view.py
deleted file mode 100644
index 9b0386bd..00000000
--- a/src/hi/apps/entity/migrations/0008_entityview_entity_view_entity_location_view.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-02 18:15
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0007_alter_entityposition_svg_rotate"),
- ]
-
- operations = [
- migrations.AddConstraint(
- model_name="entityview",
- constraint=models.UniqueConstraint(
- fields=("entity", "location_view"),
- name="entity_view_entity_location_view",
- ),
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0009_entitystateproxy_delete_proxystate.py b/src/hi/apps/entity/migrations/0009_entitystateproxy_delete_proxystate.py
deleted file mode 100644
index ea20a168..00000000
--- a/src/hi/apps/entity/migrations/0009_entitystateproxy_delete_proxystate.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-07 15:38
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0008_entityview_entity_view_entity_location_view"),
- ]
-
- operations = [
- migrations.CreateModel(
- name="EntityStateProxy",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "entity",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entity_state_proxies",
- to="entity.entity",
- verbose_name="Entity",
- ),
- ),
- (
- "entity_state",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entity_state_proxies",
- to="entity.entitystate",
- verbose_name="Entity State",
- ),
- ),
- ],
- ),
- migrations.DeleteModel(
- name="ProxyState",
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0010_entitystatedelegation_delete_entitystateproxy.py b/src/hi/apps/entity/migrations/0010_entitystatedelegation_delete_entitystateproxy.py
deleted file mode 100644
index 02a55a17..00000000
--- a/src/hi/apps/entity/migrations/0010_entitystatedelegation_delete_entitystateproxy.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-07 18:32
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0009_entitystateproxy_delete_proxystate"),
- ]
-
- operations = [
- migrations.CreateModel(
- name="EntityStateDelegation",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "delegate_entity",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entity_state_delegations",
- to="entity.entity",
- verbose_name="Deleage Entity",
- ),
- ),
- (
- "entity_state",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entity_state_delegations",
- to="entity.entitystate",
- verbose_name="Entity State",
- ),
- ),
- ],
- ),
- migrations.DeleteModel(
- name="EntityStateProxy",
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0011_alter_entitystatedelegation_options_and_more.py b/src/hi/apps/entity/migrations/0011_alter_entitystatedelegation_options_and_more.py
deleted file mode 100644
index ba413255..00000000
--- a/src/hi/apps/entity/migrations/0011_alter_entitystatedelegation_options_and_more.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-09 21:35
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0007_rename_view_type_str_locationview_location_view_type_str"),
- ("entity", "0010_entitystatedelegation_delete_entitystateproxy"),
- ]
-
- operations = [
- migrations.AlterModelOptions(
- name="entitystatedelegation",
- options={
- "verbose_name": "Entity State Delegation",
- "verbose_name_plural": "Entity State Delegations",
- },
- ),
- migrations.AlterField(
- model_name="entitypath",
- name="location",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="entity_paths",
- to="location.location",
- verbose_name="Location",
- ),
- ),
- migrations.AddConstraint(
- model_name="entitystatedelegation",
- constraint=models.UniqueConstraint(
- fields=("delegate_entity", "entity_state"),
- name="entity_state_delegation_uniqueness",
- ),
- ),
- ]
diff --git a/src/hi/apps/entity/migrations/0012_rename_attribute_entityattribute_and_more.py b/src/hi/apps/entity/migrations/0012_rename_attribute_entityattribute_and_more.py
deleted file mode 100644
index ec47d45e..00000000
--- a/src/hi/apps/entity/migrations/0012_rename_attribute_entityattribute_and_more.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-11 19:54
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("entity", "0011_alter_entitystatedelegation_options_and_more"),
- ]
-
- operations = [
- migrations.RenameModel(
- old_name="Attribute",
- new_name="EntityAttribute",
- ),
- migrations.RenameIndex(
- model_name="entityattribute",
- new_name="entity_enti_name_ca029b_idx",
- old_name="entity_attr_name_820790_idx",
- ),
- ]
diff --git a/src/hi/apps/location/edit/forms.py b/src/hi/apps/location/edit/forms.py
index 0df59648..2dafada0 100644
--- a/src/hi/apps/location/edit/forms.py
+++ b/src/hi/apps/location/edit/forms.py
@@ -31,8 +31,10 @@ class LocationForm(forms.Form):
'href',
}
- name = forms.CharField()
-
+ name = forms.CharField(
+ label = 'Location Name',
+ required = True,
+ )
svg_file = forms.FileField(
label = 'SVG file',
required = False,
diff --git a/src/hi/apps/location/migrations/0001_initial.py b/src/hi/apps/location/migrations/0001_initial.py
index eedb97a0..155929fc 100644
--- a/src/hi/apps/location/migrations/0001_initial.py
+++ b/src/hi/apps/location/migrations/0001_initial.py
@@ -1,7 +1,8 @@
-# Generated by Django 4.2.15 on 2024-08-14 19:15
+# Generated by Django 4.2.15 on 2024-10-12 15:30
from django.db import migrations, models
import django.db.models.deletion
+import hi.models
class Migration(migrations.Migration):
@@ -25,32 +26,17 @@ class Migration(migrations.Migration):
),
("name", models.CharField(max_length=64, verbose_name="Name")),
(
- "svg_filename",
- models.CharField(max_length=256, verbose_name="SVG File"),
+ "svg_fragment_filename",
+ models.CharField(max_length=255, verbose_name="SVG Filename"),
),
(
- "svg_viewbox",
- models.CharField(max_length=64, verbose_name="Viewbox"),
+ "svg_view_box_str",
+ models.CharField(max_length=128, verbose_name="Viewbox"),
),
(
- "latitude",
- models.DecimalField(
- decimal_places=6, max_digits=9, verbose_name="Latitude"
- ),
- ),
- (
- "longitude",
- models.DecimalField(
- decimal_places=6, max_digits=9, verbose_name="Longitude"
- ),
- ),
- (
- "elevation_feet",
- models.DecimalField(
- decimal_places=3, max_digits=9, verbose_name="Elevation (ft)"
- ),
+ "order_id",
+ models.PositiveIntegerField(default=0, verbose_name="Order Id"),
),
- ("order_id", models.IntegerField(default=0, verbose_name="Order Id")),
(
"created_datetime",
models.DateTimeField(auto_now_add=True, verbose_name="Created"),
@@ -63,7 +49,9 @@ class Migration(migrations.Migration):
options={
"verbose_name": "Location",
"verbose_name_plural": "Locations",
+ "ordering": ["order_id"],
},
+ bases=(models.Model, hi.models.ItemTypeModelMixin),
),
migrations.CreateModel(
name="LocationView",
@@ -77,18 +65,25 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
+ (
+ "location_view_type_str",
+ models.CharField(max_length=32, verbose_name="View Type"),
+ ),
("name", models.CharField(max_length=64, verbose_name="Name")),
(
- "svg_viewbox",
- models.CharField(max_length=64, verbose_name="Viewbox"),
+ "svg_view_box_str",
+ models.CharField(max_length=128, verbose_name="Viewbox"),
),
(
- "svg_rotation",
+ "svg_rotate",
models.DecimalField(
- decimal_places=6, max_digits=9, verbose_name="Rotation"
+ decimal_places=6, max_digits=9, verbose_name="Rotate"
),
),
- ("order_id", models.IntegerField(default=0, verbose_name="Order Id")),
+ (
+ "order_id",
+ models.PositiveIntegerField(default=0, verbose_name="Order Id"),
+ ),
(
"created_datetime",
models.DateTimeField(auto_now_add=True, verbose_name="Created"),
@@ -103,13 +98,75 @@ class Migration(migrations.Migration):
on_delete=django.db.models.deletion.CASCADE,
related_name="views",
to="location.location",
- verbose_name="View",
+ verbose_name="Location",
),
),
],
options={
"verbose_name": "View",
"verbose_name_plural": "Views",
+ "ordering": ["order_id"],
+ },
+ bases=(models.Model, hi.models.ItemTypeModelMixin),
+ ),
+ migrations.CreateModel(
+ name="LocationAttribute",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "attribute_value_type_str",
+ models.CharField(
+ max_length=32, verbose_name="Attribute Value Type"
+ ),
+ ),
+ ("name", models.CharField(max_length=64, verbose_name="Name")),
+ ("value", models.TextField(verbose_name="Value")),
+ (
+ "attribute_type_str",
+ models.CharField(max_length=32, verbose_name="Attribute Type"),
+ ),
+ (
+ "is_editable",
+ models.BooleanField(default=True, verbose_name="Editable?"),
+ ),
+ (
+ "is_required",
+ models.BooleanField(default=False, verbose_name="Required?"),
+ ),
+ (
+ "created_datetime",
+ models.DateTimeField(auto_now_add=True, verbose_name="Created"),
+ ),
+ (
+ "updated_datetime",
+ models.DateTimeField(auto_now=True, verbose_name="Updated"),
+ ),
+ (
+ "location",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="attributes",
+ to="location.location",
+ verbose_name="Location",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Attribute",
+ "verbose_name_plural": "Attributes",
+ "indexes": [
+ models.Index(
+ fields=["name", "value"], name="location_lo_name_0c26e1_idx"
+ )
+ ],
},
),
]
diff --git a/src/hi/apps/location/migrations/0002_alter_location_latitude_alter_location_longitude.py b/src/hi/apps/location/migrations/0002_alter_location_latitude_alter_location_longitude.py
deleted file mode 100644
index 8ce15868..00000000
--- a/src/hi/apps/location/migrations/0002_alter_location_latitude_alter_location_longitude.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-14 19:20
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0001_initial"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="location",
- name="latitude",
- field=models.DecimalField(
- decimal_places=8, max_digits=11, verbose_name="Latitude"
- ),
- ),
- migrations.AlterField(
- model_name="location",
- name="longitude",
- field=models.DecimalField(
- decimal_places=8, max_digits=11, verbose_name="Longitude"
- ),
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0003_locationview_view_type_str_alter_location_order_id_and_more.py b/src/hi/apps/location/migrations/0003_locationview_view_type_str_alter_location_order_id_and_more.py
deleted file mode 100644
index 29e33f78..00000000
--- a/src/hi/apps/location/migrations/0003_locationview_view_type_str_alter_location_order_id_and_more.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:12
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0002_alter_location_latitude_alter_location_longitude"),
- ]
-
- operations = [
- migrations.AddField(
- model_name="locationview",
- name="view_type_str",
- field=models.CharField(
- default="information", max_length=32, verbose_name="View Type"
- ),
- preserve_default=False,
- ),
- migrations.AlterField(
- model_name="location",
- name="order_id",
- field=models.PositiveIntegerField(default=0, verbose_name="Order Id"),
- ),
- migrations.AlterField(
- model_name="locationview",
- name="location",
- field=models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="views",
- to="location.location",
- verbose_name="Location",
- ),
- ),
- migrations.AlterField(
- model_name="locationview",
- name="order_id",
- field=models.PositiveIntegerField(default=0, verbose_name="Order Id"),
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0004_rename_svg_viewbox_location_svg_view_box_str_and_more.py b/src/hi/apps/location/migrations/0004_rename_svg_viewbox_location_svg_view_box_str_and_more.py
deleted file mode 100644
index 7804bc0b..00000000
--- a/src/hi/apps/location/migrations/0004_rename_svg_viewbox_location_svg_view_box_str_and_more.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-29 01:21
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- (
- "location",
- "0003_locationview_view_type_str_alter_location_order_id_and_more",
- ),
- ]
-
- operations = [
- migrations.RenameField(
- model_name="location",
- old_name="svg_viewbox",
- new_name="svg_view_box_str",
- ),
- migrations.RenameField(
- model_name="locationview",
- old_name="svg_viewbox",
- new_name="svg_view_box_str",
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0005_rename_svg_rotation_locationview_svg_rotate.py b/src/hi/apps/location/migrations/0005_rename_svg_rotation_locationview_svg_rotate.py
deleted file mode 100644
index 0c1c5b43..00000000
--- a/src/hi/apps/location/migrations/0005_rename_svg_rotation_locationview_svg_rotate.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-09-01 04:00
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0004_rename_svg_viewbox_location_svg_view_box_str_and_more"),
- ]
-
- operations = [
- migrations.RenameField(
- model_name="locationview",
- old_name="svg_rotation",
- new_name="svg_rotate",
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0006_alter_locationview_svg_rotate.py b/src/hi/apps/location/migrations/0006_alter_locationview_svg_rotate.py
deleted file mode 100644
index 3a707c1a..00000000
--- a/src/hi/apps/location/migrations/0006_alter_locationview_svg_rotate.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated by Django 4.2.15 on 2024-09-01 04:01
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0005_rename_svg_rotation_locationview_svg_rotate"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="locationview",
- name="svg_rotate",
- field=models.DecimalField(
- decimal_places=6, max_digits=9, verbose_name="Rotate"
- ),
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0007_rename_view_type_str_locationview_location_view_type_str.py b/src/hi/apps/location/migrations/0007_rename_view_type_str_locationview_location_view_type_str.py
deleted file mode 100644
index 623c267d..00000000
--- a/src/hi/apps/location/migrations/0007_rename_view_type_str_locationview_location_view_type_str.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-03 13:13
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0006_alter_locationview_svg_rotate"),
- ]
-
- operations = [
- migrations.RenameField(
- model_name="locationview",
- old_name="view_type_str",
- new_name="location_view_type_str",
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0008_alter_location_options_alter_locationview_options_and_more.py b/src/hi/apps/location/migrations/0008_alter_location_options_alter_locationview_options_and_more.py
deleted file mode 100644
index c5203f30..00000000
--- a/src/hi/apps/location/migrations/0008_alter_location_options_alter_locationview_options_and_more.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-11 15:38
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0007_rename_view_type_str_locationview_location_view_type_str"),
- ]
-
- operations = [
- migrations.AlterModelOptions(
- name="location",
- options={
- "ordering": ["order_id"],
- "verbose_name": "Location",
- "verbose_name_plural": "Locations",
- },
- ),
- migrations.AlterModelOptions(
- name="locationview",
- options={
- "ordering": ["order_id"],
- "verbose_name": "View",
- "verbose_name_plural": "Views",
- },
- ),
- migrations.RemoveField(
- model_name="location",
- name="elevation_feet",
- ),
- migrations.RemoveField(
- model_name="location",
- name="latitude",
- ),
- migrations.RemoveField(
- model_name="location",
- name="longitude",
- ),
- migrations.AddField(
- model_name="location",
- name="svg_fragment_filename",
- field=models.FileField(
- default="temp",
- max_length=255,
- upload_to="",
- verbose_name="SVG Filename",
- ),
- preserve_default=False,
- ),
- migrations.AlterField(
- model_name="location",
- name="svg_filename",
- field=models.FileField(upload_to=""),
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0009_alter_location_svg_fragment_filename.py b/src/hi/apps/location/migrations/0009_alter_location_svg_fragment_filename.py
deleted file mode 100644
index 0d02a721..00000000
--- a/src/hi/apps/location/migrations/0009_alter_location_svg_fragment_filename.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-11 15:39
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0008_alter_location_options_alter_locationview_options_and_more"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="location",
- name="svg_fragment_filename",
- field=models.CharField(max_length=255, verbose_name="SVG Filename"),
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0010_alter_location_svg_view_box_str.py b/src/hi/apps/location/migrations/0010_alter_location_svg_view_box_str.py
deleted file mode 100644
index cf95654e..00000000
--- a/src/hi/apps/location/migrations/0010_alter_location_svg_view_box_str.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-11 15:39
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0009_alter_location_svg_fragment_filename"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="location",
- name="svg_view_box_str",
- field=models.CharField(max_length=128, verbose_name="Viewbox"),
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0011_alter_locationview_svg_view_box_str.py b/src/hi/apps/location/migrations/0011_alter_locationview_svg_view_box_str.py
deleted file mode 100644
index 3cb667a0..00000000
--- a/src/hi/apps/location/migrations/0011_alter_locationview_svg_view_box_str.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-11 15:40
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0010_alter_location_svg_view_box_str"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="locationview",
- name="svg_view_box_str",
- field=models.CharField(max_length=128, verbose_name="Viewbox"),
- ),
- ]
diff --git a/src/hi/apps/location/migrations/0012_remove_location_svg_filename.py b/src/hi/apps/location/migrations/0012_remove_location_svg_filename.py
deleted file mode 100644
index a22aa8c4..00000000
--- a/src/hi/apps/location/migrations/0012_remove_location_svg_filename.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Generated by Django 4.2.15 on 2024-10-11 15:41
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("location", "0011_alter_locationview_svg_view_box_str"),
- ]
-
- operations = [
- migrations.RemoveField(
- model_name="location",
- name="svg_filename",
- ),
- ]
diff --git a/src/hi/apps/location/templates/location/edit/panes/location_form.html b/src/hi/apps/location/templates/location/edit/panes/location_form.html
index 986fa427..b61bb676 100644
--- a/src/hi/apps/location/templates/location/edit/panes/location_form.html
+++ b/src/hi/apps/location/templates/location/edit/panes/location_form.html
@@ -10,13 +10,21 @@
</div>
{% endif %}
-<div>
+<p>
{{ location_form.name.label }}
{{ location_form.name }}
{{ location_form.name.errors }}
-</div>
+</p>
+
+<p>
+ Optionally add an image (SVG format) showing your property and/or house layout. Skip this and we'll uses a predefined image for you. You'll be able to update this image later.
+</p>
-<div>
+<p>
<label for="id_svg_file">Select an SVG file:</label>
<input type="file" name="svg_file" id="id_svg_file">
-</div>
+</p>
+
+<p>
+
+</p>
diff --git a/src/hi/apps/sense/migrations/0001_initial.py b/src/hi/apps/sense/migrations/0001_initial.py
index 38d0eb0e..bc6d0b93 100644
--- a/src/hi/apps/sense/migrations/0001_initial.py
+++ b/src/hi/apps/sense/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:12
+# Generated by Django 4.2.15 on 2024-10-12 15:30
from django.db import migrations, models
import django.db.models.deletion
@@ -25,6 +25,24 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
+ (
+ "integration_type_str",
+ models.CharField(
+ blank=True,
+ max_length=32,
+ null=True,
+ verbose_name="Integration Type",
+ ),
+ ),
+ (
+ "integration_key",
+ models.CharField(
+ blank=True,
+ max_length=128,
+ null=True,
+ verbose_name="Integration Key",
+ ),
+ ),
("name", models.CharField(max_length=64, verbose_name="Name")),
(
"sensor_type_str",
@@ -77,44 +95,4 @@ class Migration(migrations.Migration):
"verbose_name_plural": "Sensor History",
},
),
- migrations.CreateModel(
- name="SensedEntity",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- (
- "created_datetime",
- models.DateTimeField(auto_now_add=True, verbose_name="Created"),
- ),
- (
- "entity",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="sensed_by",
- to="entity.entity",
- verbose_name="Entity",
- ),
- ),
- (
- "sensor",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- related_name="+",
- to="sense.sensor",
- verbose_name="Sensor",
- ),
- ),
- ],
- options={
- "verbose_name": "Sensed Entity",
- "verbose_name_plural": "Sensed Entities",
- },
- ),
]
diff --git a/src/hi/apps/sense/migrations/0002_sensor_integration_id_sensor_integration_type_str.py b/src/hi/apps/sense/migrations/0002_sensor_integration_id_sensor_integration_type_str.py
deleted file mode 100644
index 1bdae33e..00000000
--- a/src/hi/apps/sense/migrations/0002_sensor_integration_id_sensor_integration_type_str.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 22:27
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("sense", "0001_initial"),
- ]
-
- operations = [
- migrations.AddField(
- model_name="sensor",
- name="integration_id",
- field=models.CharField(
- blank=True, max_length=128, null=True, verbose_name="Integration Id"
- ),
- ),
- migrations.AddField(
- model_name="sensor",
- name="integration_type_str",
- field=models.CharField(
- blank=True, max_length=32, null=True, verbose_name="Integration Type"
- ),
- ),
- ]
diff --git a/src/hi/apps/sense/migrations/0003_rename_integration_id_sensor_integration_key.py b/src/hi/apps/sense/migrations/0003_rename_integration_id_sensor_integration_key.py
deleted file mode 100644
index a505b53c..00000000
--- a/src/hi/apps/sense/migrations/0003_rename_integration_id_sensor_integration_key.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 23:55
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("sense", "0002_sensor_integration_id_sensor_integration_type_str"),
- ]
-
- operations = [
- migrations.RenameField(
- model_name="sensor",
- old_name="integration_id",
- new_name="integration_key",
- ),
- ]
diff --git a/src/hi/apps/sense/migrations/0004_alter_sensor_integration_key.py b/src/hi/apps/sense/migrations/0004_alter_sensor_integration_key.py
deleted file mode 100644
index b63663d4..00000000
--- a/src/hi/apps/sense/migrations/0004_alter_sensor_integration_key.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-25 23:56
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("sense", "0003_rename_integration_id_sensor_integration_key"),
- ]
-
- operations = [
- migrations.AlterField(
- model_name="sensor",
- name="integration_key",
- field=models.CharField(
- blank=True, max_length=128, null=True, verbose_name="Integration Key"
- ),
- ),
- ]
diff --git a/src/hi/apps/sense/migrations/0005_delete_sensedentity.py b/src/hi/apps/sense/migrations/0005_delete_sensedentity.py
deleted file mode 100644
index b7ffbd5f..00000000
--- a/src/hi/apps/sense/migrations/0005_delete_sensedentity.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Generated by Django 4.2.15 on 2024-08-28 02:14
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("sense", "0004_alter_sensor_integration_key"),
- ]
-
- operations = [
- migrations.DeleteModel(
- name="SensedEntity",
- ),
- ]
diff --git a/src/hi/integrations/core/admin.py b/src/hi/integrations/core/admin.py
index 07393426..ba6e55aa 100644
--- a/src/hi/integrations/core/admin.py
+++ b/src/hi/integrations/core/admin.py
@@ -3,8 +3,8 @@ from django.contrib import admin
from . import models
-class IntegrationPropertyInLine(admin.TabularInline):
- model = models.IntegrationProperty
+class IntegrationAttributeInLine(admin.TabularInline):
+ model = models.IntegrationAttribute
extra = 0
show_change_link = True
@@ -20,4 +20,4 @@ class IntegrationAdmin(admin.ModelAdmin):
'updated_datetime',
)
- inlines = [ IntegrationPropertyInLine, ]
+ inlines = [ IntegrationAttributeInLine, ]
diff --git a/src/hi/integrations/core/enums.py b/src/hi/integrations/core/enums.py
index 0470d550..297bbd0b 100644
--- a/src/hi/integrations/core/enums.py
+++ b/src/hi/integrations/core/enums.py
@@ -1,16 +1,9 @@
from hi.apps.common.enums import LabeledEnum
-class PropertyValueType(LabeledEnum):
-
- STRING = ('String', '' )
- INTEGER = ('Integer', '' )
- FLOAT = ('Float', '' )
-
-
class IntegrationType(LabeledEnum):
- NONE = ( 'None', 'No integration placeholder.' )
+ NONE = ( 'None', 'No integration.' )
ZONEMINDER = ( 'ZoneMinder', 'ZoneMinder camera streaming and motion detection.' )
HASS = ( 'Home Assistant (hass)', 'Home Assistant device access' )
diff --git a/src/hi/integrations/core/exceptions.py b/src/hi/integrations/core/exceptions.py
index 97364a5a..f10424e6 100644
--- a/src/hi/integrations/core/exceptions.py
+++ b/src/hi/integrations/core/exceptions.py
@@ -1,4 +1,4 @@
-class IntegrationPropertyError(Exception):
+class IntegrationAttributeError(Exception):
pass
diff --git a/src/hi/integrations/core/integration_factory.py b/src/hi/integrations/core/integration_factory.py
index dccb6fa9..bded5a92 100644
--- a/src/hi/integrations/core/integration_factory.py
+++ b/src/hi/integrations/core/integration_factory.py
@@ -21,6 +21,8 @@ class IntegrationFactory( Singleton ):
def get_all_integrations( self ) -> List[ Integration ]:
integration_list = list()
for integration_type in IntegrationType:
+ if integration_type == IntegrationType.NONE:
+ continue
integration = self.get_integration( integration_type = integration_type )
integration_list.append( integration )
continue
diff --git a/src/hi/integrations/core/migrations/0001_initial.py b/src/hi/integrations/core/migrations/0001_initial.py
index 7f6c2a99..4083723a 100644
--- a/src/hi/integrations/core/migrations/0001_initial.py
+++ b/src/hi/integrations/core/migrations/0001_initial.py
@@ -1,4 +1,4 @@
-# Generated by Django 4.2.15 on 2024-08-23 19:12
+# Generated by Django 4.2.15 on 2024-10-12 15:30
from django.db import migrations, models
import django.db.models.deletion
diff --git a/src/hi/apps/location/migrations/0013_locationattribute.py b/src/hi/integrations/core/migrations/0002_integrationattribute_delete_integrationproperty.py
similarity index 79%
rename from src/hi/apps/location/migrations/0013_locationattribute.py
rename to src/hi/integrations/core/migrations/0002_integrationattribute_delete_integrationproperty.py
index 42d3be86..0902e4ee 100644
--- a/src/hi/apps/location/migrations/0013_locationattribute.py
+++ b/src/hi/integrations/core/migrations/0002_integrationattribute_delete_integrationproperty.py
@@ -1,4 +1,4 @@
-# Generated by Django 4.2.15 on 2024-10-11 19:54
+# Generated by Django 4.2.15 on 2024-10-12 17:09
from django.db import migrations, models
import django.db.models.deletion
@@ -7,12 +7,12 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
- ("location", "0012_remove_location_svg_filename"),
+ ("core", "0001_initial"),
]
operations = [
migrations.CreateModel(
- name="LocationAttribute",
+ name="IntegrationAttribute",
fields=[
(
"id",
@@ -52,23 +52,21 @@ class Migration(migrations.Migration):
models.DateTimeField(auto_now=True, verbose_name="Updated"),
),
(
- "location",
+ "integration",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
- related_name="attributes",
- to="location.location",
- verbose_name="Location",
+ related_name="properties",
+ to="core.integration",
+ verbose_name="Integration",
),
),
],
options={
"verbose_name": "Attribute",
"verbose_name_plural": "Attributes",
- "indexes": [
- models.Index(
- fields=["name", "value"], name="location_lo_name_0c26e1_idx"
- )
- ],
},
),
+ migrations.DeleteModel(
+ name="IntegrationProperty",
+ ),
]
diff --git a/src/hi/integrations/core/models.py b/src/hi/integrations/core/models.py
index 20b3fd10..cbd11a34 100644
--- a/src/hi/integrations/core/models.py
+++ b/src/hi/integrations/core/models.py
@@ -3,7 +3,10 @@ from typing import Dict
from django.db import models
-from .enums import IntegrationType, PropertyValueType
+from hi.apps.attribute.enums import AttributeValueType
+from hi.apps.attribute.models import AttributeModel
+
+from .enums import IntegrationType
class Integration( models.Model ):
@@ -46,7 +49,7 @@ class Integration( models.Model ):
return
@property
- def property_dict(self) -> Dict[ str, 'IntegrationProperty' ] :
+ def property_dict(self) -> Dict[ str, 'IntegrationAttribute' ] :
property_dict = dict()
for prop in self.properties.all():
property_dict[prop.name] = prop
@@ -54,7 +57,7 @@ class Integration( models.Model ):
return property_dict
-class IntegrationProperty(models.Model):
+class IntegrationAttribute( AttributeModel ):
integration = models.ForeignKey(
Integration,
@@ -62,48 +65,10 @@ class IntegrationProperty(models.Model):
verbose_name = 'Integration',
on_delete=models.CASCADE,
)
- name = models.CharField(
- 'Name',
- max_length = 64,
- )
- value = models.TextField(
- 'Value',
- )
- value_type_str = models.CharField(
- 'Value Type',
- max_length = 32,
- null = False, blank = False,
- )
- is_editable = models.BooleanField(
- 'Editable?',
- default = True,
- )
- is_required = models.BooleanField(
- 'Required?',
- default = False,
- )
- created_datetime = models.DateTimeField(
- 'Created',
- auto_now_add = True,
- )
- updated_datetime = models.DateTimeField(
- 'Updated',
- auto_now=True,
- blank = True,
- )
class Meta:
- verbose_name = 'Property'
- verbose_name_plural = 'Properties'
-
- @property
- def value_type(self):
- return PropertyValueType.from_name_safe( self.value_type_str )
-
- @value_type.setter
- def value_type( self, value_type : PropertyValueType ):
- self.value_type_str = str(value_type)
- return
+ verbose_name = 'Attribute'
+ verbose_name_plural = 'Attributes'
@dataclass
diff --git a/src/hi/integrations/core/templates/core/panes/config_tab.html b/src/hi/integrations/core/templates/core/panes/config_tab.html
index b6fd7296..abf29763 100644
--- a/src/hi/integrations/core/templates/core/panes/config_tab.html
+++ b/src/hi/integrations/core/templates/core/panes/config_tab.html
@@ -1,54 +1,56 @@
-{% if error_message %}
-<div class="alert alert-danger">
- <b>Error</b>: {{ error_message }}
-</div>
-{% endif %}
-
-{% if info_message %}
-<div class="alert alert-info">
- {{ info_message }}
-</div>
-{% endif %}
-
-{% for integration in integration_list %}
-<div class="row hi-config-integration">
- <div class="col-2">
- {{ integration.integration_type.label }}
+<div class="m-2" >
+ {% if error_message %}
+ <div class="alert alert-danger">
+ <b>Error</b>: {{ error_message }}
</div>
- <div class="col-2">
- {% if integration.is_enabled %}
- <span class="text-success">ENABLED</span>
- {% else %}
- <span class="text-danger">DISABLED</span>
- {% endif %}
- </div>
- <div class="col-2">
- {% if integration.is_enabled %}
- <form action="{% url 'integration_config' name=integration.integration_type.name action='disable' %}"
- method="POST" role="form" data-async="#{{ DIVID.INTEGRATION_TAB }}">
- {% csrf_token %}
- <button type="submit" class="btn btn-danger btn-control" role="button"">DISABLE</button>
- </form>
-
- {% else %}
- <form action="{% url 'integration_config' name=integration.integration_type.name action='enable' %}"
- method="POST" role="form" data-async="#{{ DIVID.INTEGRATION_TAB }}">
- {% csrf_token %}
- <button type="submit" class="btn btn-success btn-control" role="button" >ENABLE</button>
- </form>
- {% endif %}
+ {% endif %}
+
+ {% if info_message %}
+ <div class="alert alert-info">
+ {{ info_message }}
</div>
- <div class="col-2">
- {% if integration.is_enabled %}
- <a href="{% url 'integration_manage' name=integration.integration_type.name %}"
- class="btn btn-info btn-control" role="button"
- data-async="#{{ DIVID.INTEGRATION_TAB }}" >
- MANAGE
- </a>
- </form>
- {% else %}
- ---
- {% endif %}
+ {% endif %}
+
+ {% for integration in integration_list %}
+ <div class="row hi-config-integration">
+ <div class="col-3">
+ {{ integration.integration_type.label }}
+ </div>
+ <div class="col-2">
+ {% if integration.is_enabled %}
+ <span class="text-success">ENABLED</span>
+ {% else %}
+ <span class="text-danger">DISABLED</span>
+ {% endif %}
+ </div>
+ <div class="col-2">
+ {% if integration.is_enabled %}
+ <form action="{% url 'integration_config' name=integration.integration_type.name action='disable' %}"
+ method="POST" role="form" data-async="#{{ DIVID.INTEGRATION_TAB }}">
+ {% csrf_token %}
+ <button type="submit" class="btn btn-danger btn-control" role="button"">DISABLE</button>
+ </form>
+
+ {% else %}
+ <form action="{% url 'integration_config' name=integration.integration_type.name action='enable' %}"
+ method="POST" role="form" data-async="#{{ DIVID.INTEGRATION_TAB }}">
+ {% csrf_token %}
+ <button type="submit" class="btn btn-success btn-control" role="button" >ENABLE</button>
+ </form>
+ {% endif %}
+ </div>
+ <div class="col-2">
+ {% if integration.is_enabled %}
+ <a href="{% url 'integration_manage' name=integration.integration_type.name %}"
+ class="btn btn-info btn-control" role="button"
+ data-async="#{{ DIVID.INTEGRATION_TAB }}" >
+ MANAGE
+ </a>
+ </form>
+ {% else %}
+ &nbsp;
+ {% endif %}
+ </div>
</div>
+ {% endfor %}
</div>
-{% endfor %}
diff --git a/src/hi/integrations/core/views.py b/src/hi/integrations/core/views.py
index 4ed2b812..eecaf272 100644
--- a/src/hi/integrations/core/views.py
+++ b/src/hi/integrations/core/views.py
@@ -19,6 +19,10 @@ class IntegrationViewMixin:
class IntegrationConfigTabView( View, IntegrationViewMixin ):
+ def get(self, request, *args, **kwargs):
+ context = self.get_integration_config_tab_context()
+ return render( request, 'core/panes/config_tab.html', context )
+
def post(self, request, *args, **kwargs):
error_message = None
@@ -44,7 +48,7 @@ class IntegrationConfigTabView( View, IntegrationViewMixin ):
}
context.update( self.get_integration_config_tab_context() )
return render( request, 'core/panes/config_tab.html', context )
-
+
class IntegrationManageView( View, IntegrationViewMixin ):
@@ -69,3 +73,5 @@ class IntegrationManageView( View, IntegrationViewMixin ):
def post(self, request, *args, **kwargs):
return self.get( request, *args, **kwargs)
+
+
diff --git a/src/hi/integrations/hass/enums.py b/src/hi/integrations/hass/enums.py
index 519ca3c4..5027ac9c 100644
--- a/src/hi/integrations/hass/enums.py
+++ b/src/hi/integrations/hass/enums.py
@@ -1,17 +1,18 @@
from hi.apps.common.enums import LabeledEnum
-from hi.integrations.core.enums import PropertyValueType
+from hi.apps.attribute.enums import AttributeValueType
-class HassPropertyName(LabeledEnum):
+class HassAttributeName(LabeledEnum):
def __init__( self,
- label : str,
- description : str,
- value_type : PropertyValueType,
- is_editable : bool,
- is_required : bool ):
+ label : str,
+ description : str,
+ attribute_value_type : AttributeValueType,
+ is_editable : bool,
+ is_required : bool ):
super().__init__( label, description )
+ self.attribute_value_type = attribute_value_type,
self.is_editable = is_editable
self.is_required = is_required
return
@@ -19,14 +20,14 @@ class HassPropertyName(LabeledEnum):
API_BASE_URL = (
' URL',
'e.g., https://myhassserver:8123',
- PropertyValueType.STRING,
+ AttributeValueType.STRING,
True,
True,
)
API_TOKEN = (
'API Token',
'',
- PropertyValueType.STRING,
+ AttributeValueType.STRING,
True,
True,
)
diff --git a/src/hi/integrations/hass/hass_manager.py b/src/hi/integrations/hass/hass_manager.py
index 149fe70f..85ebf5be 100644
--- a/src/hi/integrations/hass/hass_manager.py
+++ b/src/hi/integrations/hass/hass_manager.py
@@ -7,10 +7,10 @@ from hi.apps.common.singleton import Singleton
from hi.apps.entity.models import Entity
from hi.integrations.core.enums import IntegrationType
-from hi.integrations.core.exceptions import IntegrationPropertyError
+from hi.integrations.core.exceptions import IntegrationAttributeError
from hi.integrations.core.models import Integration
-from .enums import HassPropertyName
+from .enums import HassAttributeName
from .hass_client import HassClient
from .hass_converter import HassConverter
from .hass_models import HassState, HassDevice
@@ -56,19 +56,19 @@ class HassManager( Singleton ):
return None
# Verify integration
- property_dict = hass_integration.property_dict
- for hass_prop_name in HassPropertyName:
- hass_prop = property_dict.get( hass_prop_name.name )
+ attribute_dict = hass_integration.attribute_dict
+ for hass_attr_name in HassAttributeName:
+ hass_prop = attribute_dict.get( hass_attr_name.name )
if not hass_prop:
- raise IntegrationPropertyError( f'Missing HAss property {hass_prop_name.name}' )
+ raise IntegrationAttributeError( f'Missing HAss attribute {hass_attr_name.name}' )
if hass_prop.is_required and not hass_prop.value.strip():
- raise IntegrationPropertyError( f'Missing HAss property value for {hass_prop_name.name}' )
+ raise IntegrationAttributeError( f'Missing HAss attribute value for {hass_attr_name.name}' )
continue
api_options = {
- HassClient.API_BASE_URL: property_dict.get( HassPropertyName.API_BASE_URL.name ).value,
- HassClient.API_TOKEN: property_dict.get( HassPropertyName.API_TOKEN.name ).value,
+ HassClient.API_BASE_URL: attribute_dict.get( HassAttributeName.API_BASE_URL.name ).value,
+ HassClient.API_TOKEN: attribute_dict.get( HassAttributeName.API_TOKEN.name ).value,
}
return HassClient( api_options = api_options )
diff --git a/src/hi/integrations/zoneminder/enums.py b/src/hi/integrations/zoneminder/enums.py
index 73110290..a95e0eb2 100644
--- a/src/hi/integrations/zoneminder/enums.py
+++ b/src/hi/integrations/zoneminder/enums.py
@@ -1,17 +1,18 @@
from hi.apps.common.enums import LabeledEnum
-from hi.integrations.core.enums import PropertyValueType
+from hi.apps.attribute.enums import AttributeValueType
-class ZmPropertyName(LabeledEnum):
+class ZmAttributeName(LabeledEnum):
def __init__( self,
- label : str,
- description : str,
- value_type : PropertyValueType,
- is_editable : bool,
- is_required : bool ):
+ label : str,
+ description : str,
+ attribute_value_type : AttributeValueType,
+ is_editable : bool,
+ is_required : bool ):
super().__init__( label, description )
+ self.attribute_value_type = attribute_value_type,
self.is_editable = is_editable
self.is_required = is_required
return
@@ -19,28 +20,28 @@ class ZmPropertyName(LabeledEnum):
API_URL = (
'API URL',
'e.g., https://myserver:8443/zm/api',
- PropertyValueType.STRING,
+ AttributeValueType.STRING,
True,
True,
)
PORTAL_URL = (
'Portal URL',
'e.g., https://myserver:8443/zm',
- PropertyValueType.STRING,
+ AttributeValueType.STRING,
True,
True,
)
API_USER = (
'Username',
'',
- PropertyValueType.STRING,
+ AttributeValueType.STRING,
True,
True,
)
API_PASSWORD = (
'Password',
'',
- PropertyValueType.STRING,
+ AttributeValueType.STRING,
True,
True,
)
diff --git a/src/hi/integrations/zoneminder/zm_manager.py b/src/hi/integrations/zoneminder/zm_manager.py
index 74b57c05..d74fb38a 100644
--- a/src/hi/integrations/zoneminder/zm_manager.py
+++ b/src/hi/integrations/zoneminder/zm_manager.py
@@ -14,11 +14,11 @@ from hi.apps.entity.models import Entity
from hi.apps.model_helper import HiModelHelper
from hi.integrations.core.enums import IntegrationType
-from hi.integrations.core.exceptions import IntegrationPropertyError
+from hi.integrations.core.exceptions import IntegrationAttributeError
from hi.integrations.core.models import Integration, IntegrationId
from .enums import (
- ZmPropertyName,
+ ZmAttributeName,
ZmMonitorState,
)
@@ -64,21 +64,21 @@ class ZoneMinderManager( Singleton ):
return None
# Verify integration
- property_dict = zm_integration.property_dict
- for zm_prop_name in ZmPropertyName:
- zm_prop = property_dict.get( zm_prop_name.name )
+ attribute_dict = zm_integration.attribute_dict
+ for zm_attr_name in ZmAttributeName:
+ zm_prop = attribute_dict.get( zm_attr_name.name )
if not zm_prop:
- raise IntegrationPropertyError( f'Missing ZM property {zm_prop_name.name}' )
+ raise IntegrationAttributeError( f'Missing ZM attribute {zm_attr_name.name}' )
if zm_prop.is_required and not zm_prop.value.strip():
- raise IntegrationPropertyError( f'Missing ZM property value for {zm_prop_name.name}' )
+ raise IntegrationAttributeError( f'Missing ZM attribute value for {zm_attr_name.name}' )
continue
api_options = {
- 'apiurl': property_dict.get( ZmPropertyName.API_URL.name ).value,
- 'portalurl': property_dict.get( ZmPropertyName.PORTAL_URL.name ).value,
- 'user': property_dict.get( ZmPropertyName.API_USER.name ).value,
- 'password': property_dict.get( ZmPropertyName.API_PASSWORD.name ).value,
+ 'apiurl': attribute_dict.get( ZmAttributeName.API_URL.name ).value,
+ 'portalurl': attribute_dict.get( ZmAttributeName.PORTAL_URL.name ).value,
+ 'user': attribute_dict.get( ZmAttributeName.API_USER.name ).value,
+ 'password': attribute_dict.get( ZmAttributeName.API_PASSWORD.name ).value,
# 'disable_ssl_cert_check': True
}
diff --git a/src/hi/templates/pages/start.html b/src/hi/templates/pages/start.html
index 98e43387..801d750a 100644
--- a/src/hi/templates/pages/start.html
+++ b/src/hi/templates/pages/start.html
@@ -1,14 +1,24 @@
{% extends "pages/base.html" %}
{% block content %}
-<h1>Start Page</h1>
+<div class="container-fluid">
+ <h1>Home Information Center</h1>
+ <h2>Welcome!</h2>
-<div>
- <a role="button" class="btn btn-success"
- href="{% url 'location_edit_location_add' %}"
- data-async="modal">
- ADD NEW LOCATION
- </a>
+ <p>
+ To get started, we need to set up your location.
+ </p>
+ <p>
+ Give your location a new and optionally upload an SVG image of your property and/or house.
+ </p>
+
+ <div>
+ <a role="button" class="btn btn-success"
+ href="{% url 'location_edit_location_add' %}"
+ data-async="modal">
+ ADD MY LOCATION
+ </a>
+ </div>
</div>
{% endblock %}
diff --git a/src/hi/views.py b/src/hi/views.py
index 429294d5..38eafe52 100644
--- a/src/hi/views.py
+++ b/src/hi/views.py
@@ -9,7 +9,9 @@ from django.views.generic import View
import hi.apps.common.antinode as antinode
from hi.apps.common.utils import is_ajax
from hi.apps.location.edit.forms import LocationForm
+from hi.apps.location.models import Location
+from hi.enums import ViewMode
def error_response( request : HttpRequest,
sync_template_name : str,
@@ -150,6 +152,16 @@ class HomeView( View ):
class StartView( View ):
def get(self, request, *args, **kwargs):
+
+ # Only for first time users (when no Locations exist)
+ if Location.objects.all().exists():
+ redirect_url = reverse( 'home' )
+ return HttpResponseRedirect( redirect_url )
+
+ # First actions need edit ability.
+ request.view_parameters.view_mode = ViewMode.EDIT
+ request.view_parameters.to_session( request )
+
context = {
'location_form': LocationForm(),
}