2021-04-21 16:47:18 +00:00
|
|
|
"""
|
|
|
|
This module defines the Authorization database class.
|
|
|
|
"""
|
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
from ..base import ext
|
2021-04-21 16:47:18 +00:00
|
|
|
|
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
class Authorization(ext.Model):
|
|
|
|
rid = ext.Column(ext.Integer, ext.ForeignKey("repository.id", ondelete="CASCADE"), primary_key=True)
|
|
|
|
email = ext.Column(ext.String, ext.ForeignKey("user.email", ondelete="CASCADE"), primary_key=True)
|
2021-04-21 16:47:18 +00:00
|
|
|
# Relationships
|
2021-05-07 17:46:14 +00:00
|
|
|
repository = ext.relationship("Repository", back_populates="authorizations")
|
2021-05-20 11:48:15 +00:00
|
|
|
user = ext.relationship("User", back_populates="authorizations")
|
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
return {
|
|
|
|
"rid": self.rid,
|
|
|
|
"email": self.email,
|
|
|
|
}
|