Skip to content

Commit

Permalink
issue with spatial docs + major mine app document xref, also, a small…
Browse files Browse the repository at this point in the history
… ask from Denise
  • Loading branch information
taraepp committed Dec 18, 2024
1 parent 5aff4a2 commit 47e83e7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -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'),
Expand All @@ -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}'
27 changes: 27 additions & 0 deletions services/core-api/app/api/utils/models_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ div.condition-layer {
.condition-content {
&.editable:hover {
cursor: pointer;
background-color: lightgrey;
background-color: #F4F0F0;
}

.view-item {
Expand Down

0 comments on commit 47e83e7

Please sign in to comment.