From ec25fe8daa6db136529126c9f145bbd908283d6c Mon Sep 17 00:00:00 2001 From: Lars van Vianen Date: Sun, 7 Jul 2024 11:10:13 +0200 Subject: [PATCH] Cleaning --- src/django-bim/models/model_ifc_actor_role.py | 104 ----------- src/django-bim/models/model_ifc_address.py | 123 ------------- .../models/model_ifc_application.py | 122 ------------- src/django-bim/models/model_ifc_building.py | 41 ----- .../models/model_ifc_cartesian_point.py | 0 src/django-bim/models/model_ifc_object.py | 96 ---------- .../models/model_ifc_object_definition.py | 90 ---------- .../models/model_ifc_organization.py | 125 ------------- .../models/model_ifc_owner_history.py | 148 ---------------- src/django-bim/models/model_ifc_person.py | 166 ------------------ .../models/model_ifc_person_organization.py | 102 ----------- src/django-bim/models/model_ifc_product.py | 18 -- src/django-bim/models/model_ifc_project.py | 101 ----------- .../models/model_ifc_representation.py | 99 ----------- .../model_ifc_representation_context.py | 102 ----------- .../models/model_ifc_representation_item.py | 74 -------- src/django-bim/models/model_ifc_root.py | 120 ------------- 17 files changed, 1631 deletions(-) delete mode 100644 src/django-bim/models/model_ifc_actor_role.py delete mode 100644 src/django-bim/models/model_ifc_address.py delete mode 100644 src/django-bim/models/model_ifc_application.py delete mode 100644 src/django-bim/models/model_ifc_building.py delete mode 100644 src/django-bim/models/model_ifc_cartesian_point.py delete mode 100644 src/django-bim/models/model_ifc_object.py delete mode 100644 src/django-bim/models/model_ifc_object_definition.py delete mode 100644 src/django-bim/models/model_ifc_organization.py delete mode 100644 src/django-bim/models/model_ifc_owner_history.py delete mode 100644 src/django-bim/models/model_ifc_person.py delete mode 100644 src/django-bim/models/model_ifc_person_organization.py delete mode 100644 src/django-bim/models/model_ifc_product.py delete mode 100644 src/django-bim/models/model_ifc_project.py delete mode 100644 src/django-bim/models/model_ifc_representation.py delete mode 100644 src/django-bim/models/model_ifc_representation_context.py delete mode 100644 src/django-bim/models/model_ifc_representation_item.py delete mode 100644 src/django-bim/models/model_ifc_root.py diff --git a/src/django-bim/models/model_ifc_actor_role.py b/src/django-bim/models/model_ifc_actor_role.py deleted file mode 100644 index 88fd642..0000000 --- a/src/django-bim/models/model_ifc_actor_role.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Actor Role Model Class -=================================== - -This model represents the IfcActorRole as defined in the IFC 2x3 standard, -detailing the roles played by different actors (e.g., individuals or -organizations) in construction projects. - -For more information, refer to: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcactorresource/lexical/ifcactorrole.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from ..fields.model import ( - # IfcGloballyUniqueIdField, - # IfcIdentifierField, - IfcLabelField, - IfcRoleTypeField, - IfcTextField, -) -# from ..enums import ( -# IfcRoleEnum, -# ) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcActorRoleModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcActorRoleModel(models.Model): - """ - IFC Actor Role Model Class - ========================== - - Model representing an IfcActorRole as defined in the IFC standard. - - This model captures the roles played by actors in construction projects. - Each role can be predefined or user-defined, and includes a description. - - Attributes: - role_type (CharField): Specifies the standard role type from IFC - standards or 'USERDEFINED' if not listed. - user_defined_role (IfcLabelField): Allows specification of a role not - included in standard choices, applicable if role_type - is 'USERDEFINED'. - description (IfcTextField): Describes the responsibilities and duties - associated with the role. - """ - - role_type = IfcRoleTypeField( - verbose_name=_("Role"), - help_text=_("The role of the actor in the project according to IFC standards.") # noqa E501 - ) - - user_defined_role = IfcLabelField( - blank=True, - null=True, - verbose_name=_("User Defined Role"), - help_text=_("A user-defined role, applicable if the role type is 'USERDEFINED'.") # noqa E501 - ) - - description = IfcTextField( - blank=True, - null=True, - verbose_name=_("Description"), - help_text=_("A description of the role.") - ) - - def __str__(self): - if self.user_defined_role: - return f"{self.user_defined_role} ({self.get_role_type_display()})" - return self.get_role_type_display() - - class Meta: - verbose_name = _("IFC Actor Role") - verbose_name_plural = _("IFC Actor Roles") diff --git a/src/django-bim/models/model_ifc_address.py b/src/django-bim/models/model_ifc_address.py deleted file mode 100644 index 059b5cd..0000000 --- a/src/django-bim/models/model_ifc_address.py +++ /dev/null @@ -1,123 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Address Model Class -================================ - - -For more information, refer to: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcactorresource/lexical/ifcaddress.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from ..fields.model import ( - # IfcGloballyUniqueIdField, - # IfcIdentifierField, - IfcLabelField, - IfcTextField, -) -from ..enums import IfcAddressTypeEnum - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcAddressModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcAddressModel(models.Model): - """ - IFC Address Model Class - ======================= - - Model representing an IfcAddress as defined in the IFC 2x3 standard. - - This model is capable of representing various types of addresses including - physical, postal, telecom, and email addresses in accordance with the - specifications provided in the IFC standards. - - Attributes: - purpose (CharField): The intended purpose of this address, based on - IfcAddressTypeEnum. - description (TextField): Additional description or notes about - the address. - user_defined_purpose (CharField): Allows specification of a - non-standard purpose, if 'USERDEFINED' is chosen. - of_organization (ForeignKey): Link to the organization this address - belongs to. - of_person (ForeignKey): Link to the person this address belongs to. - - """ - - purpose = models.CharField( - max_length=50, - choices=IfcAddressTypeEnum.choices(), - default=IfcAddressTypeEnum.NOTDEFINED.name, - verbose_name=_("Purpose"), - help_text=_("The intended purpose of this address, according to IfcAddressTypeEnum.") # noqa E501 - ) - - description = IfcTextField( - blank=True, - null=True, - verbose_name=_("Description"), - help_text=_("Additional description or notes about the address.") - ) - - user_defined_purpose = IfcLabelField( - blank=True, - null=True, - verbose_name=_("User Defined Purpose"), - help_text=_("Specify the purpose if 'USERDEFINED' is selected in 'purpose'.") # noqa E501 - ) - - # of_organization = models.ForeignKey( - # 'IfcOrganization', - # on_delete=models.CASCADE, - # related_name='addresses', - # null=True, - # blank=True, - # verbose_name=_("Organization"), - # help_text=_("The organization this address is associated with.") - # ) - - # of_person = models.ForeignKey( - # 'IfcPerson', - # on_delete=models.CASCADE, - # related_name='addresses', - # null=True, - # blank=True, - # verbose_name=_("Person"), - # help_text=_("The person this address is associated with.") - # ) - - def __str__(self): - return f"{self.purpose}: {self.description[:50]}..." if self.description else self.purpose # noqa E501 - - class Meta: - verbose_name = _("IFC Address") - verbose_name_plural = _("IFC Addresses") diff --git a/src/django-bim/models/model_ifc_application.py b/src/django-bim/models/model_ifc_application.py deleted file mode 100644 index 3b3eb31..0000000 --- a/src/django-bim/models/model_ifc_application.py +++ /dev/null @@ -1,122 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Application Model Class -==================================== - -This module defines the IfcApplicationModel, which records details about the -software application used in the creation, modification, or interpretation of -IFC data models. This model is in accordance with the IFC 2x3 standard and -includes information about the application's developer, name, version, and a -unique identifier. - -For more information, refer to: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcutilityresource/lexical/ifcapplication.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from ..fields.model import ( - # IfcGloballyUniqueIdField, - IfcIdentifierField, - IfcLabelField, - # IfcTextField, -) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcApplicationModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcApplicationModel(models.Model): - """ - IFC Application Model Class - =========================== - - Model representing an IfcApplication, which is a component of the IFC - standard used to record and reference the application software being used - to generate the IFC model. - - This includes details about the application developer, software name, - version identifier, and a unique application identifier. - - This model stores information about the software used to generate, modify, - or analyze IFC models, facilitating documentation and standardization of - application metadata. - - Attributes: - application_developer (ForeignKey): Reference to the IfcOrganization - responsible for the application. - application_full_name (IfcLabelField): The official name of the - application. - application_identifier (IfcIdentifierField): A unique identifier for - the application, often as a UUID. - version (IfcLabelField): The software version detail. - - """ - - application_developer = models.ForeignKey( - 'IfcOrganizationModel', - on_delete=models.SET_NULL, - null=True, - blank=True, - related_name='developed_applications', - verbose_name=_("Application Developer"), - help_text=_("Name of the organization or individual developing the application.") # noqa E501 - ) - - application_full_name = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Application Full Name"), - help_text=_("Full name of the application software.") - ) - - application_identifier = IfcIdentifierField( - unique=True, # Ensuring uniqueness for each application identifier - blank=True, - null=True, - verbose_name=_("Application Identifier"), - help_text=_("A unique identifier for the application.") - ) - - version = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Version"), - help_text=_("The version of the application software.") - ) - - def __str__(self) -> str: - dev_name = self.application_developer.name if self.application_developer else "Unknown Developer" # noqa E501 - return f"{self.application_full_name or 'Unnamed Application'} {self.version or 'v. Unknown'} by {dev_name}" # noqa E501 - - class Meta: - verbose_name = _("IfcApplication") - verbose_name_plural = _("IfcApplications") - ordering = ['application_full_name', 'version'] diff --git a/src/django-bim/models/model_ifc_building.py b/src/django-bim/models/model_ifc_building.py deleted file mode 100644 index c0f4b17..0000000 --- a/src/django-bim/models/model_ifc_building.py +++ /dev/null @@ -1,41 +0,0 @@ -from django.db import models - - -class Building(models.Model): - """ - """ - name = models.CharField(max_length=100) - address = models.TextField() - - def __str__(self): - return self.name - -class Building(models.Model): - project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='buildings') - name = models.CharField(max_length=255) - location_description = models.CharField(max_length=255, blank=True, null=True) - - def __str__(self): - return self.name - - -class IfcBuilding(models.Model): - # Core Attributes - name = models.CharField(max_length=255, blank=True, null=True) - description = models.TextField(blank=True, null=True) - - # Relational Attributes - object_placement = models.JSONField(blank=True, null=True, help_text="Spatial structure of the building.") - representation = models.JSONField(blank=True, null=True, help_text="Representation of the building in terms of geometry or other parameters.") - - # Specific Attributes - elevation_of_ref_height = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text="Elevation at reference height above sea level.") - elevation_of_terrain = models.DecimalField(max_digits=9, decimal_places=2, blank=True, null=True, help_text="Elevation of the natural terrain around the building's perimeter at reference height.") - building_address = models.JSONField(blank=True, null=True, help_text="Address of the building.") - - # Relationships (For simplicity, assuming relationships are managed as JSON. Adjust according to your application's needs.) - building_elements = models.JSONField(blank=True, null=True, help_text="Elements that form part of the building.") - project = models.ForeignKey('IfcProject', on_delete=models.CASCADE, related_name='buildings', blank=True, null=True) - - def __str__(self): - return self.name or "Unnamed Building" diff --git a/src/django-bim/models/model_ifc_cartesian_point.py b/src/django-bim/models/model_ifc_cartesian_point.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/django-bim/models/model_ifc_object.py b/src/django-bim/models/model_ifc_object.py deleted file mode 100644 index 65772f9..0000000 --- a/src/django-bim/models/model_ifc_object.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Object Model Class -=============================== - -This Django model represents an IfcObject as defined in the IFC 2x3 standard, -which serves as a generalization for any entity participating in a project -context. It supports the instantiation of both physical (product) and -non-physical (control elements) entities. - -For detailed specifications, see: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifckernel/lexical/ifcobject.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.urls import reverse -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from .model_ifc_object_definition import IfcObjectDefinitionModel -from ..fields.model import ( - IfcLabelField, -) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcObjectModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcObjectModel(IfcObjectDefinitionModel): - """ - IFC Object Model Class - ====================== - - Model representing an IfcObject as defined in the IFC 2x3 standard. - - IfcObject is a generalization of any entity that participates in a - project context and forms the most generic instantiation of all entities - that are used within IFC. It may represent objects that are physical - (product) or non-physical (control elements). - - Attributes: - object_type (models.CharField): A user-defined type for the object that - can further classify the specific object types beyond the system - provided by the entity type name. - - """ - - object_type = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Object Type"), - help_text=_("A user-defined type to classify the object beyond its classification by entity type.") # noqa E501 - ) - - class Meta: - verbose_name = _("IfcObject") - verbose_name_plural = _("IfcObjects") - abstract = True # This model remains abstract and should be inherited - - def __str__(self): - """ - Provides a human-readable string that is more informative, - especially in admin or logs. - """ - return f"{self.name} - {self.object_type}" if self.object_type else super().__str__() # noqa E501 - - def get_absolute_url(self): - """ - Generate the absolute URL for an object instance to aid in admin - navigation or UI display. - """ - return reverse('ifc_object_detail', kwargs={'pk': self.pk}) diff --git a/src/django-bim/models/model_ifc_object_definition.py b/src/django-bim/models/model_ifc_object_definition.py deleted file mode 100644 index 3246f0a..0000000 --- a/src/django-bim/models/model_ifc_object_definition.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Object Definition Model Class -========================================= - -This Django model class serves as an abstract base for all object definitions -according to the IFC 2x3 standard. It encapsulates common attributes and -behaviors that are inherited by more specific IFC entity models, facilitating -generic metadata management and object relationships. - -This model enhances the IfcRootModel by adding or refining functionality -specific to object definitions. - -For detailed specifications, see: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifckernel/lexical/ifcobjectdefinition.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.urls import reverse -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from .model_ifc_root import IfcRootModel - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcObjectDefinitionModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcObjectDefinitionModel(IfcRootModel): - """ - IFC Object Definition Model Class - ================================ - - Abstract model representing an IfcObjectDefinition as defined in the - IFC 2x3 standard. - - This class provides a framework for all derived IFC object models and - includes mechanisms for generic metadata management and establishing - relationships within the IFC data schema. - - Attributes inherited from IfcRootModel: - global_id (IfcGloballyUniqueIdField): Globally unique identifier. - name (IfcLabelField): The name of the object, allowing null. - description (IfcTextField): A textual description of the object, - allowing null. - owner_history (ForeignKey to IfcOwnerHistory): Ownership history of - the object. - - """ - - class Meta(IfcRootModel.Meta): - abstract = True # Ensuring this remains an abstract model - - def __str__(self): - """ - Provide a more informative string for representing this object - in the admin or logs. - """ - return self.name if self.name else _("Unnamed IFC Object") - - def get_absolute_url(self): - """ - Generate the absolute URL for an object instance (useful for admin - or detail views). - """ - return reverse('ifc_object_definition_detail', kwargs={'pk': self.pk}) diff --git a/src/django-bim/models/model_ifc_organization.py b/src/django-bim/models/model_ifc_organization.py deleted file mode 100644 index 16c3cc5..0000000 --- a/src/django-bim/models/model_ifc_organization.py +++ /dev/null @@ -1,125 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Organization Model Class -===================================== - -This model represents an organization as defined in the IFC 2x3 standard, -encompassing entities involved in construction projects. This model captures -crucial details such as the organization's name, unique identifier, roles -within construction projects, and their addresses. - -For more information, refer to: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcactorresource/lexical/ifcorganization.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from ..fields.model import ( - # IfcGloballyUniqueIdField, - IfcIdentifierField, - IfcLabelField, - IfcTextField, -) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcOrganizationModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcOrganizationModel(models.Model): - """ - IFC Organization Model Class - ============================ - - Represents an IfcOrganization as defined by IFC standards, detailing - organizations involved in various capacities within construction projects. - - Attributes: - identifier (IfcIdentifierField): A unique, optionally nullable - identifier for the organization. - name (IfcLabelField): The formal name of the organization, which can - also be left unspecified. - description (IfcTextField): Descriptive text about the organization's - function or structure. - roles (ManyToManyField): Links to defined roles the organization - fulfills in the construction process. - address (ManyToManyField): Links to addresses associated with the - organization, covering both physical and electronic forms of - contact. - """ - - identifier = IfcIdentifierField( - unique=True, - blank=True, - null=True, - verbose_name=_("Identifier"), - help_text=_("A unique identifier for the organization, such as a registration number.") # noqa E501 - ) - - name = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Organization Name"), - help_text=_("The official name of the organization.") - ) - - description = IfcTextField( - blank=True, - null=True, - verbose_name=_("Description"), - help_text=_("A brief description of the organization.") - ) - - roles = models.ManyToManyField( - 'IfcRoleModel', - verbose_name=_("Roles"), - help_text=_("Roles that the organization performs in the construction process."), # noqa E501 - blank=True - ) - - address = models.ManyToManyField( - 'IfcAddressModel', - verbose_name=_("Addresses"), - help_text=_("Postal and telecom addresses of an organization."), - blank=True - ) - - def __str__(self) -> str: - """ - Provides a human-readable representation of the organization, - defaulting to a placeholder if the name is unspecified. - """ - return self.name or _("Unnamed Organization") - - class Meta: - verbose_name = _("IFC Organization") - verbose_name_plural = _("IFC Organizations") - indexes = [ - models.Index(fields=['identifier'], name='idx_ifc_organization_identifier') # noqa E501 - ] diff --git a/src/django-bim/models/model_ifc_owner_history.py b/src/django-bim/models/model_ifc_owner_history.py deleted file mode 100644 index 90be26e..0000000 --- a/src/django-bim/models/model_ifc_owner_history.py +++ /dev/null @@ -1,148 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Owner History Model Class -====================================== - -This Django model tracks the ownership and modification history of IFC entities, -documenting who made changes, when these changes were made, and the nature of -these changes in line with the IFC 2x3 standard. - -For more information, refer to: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcutilityresource/lexical/ifcownerhistory.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ -# from django.contrib.auth.models import User - -# Import | Local Modules -from ..fields.model import ( - IfcTimestampField, -) -from ..enums import ( - IfcChangeActionEnum, - IfcStateEnum, -) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcOwnerHistoryModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcOwnerHistoryModel(models.Model): - """ - IFC Owner History Model Class - ============================= - - Model representing IFC Owner History. - - This model tracks modifications and ownership history related to IFC - entities, capturing who made changes, when, and what kind of change was - made, according to the IFC 2x3 standard. - - Attributes: - creation_user (ForeignKey): The user who initially created the entity. - modification_user (ForeignKey): The user who last modified the entity. - creation_date (IfcTimestampField): When the entity was created. - last_modified_date (IfcTimestampField): When the entity was last - modified. - change_action (CharField): Type of change made (modified, added, - deleted). - state (CharField): State of the entity at the last modification. - application (ForeignKey): Application used for the modification. - - """ - - creation_user = models.ForeignKey( - 'IfcPersonAndOrganizationModel', - on_delete=models.SET_NULL, - null=True, - blank=True, - related_name='created_ifc_entities', - verbose_name=_("Creation User"), - help_text=_("The user who initially created the entity.") - ) - - modification_user = models.ForeignKey( - 'IfcPersonAndOrganizationModel', - on_delete=models.SET_NULL, - null=True, - blank=True, - related_name='modified_ifc_entities', - verbose_name=_("Modification User"), - help_text=_("The user who last modified the entity.") - ) - - creation_date = IfcTimestampField( - auto_now_add=True, - verbose_name=_("Creation Date"), - help_text=_("The timestamp when the entity was created.") - ) - - last_modified_date = IfcTimestampField( - auto_now=True, - verbose_name=_("Last Modified Date"), - help_text=_("The timestamp when the entity was last modified.") - ) - - change_action = models.CharField( - max_length=50, - choices=IfcChangeActionEnum.choices(), - default=IfcChangeActionEnum.NOTDEFINED.name, - verbose_name=_("Change Action"), - help_text=_("The type of procedural action taken on the entity.") - ) - - state = models.CharField( - max_length=50, - choices=IfcStateEnum.choices(), - default=IfcStateEnum.NOTDEFINED.name, - verbose_name=_("State"), - help_text=_("The state of the entity at the last modification time.") - ) - - application = models.ForeignKey( - 'IfcApplicationModel', - on_delete=models.SET_NULL, - null=True, - blank=True, - related_name='used_in_modifications', - verbose_name=_("Application"), - help_text=_("The software application used to make the modification.") - ) - - def __str__(self): - creation_time = self.creation_date.strftime('%Y-%m-%d %H:%M:%S') - return f"{self.creation_user.username if self.creation_user else 'Unknown User'} on {creation_time}" # noqa E501 - - class Meta: - verbose_name = _("IFC Owner History") - verbose_name_plural = _("IFC Owner Histories") - indexes = [ - models.Index(fields=['creation_user'], name='idx_creation_user'), - models.Index(fields=['modification_user'], name='idx_modification_user'), # noqa E501 - ] diff --git a/src/django-bim/models/model_ifc_person.py b/src/django-bim/models/model_ifc_person.py deleted file mode 100644 index 89bbfab..0000000 --- a/src/django-bim/models/model_ifc_person.py +++ /dev/null @@ -1,166 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Person Model Class -=============================== - -This Django model encapsulates an individual's detailed information, -adhering to the IFC 2x3 standard for representing persons involved in -building projects. It covers personal identification, names, titles, -roles, and addresses. - -For more information, refer to: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcactorresource/lexical/ifcperson.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from ..fields.model import ( - # IfcGloballyUniqueIdField, - IfcIdentifierField, - IfcLabelField, - # IfcTextField, -) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcPersonModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcPersonModel(models.Model): - """ - IFC Person Model Class - ====================== - - Represents an IfcPerson as defined by the IFC 2x3 standard. - - This model handles personal details necessary for identifying individuals - participating in construction projects. It facilitates the management of - their roles and contact information within the project's ecosystem. - - Attributes: - identifier (IfcIdentifierField): A unique and potentially nullable - identifier for the person. - last_name (IfcLabelField): The individual's last name. - first_name (IfcLabelField): The individual's first name. - middle_names (IfcLabelField): Any middle names of the individual. - prefix_titles (IfcLabelField): Titles preceding the name, - e.g., Mr., Dr. - suffix_titles (IfcLabelField): Titles following the name, - e.g., Jr., PhD. - roles (ManyToManyField): Various roles the person may hold within - projects. - addresses (ManyToManyField): Linked addresses for the individual. - - """ - - identifier = IfcIdentifierField( - unique=True, - blank=True, - null=True, - verbose_name=_("Identification"), - help_text=_( - "A unique identifier for the person, such as an employee or membership number." # noqa E501 - ) - ) - - last_name = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Last Name"), - help_text=_("The individual's surname or family name.") - ) - - first_name = IfcLabelField( - blank=True, - null=True, - verbose_name=_("First Name"), - help_text=_("The individual's given name.") - ) - - middle_names = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Middle Names"), - help_text=_("Any middle names of the individual.") - ) - - prefix_titles = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Prefix Titles"), - help_text=_( - "Honorifics or formal titles preceding the individual's name." - ) - ) - - suffix_titles = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Suffix Titles"), - help_text=_( - "Qualifications or titles following the individual's name." - ) - ) - - roles = models.ManyToManyField( - 'IfcRoleModel', - verbose_name=_("Roles"), - help_text=_( - "The roles held by the individual within various projects." - ), - blank=True - ) - - addresses = models.ManyToManyField( - 'IfcAddressModel', - verbose_name=_("Addresses"), - help_text=_("The individual's contact addresses."), - blank=True - ) - - def __str__(self): - """ - Provide a human-readable string representation of the person. - """ - parts = [ - self.prefix_titles, - self.first_name, - self.middle_names, - self.last_name, - self.suffix_titles - ] - # Efficiently concatenate non-empty name parts - - return " ".join(part for part in parts if part) - - class Meta: - verbose_name = _("IfcPerson") - verbose_name_plural = _("IfcPersons") - # Default ordering by last name then first name for easier navigation - ordering = ['last_name', 'first_name'] diff --git a/src/django-bim/models/model_ifc_person_organization.py b/src/django-bim/models/model_ifc_person_organization.py deleted file mode 100644 index 92f778e..0000000 --- a/src/django-bim/models/model_ifc_person_organization.py +++ /dev/null @@ -1,102 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Person Organization Model Class -============================================ - - -For more information, refer to: - - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -# from ..fields.model import ( -# # IfcGloballyUniqueIdField, -# # IfcIdentifierField, -# # IfcLabelField, -# # IfcTextField, -# ) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcPersonAndOrganizationModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - - -class IfcPersonAndOrganizationModel(models.Model): - """ - IFC Person Organization Model Class - =================================== - - Model representing an IfcPersonAndOrganization as defined in the - IFC 2x3 standard. - - This model links individuals (IfcPerson) with organizations - (IfcOrganization), capturing their associations within the context of - building projects. - - Attributes: - person (ForeignKey): The individual involved in the organization. - organization (ForeignKey): The organization with which the person - is associated. - roles (ManyToManyField): Specific roles the person fulfills within - the organization. - """ - - person = models.ForeignKey( - 'IfcPersonModel', - on_delete=models.CASCADE, - verbose_name=_("Person"), - help_text=_("The individual associated with the organization.") - ) - - organization = models.ForeignKey( - 'IfcOrganizationModel', - on_delete=models.CASCADE, - verbose_name=_("Organization"), - help_text=_("The organization with which the person is associated.") - ) - - roles = models.ManyToManyField( - 'IfcRoleModel', - verbose_name=_("Roles"), - help_text=_( - "Specific roles the person fulfills within the organization." - ), - blank=True - ) - - def __str__(self): - return f"{self.person} at {self.organization}" - - class Meta: - verbose_name = _("IfcPerson and Organization") - verbose_name_plural = _("IfcPersons and Organizations") - # Ensures each combination of person and organization is unique - unique_together = ('person', 'organization') diff --git a/src/django-bim/models/model_ifc_product.py b/src/django-bim/models/model_ifc_product.py deleted file mode 100644 index 5ffe3de..0000000 --- a/src/django-bim/models/model_ifc_product.py +++ /dev/null @@ -1,18 +0,0 @@ -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifckernel/lexical/ifcproduct.htm - -from django.db import models - -class IfcProduct(models.Model): - # Attributes - name = models.CharField(max_length=255, blank=True, null=True) - description = models.TextField(blank=True, null=True) - object_placement = models.JSONField(blank=True, null=True, help_text="Spatial structure defining the object's placement in the project.") - representation = models.JSONField(blank=True, null=True, help_text="Physical or geometric representation of the product.") - - # Relationships - project = models.ForeignKey('IfcProject', on_delete=models.CASCADE, related_name='products', blank=True, null=True) - owner_history = models.ForeignKey('IfcOwnerHistory', on_delete=models.SET_NULL, null=True, blank=True, help_text="Information about the creation or modification of the product.") - - def __str__(self): - return self.name or "Unnamed Product" - diff --git a/src/django-bim/models/model_ifc_project.py b/src/django-bim/models/model_ifc_project.py deleted file mode 100644 index 93c4547..0000000 --- a/src/django-bim/models/model_ifc_project.py +++ /dev/null @@ -1,101 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Project Model Class -================================ - - -For detailed specifications, see: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifckernel/lexical/ifcproject.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.urls import reverse -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from .model_ifc_object_definition import IfcObjectDefinitionModel -from ..fields.model import ( - IfcLabelField, -) -from .ifc_unit_assignment import IfcUnitAssignment # Assume this handles the units used throughout the project -from .ifc_geometric_representation_context import IfcGeometricRepresentationContext # Assume this handles the geometric context - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcProjectModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcProjectModel(IfcObjectDefinitionModel): - """ - IFC Project Model Class - ======================= - - Model representing an IfcProject as defined in the IFC 2x3 standard. - - This model encapsulates the top-level project information in an IFC file, - providing a context for all project-related data, including project name, geographic - and geometric context, and units of measurement. - - Attributes: - long_name (models.CharField): A long and more descriptive name for the project. - phase (models.CharField): The current phase of the project (e.g., design, construction). - units_in_context (ForeignKey): The units used in this project. - representation_contexts (ManyToManyField): Contexts that define the geometric representation. - """ - - long_name = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Long Name"), - help_text=_("A longer and more descriptive name for the project.") - ) - - phase = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Phase"), - help_text=_("The current phase of the project such as planning, construction, or operation.") # noqa E501 - ) - - units_in_context = models.ForeignKey( - IfcUnitAssignment, - on_delete=models.RESTRICT, - verbose_name=_("Units In Context"), - help_text=_("The units used within this project.") - ) - - representation_contexts = models.ManyToManyField( - IfcGeometricRepresentationContext, - verbose_name=_("Geometric Representation Contexts"), - help_text=_("Geometric contexts that define how the geometries are represented in the project.") - ) - - class Meta: - verbose_name = _("IfcProject") - verbose_name_plural = _("IfcProjects") - - def __str__(self): - return f"{self.long_name} - Phase: {self.phase}" diff --git a/src/django-bim/models/model_ifc_representation.py b/src/django-bim/models/model_ifc_representation.py deleted file mode 100644 index 7a2cd74..0000000 --- a/src/django-bim/models/model_ifc_representation.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Representation Model Class -======================================= - - -For detailed specifications, see: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcrepresentationresource/lexical/ifcrepresentation.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.urls import reverse -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from .model_ifc_object_definition import IfcObjectDefinitionModel -from ..fields.model import ( - IfcLabelField, -) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcRepresentation", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcRepresentation(models.Model): - """ - """ - -class IfcRepresentation(models.Model): - """ - Model representing an IfcRepresentation as defined in the IFC 2x3 standard. - - This model defines the representation of a product in a specific representation context, - such as the geometry or spatial structure. - - Attributes: - context_of_items (ForeignKey): The context in which the items are represented. - representation_identifier (CharField): Identifier of the representation, e.g., 'Body', 'Axis'. - representation_type (CharField): The type of the representation, e.g., 'Mesh', 'Solid'. - items (ManyToManyField): Items that are part of this representation. - """ - - context_of_items = models.ForeignKey( - IfcRepresentationContext, - on_delete=models.CASCADE, - verbose_name=_("Context of Items"), - help_text=_("The context that defines how the representation items are interpreted.") - ) - - representation_identifier = models.CharField( - max_length=255, - blank=True, - null=True, - verbose_name=_("Representation Identifier"), - help_text=_("Identifier of the representation, such as 'Body' for geometric representation or 'Axis' for symbolic representation.") - ) - representation_type = models.CharField( - max_length=255, - blank=True, - null=True, - verbose_name=_("Representation Type"), - help_text=_("The type of the representation, such as 'Mesh', 'Solid', or 'Curve'.") - ) - items = models.ManyToManyField( - IfcRepresentationItem, - verbose_name=_("Items"), - help_text=_("Geometric or spatial items included in this representation.") - ) - - class Meta: - verbose_name = _("IfcRepresentation") - verbose_name_plural = _("IfcRepresentations") - - def __str__(self): - return f"{self.representation_identifier} - {self.representation_type}" diff --git a/src/django-bim/models/model_ifc_representation_context.py b/src/django-bim/models/model_ifc_representation_context.py deleted file mode 100644 index 0c3d90b..0000000 --- a/src/django-bim/models/model_ifc_representation_context.py +++ /dev/null @@ -1,102 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Representation Context Model Class -=============================================== - - -For detailed specifications, see: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcrepresentationresource/lexical/ifcrepresentationcontext.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from ..fields.model import ( - IfcLabelField, -) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcRepresentationContextModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcRepresentationContextModel(models.Model): - """ - IFC Representation Context Model Class - ====================================== - - Model representing an IfcRepresentationContext as defined in the - IFC 2x3 standard. - - This model provides a context for all representations, detailing the - coordinate system and dimensionality, ensuring that the geometric or - spatial representations are correctly interpreted according to the - project's standards. - - Attributes: - context_identifier (models.CharField): Identifies the context type - (e.g., Plan, Elevation). - context_type (models.CharField): Describes the context further - (e.g., 2D, 3D). - coordinate_space_dimension (models.IntegerField): The dimensionality - of the coordinate system (typically 2 or 3). - - """ - - context_identifier = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Context Identifier"), - help_text=_( - "Identifies the context type, which could be used to differentiate between different graphical or spatial contexts." # noqa E501 - ) - ) - - context_type = IfcLabelField( - blank=True, - null=True, - verbose_name=_("Context Type"), - help_text=_( - "Further describes the type of representation context, such as 'Model' or 'Plan'." # noqa E501 - ) - ) - - coordinate_space_dimension = models.IntegerField( - default=3, - verbose_name=_("Coordinate Space Dimension"), - help_text=_( - "The dimensionality of the coordinate system used in this context, typically 2 or 3." # noqa E501 - ) - ) - - class Meta: - verbose_name = _("IFC Representation Context") - verbose_name_plural = _("IFC Representation Contexts") - - def __str__(self): - return f"{self.context_identifier} ({self.context_type})" diff --git a/src/django-bim/models/model_ifc_representation_item.py b/src/django-bim/models/model_ifc_representation_item.py deleted file mode 100644 index 39de377..0000000 --- a/src/django-bim/models/model_ifc_representation_item.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Representation Item Model Class -============================================ - - -For detailed specifications, see: -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifcgeometryresource/lexical/ifcrepresentationitem.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcRepresentationItemModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcRepresentationItemModel(models.Model): - """ - IFC Representation Item Model Class - =================================== - - Abstract Django model representing an IfcRepresentationItem, which is - defined in the IFC 2x3 standard as the abstract supertype of all geometric - and topological representation items within a representation. - - This model is abstract and should be inherited by specific models that - implement detailed geometric or topological structures. - - Attributes: - name (CharField): Optional name of the representation item. - - """ - - name = models.CharField( - max_length=255, - blank=True, - null=True, - verbose_name=_("Name"), - help_text=_("Optional name of the representation item.") - ) - - class Meta: - abstract = True # Makes this model an abstract base class - - def __str__(self): - return self.name if self.name else super().__str__() diff --git a/src/django-bim/models/model_ifc_root.py b/src/django-bim/models/model_ifc_root.py deleted file mode 100644 index 824c2f2..0000000 --- a/src/django-bim/models/model_ifc_root.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- - - -# ============================================================================= -# Docstring -# ============================================================================= - -""" -Provides IFC Root Model Class -============================= - -This module defines an abstract base class for all IFC models, ensuring -consistency and reusability across different IFC entities within the -Django application. - -Definition from buildingSMART: -The IfcRoot is the most abstract and root class for all IFC entity definitions -that roots in the kernel or in subsequent layers of the IFC object model. -It is therefore the common supertype all all IFC entities, beside those -defined in an IFC resource schema. All entities that are subtypes of IfcRoot -can be used independently, whereas resource schema entities, that are not -subtypes of IfcRoot, are not supposed to be independent entities. - -https://standards.buildingsmart.org/IFC/RELEASE/IFC2x3/TC1/HTML/ifckernel/lexical/ifcroot.htm - -""" # noqa E501 - - -# ============================================================================= -# Import -# ============================================================================= - -# Import | Standard Library -# from uuid import uuid4 -# from typing import Any, Dict, List - -# Import | Libraries -from django.db import models -from django.urls import reverse -from django.utils.translation import gettext_lazy as _ - -# Import | Local Modules -from ..fields.model import ( - IfcGloballyUniqueIdField, - IfcLabelField, - IfcTextField, -) - - -# ============================================================================= -# Variables -# ============================================================================= - -__all__ = ["IfcRootModel", ] - - -# ============================================================================= -# Classes -# ============================================================================= - -class IfcRootModel(models.Model): - """ - IFC Root Model Class - ==================== - - This abstract base class provides common fields and functionality for all - IFC models, such as a unique global identifier and metadata regarding - the creation and modification history of the entity. - - Attributes: - global_id (IfcGloballyUniqueIdField): A unique identifier for the - entity within the IFC model. - name (IfcLabelField): The name of the IFC entity. - description (IfcTextField): A description of the IFC entity. - owner_history (ForeignKey): A link to the ownership history of the - entity. - - Note: - This class is not meant to be instantiated directly. - - """ - - global_id = IfcGloballyUniqueIdField( - help_text=_("Globally unique identifier in the IFC model.") - ) - - name = IfcLabelField( - blank=True, - null=True, - verbose_name=_("name"), - help_text=_("Name of the IFC entity.") - ) - - description = IfcTextField( - blank=True, - null=True, - verbose_name=_("description"), - help_text=_("Description of the IFC entity.") - ) - - owner_history = models.ForeignKey( - 'IfcOwnerHistory', - on_delete=models.SET_NULL, - null=True, - blank=True, - related_name='owned_entities', - verbose_name=_("owner history"), - help_text=_("Ownership history of the object.") - ) - - class Meta: - abstract = True - verbose_name = _("IFC Root Model") - verbose_name_plural = _("IFC Root Models") - - def __str__(self): - return self.name or _("Unnamed IFC Entity") - - def get_absolute_url(self): - return reverse('ifc_entity_detail', kwargs={'pk': self.pk})