1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 14:34:19 +00:00

🧹 Reformat code

This commit is contained in:
Stefano Pigozzi 2021-04-29 04:02:08 +02:00
parent a481a4e087
commit 0b8f9a6818
Signed by untrusted user who does not match committer: steffo
GPG key ID: 6965406171929D01

View file

@ -1,5 +1,5 @@
"""
This module defines the Repository database class.
This module defines the :class:`.Repository` database class.
"""
from ..base import Base
@ -7,13 +7,17 @@ from ..base import Base
class Repository(Base.Model):
__tablename__ = "repository"
# Columns
id = Base.Column(Base.Integer, primary_key=True)
name = Base.Column(Base.String, nullable=False)
start = Base.Column(Base.DateTime, nullable=True)
end = Base.Column(Base.DateTime, nullable=True)
isActive = Base.Column(Base.Boolean, nullable=False, default=False)
# Foreign Keys
owner_id = Base.Column(Base.String, Base.ForeignKey("user.email"), nullable=False)
# Relationships
owner = Base.relationship("User", back_populates="owner_of")
authorizations = Base.relationship("Authorization", back_populates="repository")
@ -22,6 +26,11 @@ class Repository(Base.Model):
uses = Base.relationship("Uses", back_populates="repository")
def to_json(self):
return {"id": self.id, "name": self.name, "start": (self.start.isoformat() if self.start else None),
"isActive": self.isActive, "end": (self.end.isoformat() if self.end else None),
"owner": self.owner.to_json()}
return {
"id": self.id,
"name": self.name,
"start": self.start.isoformat() if self.start else None,
"isActive": self.isActive,
"end": self.end.isoformat() if self.end else None,
"owner": self.owner.to_json()
}