Skip to content

Commit

Permalink
Added Version / UserAdditionalInfo entities
Browse files Browse the repository at this point in the history
  • Loading branch information
rw-bsi committed Nov 17, 2024
1 parent 1838e91 commit c4c5924
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
50 changes: 50 additions & 0 deletions migrations/0003_version_useradditionalinfo.py
Original file line number Diff line number Diff line change
@@ -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',
},
),
]
76 changes: 76 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit c4c5924

Please sign in to comment.