diff --git a/services/core-api/app/api/projects/major_mine_application/models/major_mine_application_document_xref.py b/services/core-api/app/api/projects/major_mine_application/models/major_mine_application_document_xref.py index 10a3fa1ac6..529f0e65e6 100644 --- a/services/core-api/app/api/projects/major_mine_application/models/major_mine_application_document_xref.py +++ b/services/core-api/app/api/projects/major_mine_application/models/major_mine_application_document_xref.py @@ -1,22 +1,14 @@ from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.schema import FetchedValue -from sqlalchemy.ext.associationproxy import association_proxy -from app.api.utils.models_mixins import Base -from app.api.mines.documents.models.mine_document import MineDocument +from app.api.utils.models_mixins import Base, DocumentXrefMixin from app.extensions import db - -class MajorMineApplicationDocumentXref(Base): +class MajorMineApplicationDocumentXref(Base, DocumentXrefMixin): __tablename__ = 'major_mine_application_document_xref' major_mine_application_document_xref_guid = db.Column( UUID(as_uuid=True), primary_key=True, server_default=FetchedValue()) - mine_document_guid = db.Column( - UUID(as_uuid=True), - db.ForeignKey('mine_document.mine_document_guid'), - nullable=False, - unique=True) major_mine_application_id = db.Column( db.Integer, db.ForeignKey('major_mine_application.major_mine_application_id'), @@ -27,20 +19,5 @@ class MajorMineApplicationDocumentXref(Base): 'major_mine_application_document_type.major_mine_application_document_type_code'), nullable=False) - mine_document = db.relationship('MineDocument', lazy='select', overlaps='major_mine_application_document_xref') - mine_guid = association_proxy('mine_document', 'mine_guid') - document_manager_guid = association_proxy('mine_document', 'document_manager_guid') - document_name = association_proxy('mine_document', 'document_name') - upload_date = association_proxy('mine_document', 'upload_date') - create_user = association_proxy('mine_document', 'create_user') - versions = association_proxy('mine_document', 'versions') - update_timestamp = association_proxy('mine_document', 'update_timestamp') - mine_document_bundle_id = association_proxy('mine_document', 'mine_document_bundle_id') - def __repr__(self): - return f'{self.__class__.__name__} {self.major_mine_application_document_xref_guid}' - - @classmethod - def find_by_mine_document_guid(cls, mine_document_guid): - return cls.query.filter_by(mine_document_guid=mine_document_guid).filter( - MineDocument.deleted_ind == False).one_or_none() + return f'{self.__class__.__name__} {self.major_mine_application_document_xref_guid}' \ No newline at end of file diff --git a/services/core-api/app/api/utils/models_mixins.py b/services/core-api/app/api/utils/models_mixins.py index cf4607a192..8d6f32cfe3 100644 --- a/services/core-api/app/api/utils/models_mixins.py +++ b/services/core-api/app/api/utils/models_mixins.py @@ -478,6 +478,33 @@ class AuditMixin(object): update_timestamp = db.Column( db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow) +class DocumentXrefMixin(object): + @declared_attr + def mine_document(cls): + return db.relationship('MineDocument', lazy='select') + + @declared_attr + def mine_document_guid(cls): + return db.Column( + UUID(as_uuid=True), + db.ForeignKey('mine_document.mine_document_guid'), + nullable=False, + unique=True) + + mine_guid = association_proxy('mine_document', 'mine_guid') + document_manager_guid = association_proxy('mine_document', 'document_manager_guid') + document_name = association_proxy('mine_document', 'document_name') + upload_date = association_proxy('mine_document', 'upload_date') + create_user = association_proxy('mine_document', 'create_user') + versions = association_proxy('mine_document', 'versions') + update_timestamp = association_proxy('mine_document', 'update_timestamp') + mine_document_bundle_id = association_proxy('mine_document', 'mine_document_bundle_id') + deleted_ind = association_proxy('mine_document', 'deleted_ind') + + @classmethod + def find_by_mine_document_guid(cls, mine_document_guid): + return cls.query.filter_by(mine_document_guid=mine_document_guid).filter( # type: ignore + cls.deleted_ind == False).one_or_none() class SoftDeleteMixin(object): deleted_ind = db.Column(db.Boolean, nullable=False, server_default=FetchedValue()) diff --git a/services/core-web/src/styles/components/PermitConditions.scss b/services/core-web/src/styles/components/PermitConditions.scss index 68f8e73974..bcb1c2cca7 100644 --- a/services/core-web/src/styles/components/PermitConditions.scss +++ b/services/core-web/src/styles/components/PermitConditions.scss @@ -8,7 +8,7 @@ div.condition-layer { .condition-content { &.editable:hover { cursor: pointer; - background-color: lightgrey; + background-color: #F4F0F0; } .view-item {