generated from bcgov/EPIC.scaffold
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from dinesh-aot/COMP-275
Ispection requirements model
- Loading branch information
Showing
14 changed files
with
1,337 additions
and
30 deletions.
There are no files selected for viewing
699 changes: 699 additions & 0 deletions
699
compliance-api/migrations/versions/50caf15789a6_inspection_requirements.py
Large diffs are not rendered by default.
Oops, something went wrong.
329 changes: 329 additions & 0 deletions
329
compliance-api/migrations/versions/a684c47ac3e8_document_types.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
compliance-api/src/compliance_api/models/compliance_finding.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Compliance finding model.""" | ||
|
||
from enum import Enum | ||
|
||
from .option_base_model import OptionModel | ||
|
||
|
||
class ComplianceFindingOptionEnum(Enum): | ||
"""ComplianceFindingEnum.""" | ||
|
||
IN = 1 | ||
OUT = 2 | ||
NOT_DETERMINED = 3 | ||
|
||
|
||
class ComplianceFindingOption(OptionModel): | ||
"""ComplianceFinding.""" | ||
|
||
__tablename__ = "compliance_finding_options" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""DocumentType Model.""" | ||
|
||
from .option_base_model import OptionModel | ||
|
||
|
||
class DocumentType(OptionModel): | ||
"""DocumentType Model.""" | ||
|
||
__tablename__ = "document_types" |
24 changes: 24 additions & 0 deletions
24
compliance-api/src/compliance_api/models/enforcement_action.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""EnforcementActionModel.""" | ||
from enum import Enum | ||
|
||
from .option_base_model import OptionModel | ||
|
||
|
||
class EnforcementActionOptionEnum(Enum): | ||
"""EnforcementActionOptionEnum.""" | ||
|
||
TO_BE_DETERMINED = 1 | ||
NOT_APPLICABLE = 2 | ||
NOTICE_OF_NON_COMPLIANCE = 3 | ||
WARNING_LETTER = 4 | ||
ORDER = 5 | ||
REFERRAL_TO_ADMINISTRATIVE_PENALTY = 6 | ||
REFERRAL_TO_ANOTHER_AGENCY = 7 | ||
VIOLATION_TICKET = 8 | ||
PROSECUTION_RECOMMENTDATAION = 10 | ||
|
||
|
||
class EnforcementActionOption(OptionModel): | ||
"""Requirement source.""" | ||
|
||
__tablename__ = "enforcement_action_options" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
compliance-api/src/compliance_api/models/inspection/inspection_req_detail_doc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""InspectionRequirementDetailDocument Model.""" | ||
|
||
from sqlalchemy import Column, ForeignKey, Integer, String | ||
from sqlalchemy.orm import relationship | ||
|
||
from ..base_model import BaseModelVersioned | ||
|
||
|
||
class InspectionReqDetailDocument(BaseModelVersioned): | ||
"""InspectionReqDetailDocument Model.""" | ||
|
||
__tablename__ = "inspection_req_detail_documents" | ||
|
||
id = Column( | ||
Integer, | ||
primary_key=True, | ||
autoincrement=True, | ||
comment="The unique identifier", | ||
) | ||
req_detail_id = Column( | ||
Integer, | ||
ForeignKey( | ||
"inspection_req_source_details.id", | ||
name="inspection_req_detail_documents_req_detail_id_fkey", | ||
), | ||
comment="The unique identifier of the requirement detail", | ||
nullable=False, | ||
) | ||
document_type_id = Column( | ||
Integer, | ||
ForeignKey( | ||
"document_types.id", name="inspection_req_detail_documents_document_id_fkey" | ||
), | ||
comment="The unique identifier of the document type", | ||
nullable=False, | ||
) | ||
document_title = Column(String, nullable=False, comment="The title of the document") | ||
section_number = Column( | ||
String, | ||
nullable=True, | ||
comment="The highlighted section number in the uploaded document", | ||
) | ||
section_title = Column( | ||
String, | ||
nullable=True, | ||
comment="The title of the section associated with the document", | ||
) | ||
description = Column( | ||
String, nullable=True, comment="Additional description of the document" | ||
) | ||
requirement_source_detail = relationship( | ||
"InspectionReqSourceDetail", foreign_keys=[req_detail_id], lazy="select" | ||
) | ||
document_type = relationship( | ||
"DocumentType", foreign_keys=[document_type_id], lazy="select" | ||
) |
64 changes: 64 additions & 0 deletions
64
compliance-api/src/compliance_api/models/inspection/inspection_req_source_detail.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"""InspectionRequirementSourceDetail Model.""" | ||
|
||
from sqlalchemy import Column, ForeignKey, Integer, String | ||
from sqlalchemy.orm import relationship | ||
|
||
from ..base_model import BaseModelVersioned | ||
|
||
|
||
class InspectionReqSourceDetail(BaseModelVersioned): | ||
"""InspectionReqSourceDetail.""" | ||
|
||
__tablename__ = "inspection_req_source_details" | ||
id = Column( | ||
Integer, | ||
primary_key=True, | ||
autoincrement=True, | ||
comment="The unique identifier", | ||
) | ||
requirement_id = Column( | ||
Integer, | ||
ForeignKey( | ||
"inspection_requirements.id", name="inspection_req_detail_req_id_fkey" | ||
), | ||
nullable=False, | ||
comment="The requirement id", | ||
) | ||
requirement_source_id = Column( | ||
Integer, | ||
ForeignKey( | ||
"requirement_sources.id", name="inspection_req_detail_source_id_fkey" | ||
), | ||
nullable=False, | ||
comment="The source of the requirement", | ||
) | ||
section_number = Column( | ||
String, | ||
nullable=True, | ||
comment="The optional section number associated with requirement sources" | ||
"(Act (2018), Schedule A, Compliance Agreement, Act (2002))", | ||
) | ||
condition_number = Column( | ||
String, | ||
nullable=True, | ||
comment="The optional condition number associated with rquirement sources(Schedule B, EAC Certificate)", | ||
) | ||
amendment_number = Column( | ||
String, | ||
nullable=True, | ||
comment="The optional amendment number if the requirement source is EAC Amendment", | ||
) | ||
title = Column( | ||
String, nullable=True, comment="The title of the requirement source detail" | ||
) | ||
description = Column( | ||
String, | ||
nullable=True, | ||
comment="The description of the requirement source detail", | ||
) | ||
inspection_requirement = relationship( | ||
"InspectionRequirement", foreign_keys=[requirement_id], lazy="select" | ||
) | ||
requirement_source = relationship( | ||
"RequirementSource", foreign_keys=[requirement_source_id], lazy="joined" | ||
) |
60 changes: 60 additions & 0 deletions
60
compliance-api/src/compliance_api/models/inspection/inspection_requirement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"""InspectionRequirement Model.""" | ||
|
||
from sqlalchemy import Column, ForeignKey, Integer, String | ||
from sqlalchemy.orm import relationship | ||
|
||
from ..base_model import BaseModelVersioned | ||
|
||
|
||
class InspectionRequirement(BaseModelVersioned): | ||
"""InspectionRequirementModel.""" | ||
|
||
__tablename__ = "inspection_requirements" | ||
id = Column( | ||
Integer, | ||
primary_key=True, | ||
autoincrement=True, | ||
comment="The unique identifier", | ||
) | ||
inspection_id = Column( | ||
Integer, | ||
ForeignKey("inspections.id", name="inspection_requirements_inspection_id_fkey"), | ||
nullable=False, | ||
comment="The unique identifier of the inspection", | ||
) | ||
summary = Column(String, nullable=False, comment="The summary of the requirement") | ||
topic_id = Column( | ||
Integer, | ||
ForeignKey("topics.id", name="inspection_requirements_topic_id_fkey"), | ||
nullable=False, | ||
comment="The topic of the requirement", | ||
) | ||
enforcement_action_id = Column( | ||
Integer, | ||
ForeignKey( | ||
"enforcement_action_options.id", | ||
name="insepction_requirements_enforcement_action_fkey", | ||
), | ||
nullable=False, | ||
comment="The enforcement action taken on the requirement", | ||
) | ||
compliance_finding_id = Column( | ||
Integer, | ||
ForeignKey( | ||
"compliance_finding_options.id", | ||
name="inspection_req_compliance_finding_fkey", | ||
), | ||
nullable=False, | ||
comment="Compliance finding of the requirement", | ||
) | ||
findings = Column( | ||
String, comment="The findings of the requirement" | ||
) | ||
inspection = relationship("Inspection", foreign_keys=[inspection_id], lazy="select") | ||
topic = relationship("Topic", foreign_keys=[topic_id], lazy="joined") | ||
enforcement_action = relationship( | ||
"EnforcementActionOption", foreign_keys=[enforcement_action_id], lazy="joined" | ||
) | ||
compliance_finding = relationship( | ||
"ComplianceFindingOption", foreign_keys=[compliance_finding_id], lazy="joined" | ||
) |
30 changes: 30 additions & 0 deletions
30
compliance-api/src/compliance_api/models/req_source_document_map.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""RequirementSourceDocumentMap Model.""" | ||
|
||
from sqlalchemy import Column, ForeignKey, Integer | ||
from sqlalchemy.orm import relationship | ||
|
||
from .base_model import BaseModelVersioned | ||
|
||
|
||
class RequirementSourceDocumentMap(BaseModelVersioned): | ||
"""RequirementSourceDocumentMap Model.""" | ||
|
||
__tablename__ = "requirement_source_document_maps" | ||
|
||
id = Column( | ||
Integer, primary_key=True, autoincrement=True, comment="The unique identifier" | ||
) | ||
requirement_source_id = Column( | ||
Integer, | ||
ForeignKey("requirement_sources.id", name="req_source_map_req_source_id_fkey"), | ||
) | ||
document_type_id = Column( | ||
Integer, | ||
ForeignKey("document_types.id", name="req_doc_type_id_document_types_id_fkey"), | ||
) | ||
requirement_source = relationship( | ||
"RequirementSource", foreign_keys=[requirement_source_id], lazy="joined" | ||
) | ||
document_type = relationship( | ||
"DocumentType", foreign_keys=[document_type_id], lazy="joined" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.