From 12056a6de2bbf9a0d635b1dcbb677b9b143c2a98 Mon Sep 17 00:00:00 2001 From: Bhavin Katabathuni Date: Fri, 22 Dec 2023 11:34:38 +0100 Subject: [PATCH] Foreign key of package with molecule relation table --- .idea/workspace.xml | 14 +++++++++++--- ckanext/rdkit_visuals/models/molecule_rel.py | 16 ++-------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3d61e23..0a19c11 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,7 @@ - + @@ -262,7 +262,14 @@ @@ -292,6 +299,7 @@ - \ No newline at end of file diff --git a/ckanext/rdkit_visuals/models/molecule_rel.py b/ckanext/rdkit_visuals/models/molecule_rel.py index 036242c..50c86fb 100644 --- a/ckanext/rdkit_visuals/models/molecule_rel.py +++ b/ckanext/rdkit_visuals/models/molecule_rel.py @@ -32,7 +32,6 @@ class MolecularRelationData(Base): molecules_id = Column(u'molecules_id', _types.Integer, ForeignKey(u'molecules.id'), nullable=False) package_id = Column(u'package_id', _types.UnicodeText, ForeignKey(_package.Package.id), nullable=False) - @classmethod def create(cls, molecules_id, package_id): """ @@ -134,16 +133,5 @@ def get_molecule_data_by_package_id(cls, package_id): return molecule_data -package = relationship(_package.Package, secondary= MolecularRelationData, backref="molecular_relation_data") - -#meta.registry.map_imperatively(MolecularRelationData, MolecularRelationData.__table__) - -#meta.mapper(# -# MolecularRelationData, -# 'molecule_rel_data', -# properties={ -# u"package": orm.relation( -# Package, backref=orm.backref(u"molecule_rel_data", cascade=u"all, delete, delete-orphan") -# ) -# }, -#) \ No newline at end of file +# relationship to build between molecules and packages +package = relationship(_package.Package, secondary= MolecularRelationData, back_populates="molecular_relation_data", cascade="all, delete")