-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 maganing organization table (#53)
* feat: added managing organization table * fix: api for managing org * fix: api for managing org * fix: test for managing org * fix: model classes of managing organization * style: format
- Loading branch information
Showing
7 changed files
with
135 additions
and
94 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from ..db import db | ||
|
||
|
||
class DatasetManagingOrganization(db.Model): # type: ignore | ||
def __init__(self, dataset): | ||
self.dataset = dataset | ||
self.name = "" | ||
self.identifier = "" | ||
self.identifier_scheme = "" | ||
self.identifier_scheme_uri = "" | ||
|
||
__tablename__ = "dataset_managing_organization" | ||
|
||
name = db.Column(db.String, nullable=False) | ||
identifier = db.Column(db.String, nullable=False) | ||
identifier_scheme = db.Column(db.String, nullable=False) | ||
identifier_scheme_uri = db.Column(db.String, nullable=False) | ||
|
||
dataset_id = db.Column( | ||
db.CHAR(36), db.ForeignKey("dataset.id"), primary_key=True, nullable=False | ||
) | ||
dataset = db.relationship("Dataset", back_populates="dataset_managing_organization") | ||
|
||
def to_dict(self): | ||
return { | ||
"name": self.name, | ||
"identifier": self.identifier, | ||
"identifier_scheme": self.identifier_scheme, | ||
"identifier_scheme_uri": self.identifier_scheme_uri, | ||
} | ||
|
||
def to_dict_metadata(self): | ||
return { | ||
"name": self.name, | ||
"identifier": self.identifier, | ||
} | ||
|
||
@staticmethod | ||
def from_data(dataset, data: dict): | ||
dataset_other = DatasetManagingOrganization(dataset) | ||
dataset_other.update(data) | ||
return dataset_other | ||
|
||
def update(self, data: dict): | ||
if "name" in data: | ||
self.name = data["name"] | ||
if "identifier" in data: | ||
self.identifier = data["identifier"] | ||
if "identifier_scheme" in data: | ||
self.identifier_scheme = data["identifier_scheme"] | ||
if "identifier_scheme_uri" in data: | ||
self.identifier_scheme_uri = data["identifier_scheme_uri"] |
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
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