From c4c5924124175ee2d7c9be587369d6e740af900c Mon Sep 17 00:00:00 2001 From: rw-bsi Date: Sun, 17 Nov 2024 15:35:41 +0000 Subject: [PATCH] Added Version / UserAdditionalInfo entities --- migrations/0003_version_useradditionalinfo.py | 50 ++++++++++++ models.py | 76 +++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 migrations/0003_version_useradditionalinfo.py diff --git a/migrations/0003_version_useradditionalinfo.py b/migrations/0003_version_useradditionalinfo.py new file mode 100644 index 0000000..b938a45 --- /dev/null +++ b/migrations/0003_version_useradditionalinfo.py @@ -0,0 +1,50 @@ +# Generated by Django 5.1.3 on 2024-11-17 15:30 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ifc_validation_models', '0002_modelinstance_modelid_stepfileid_ifctype'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Version', + fields=[ + ('created', models.DateTimeField(auto_now_add=True, help_text='Timestamp this instance was created.')), + ('updated', models.DateTimeField(blank=True, help_text='Timestamp this instance was last updated.', null=True)), + ('id', models.AutoField(help_text='Identifier of the Version (auto-generated).', primary_key=True, serialize=False)), + ('name', models.CharField(db_index=True, help_text='Name of the Version, eg. 0.6.8', max_length=50, unique=True)), + ('released', models.DateTimeField(help_text='Timestamp the Version was released.')), + ('release_notes', models.TextField(blank=True, help_text='Description or URL of the Release Notes.', max_length=255, null=True)), + ], + options={ + 'verbose_name': 'Version', + 'verbose_name_plural': 'Versions', + 'db_table': 'ifc_version', + }, + ), + migrations.CreateModel( + name='UserAdditionalInfo', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True, help_text='Timestamp this instance was created.')), + ('updated', models.DateTimeField(blank=True, help_text='Timestamp this instance was last updated.', null=True)), + ('is_vendor', models.BooleanField(blank=True, help_text='Whether this user belongs to an Authoring Tool vendor (optional)', null=True)), + ('company', models.OneToOneField(blank=True, help_text='What Company the User belongs to (optional)', null=True, on_delete=django.db.models.deletion.CASCADE, to='ifc_validation_models.company')), + ('created_by', models.ForeignKey(help_text='Who created this instance', on_delete=django.db.models.deletion.RESTRICT, related_name='+', to=settings.AUTH_USER_MODEL)), + ('updated_by', models.ForeignKey(blank=True, help_text='Who updated this instance.', null=True, on_delete=django.db.models.deletion.RESTRICT, related_name='+', to=settings.AUTH_USER_MODEL)), + ('user', models.OneToOneField(help_text='What User this additional info belongs to', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'User Additional Info', + 'verbose_name_plural': 'User Additional Info', + 'db_table': 'ifc_user_aditional_info', + }, + ), + ] diff --git a/models.py b/models.py index d50b600..470de09 100644 --- a/models.py +++ b/models.py @@ -230,6 +230,38 @@ def __str__(self): return f'{self.name}' +class UserAdditionalInfo(AuditedBaseModel): + """ + A model to store and track additional User fields. + """ + + user = models.OneToOneField( + User, + on_delete=models.CASCADE, + help_text='What User this additional info belongs to' + ) + + is_vendor = models.BooleanField( + null=True, + blank=True, + help_text='Whether this user belongs to an Authoring Tool vendor (optional)' + ) + + company = models.OneToOneField( + Company, + null=True, + blank=True, + on_delete=models.CASCADE, + help_text='What Company the User belongs to (optional)' + ) + + class Meta: + + db_table = "ifc_user_aditional_info" + verbose_name = "User Additional Info" + verbose_name_plural = "User Additional Info" + + class AuthoringTool(TimestampedBaseModel): """ A model to store and track Authoring Tool information. @@ -1158,6 +1190,50 @@ def determine_severity(self): raise ValueError(f"Outcome code '{self.name}' not recognized") +class Version(TimestampedBaseModel): + + """ + A model to store and track Validation Service software versions. + """ + + id = models.AutoField( + primary_key=True, + help_text="Identifier of the Version (auto-generated)." + ) + + name = models.CharField( + max_length=50, + null=False, + blank=False, + unique=True, + db_index=True, + help_text="Name of the Version, eg. 0.6.8" + ) + + released = models.DateTimeField( + null=False, + blank=False, + help_text="Timestamp the Version was released." + ) + + release_notes = models.TextField( + max_length=255, + null=True, + blank=True, + help_text="Description or URL of the Release Notes (optional)." + ) + + class Meta: + + db_table = "ifc_version" + verbose_name = "Version" + verbose_name_plural = "Versions" + + def __str__(self): + + return f'{self.name}' + + id_prefix_mapping = { Model: 'm', ModelInstance: 'i',