Add more components + base for history

This commit is contained in:
2024-10-01 15:42:18 +02:00
parent fb4d566007
commit 8f9c83dc2a
38 changed files with 1374 additions and 665 deletions
@@ -0,0 +1,36 @@
# Generated by Django 5.1.1 on 2024-09-30 19:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("items", "0004_alter_property_type"),
]
operations = [
migrations.AlterField(
model_name="property",
name="type",
field=models.CharField(
choices=[
("text", "Text"),
("date", "Date"),
("datetime", "Date & time"),
("time", "Time"),
("duration", "Duration"),
("uuid", "UUID"),
("number", "Number"),
("float", "Float"),
("boolean", "Boolean"),
("email", "Email"),
("ipv4", "IPv4 address"),
("ipv6", "IPv6 address"),
("json", "JSON"),
],
default="text",
max_length=32,
),
),
]
@@ -0,0 +1,325 @@
# Generated by Django 5.1.1 on 2024-10-01 13:41
import django.db.models.deletion
import simple_history.models
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("items", "0005_alter_property_type"),
("users", "0006_historicalusersettings"),
]
operations = [
migrations.CreateModel(
name="HistoricalItem",
fields=[
("id", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
("custom_identifier", models.TextField(blank=True, max_length=2048, null=True)),
("created_at", models.DateTimeField(blank=True, editable=False)),
("last_modified_at", models.DateTimeField(blank=True, editable=False)),
("name", models.TextField(max_length=2048)),
("description", models.TextField(max_length=2048)),
("history_id", models.AutoField(primary_key=True, serialize=False)),
("history_date", models.DateTimeField(db_index=True)),
("history_change_reason", models.CharField(max_length=100, null=True)),
("history_type", models.CharField(choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], max_length=1)),
(
"author",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="users.usersettings",
),
),
(
"history_user",
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="users.usersettings"),
),
(
"type",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="items.itemtype",
),
),
],
options={
"verbose_name": "historical item",
"verbose_name_plural": "historical items",
"ordering": ("-history_date", "-history_id"),
"get_latest_by": ("history_date", "history_id"),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name="HistoricalItemRelation",
fields=[
("id", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
("name", models.TextField(blank=True, max_length=2048, null=True)),
("description", models.TextField(blank=True, max_length=2048, null=True)),
("custom_identifier", models.TextField(blank=True, max_length=2048, null=True)),
("created_at", models.DateTimeField(blank=True, editable=False)),
("last_modified_at", models.DateTimeField(blank=True, editable=False)),
("history_id", models.AutoField(primary_key=True, serialize=False)),
("history_date", models.DateTimeField(db_index=True)),
("history_change_reason", models.CharField(max_length=100, null=True)),
("history_type", models.CharField(choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], max_length=1)),
(
"author",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="users.usersettings",
),
),
(
"child",
models.ForeignKey(
blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name="+", to="items.item"
),
),
(
"history_user",
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="users.usersettings"),
),
(
"parent",
models.ForeignKey(
blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name="+", to="items.item"
),
),
],
options={
"verbose_name": "historical item relation",
"verbose_name_plural": "historical item relations",
"ordering": ("-history_date", "-history_id"),
"get_latest_by": ("history_date", "history_id"),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name="HistoricalItemType",
fields=[
("id", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
("name", models.TextField(blank=True, max_length=2048, null=True)),
("description", models.TextField(blank=True, max_length=2048, null=True)),
("custom_identifier", models.TextField(blank=True, max_length=2048, null=True)),
("created_at", models.DateTimeField(blank=True, editable=False)),
("last_modified_at", models.DateTimeField(blank=True, editable=False)),
("history_id", models.AutoField(primary_key=True, serialize=False)),
("history_date", models.DateTimeField(db_index=True)),
("history_change_reason", models.CharField(max_length=100, null=True)),
("history_type", models.CharField(choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], max_length=1)),
(
"author",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="users.usersettings",
),
),
(
"history_user",
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="users.usersettings"),
),
],
options={
"verbose_name": "historical item type",
"verbose_name_plural": "historical item types",
"ordering": ("-history_date", "-history_id"),
"get_latest_by": ("history_date", "history_id"),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name="HistoricalLinkedProperty",
fields=[
("id", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
("name", models.TextField(blank=True, max_length=2048, null=True)),
("description", models.TextField(blank=True, max_length=2048, null=True)),
("custom_identifier", models.TextField(blank=True, max_length=2048, null=True)),
("created_at", models.DateTimeField(blank=True, editable=False)),
("last_modified_at", models.DateTimeField(blank=True, editable=False)),
("value", models.TextField(max_length=2048)),
("history_id", models.AutoField(primary_key=True, serialize=False)),
("history_date", models.DateTimeField(db_index=True)),
("history_change_reason", models.CharField(max_length=100, null=True)),
("history_type", models.CharField(choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], max_length=1)),
(
"author",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="users.usersettings",
),
),
(
"history_user",
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="users.usersettings"),
),
(
"item",
models.ForeignKey(
blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name="+", to="items.item"
),
),
(
"property",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="items.property",
),
),
],
options={
"verbose_name": "historical linked property",
"verbose_name_plural": "historical linked propertys",
"ordering": ("-history_date", "-history_id"),
"get_latest_by": ("history_date", "history_id"),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name="HistoricalProperty",
fields=[
("id", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
("name", models.TextField(blank=True, max_length=2048, null=True)),
("description", models.TextField(blank=True, max_length=2048, null=True)),
("custom_identifier", models.TextField(blank=True, max_length=2048, null=True)),
("created_at", models.DateTimeField(blank=True, editable=False)),
("last_modified_at", models.DateTimeField(blank=True, editable=False)),
(
"type",
models.CharField(
choices=[
("text", "Text"),
("date", "Date"),
("datetime", "Date & time"),
("time", "Time"),
("duration", "Duration"),
("uuid", "UUID"),
("number", "Number"),
("float", "Float"),
("boolean", "Boolean"),
("email", "Email"),
("ipv4", "IPv4 address"),
("ipv6", "IPv6 address"),
("json", "JSON"),
],
default="text",
max_length=32,
),
),
("history_id", models.AutoField(primary_key=True, serialize=False)),
("history_date", models.DateTimeField(db_index=True)),
("history_change_reason", models.CharField(max_length=100, null=True)),
("history_type", models.CharField(choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], max_length=1)),
(
"author",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="users.usersettings",
),
),
(
"history_user",
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="users.usersettings"),
),
],
options={
"verbose_name": "historical property",
"verbose_name_plural": "historical propertys",
"ordering": ("-history_date", "-history_id"),
"get_latest_by": ("history_date", "history_id"),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name="HistoricalRelationProperty",
fields=[
("id", models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
("name", models.TextField(blank=True, max_length=2048, null=True)),
("description", models.TextField(blank=True, max_length=2048, null=True)),
("custom_identifier", models.TextField(blank=True, max_length=2048, null=True)),
("created_at", models.DateTimeField(blank=True, editable=False)),
("last_modified_at", models.DateTimeField(blank=True, editable=False)),
("value", models.TextField(max_length=2048)),
("history_id", models.AutoField(primary_key=True, serialize=False)),
("history_date", models.DateTimeField(db_index=True)),
("history_change_reason", models.CharField(max_length=100, null=True)),
("history_type", models.CharField(choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], max_length=1)),
(
"author",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="users.usersettings",
),
),
(
"history_user",
models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="users.usersettings"),
),
(
"property",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="items.property",
),
),
(
"relation",
models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="items.itemrelation",
),
),
],
options={
"verbose_name": "historical relation property",
"verbose_name_plural": "historical relation propertys",
"ordering": ("-history_date", "-history_id"),
"get_latest_by": ("history_date", "history_id"),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
]