change(FastAPI): allow User.notified to accept a Package OR PackageBase

In addition, shorten the `package_notifications` relationship to
`notifications`.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-09-27 13:49:33 -07:00
parent 4abbf9a917
commit f849e8b696
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
4 changed files with 23 additions and 9 deletions

View file

@ -15,7 +15,7 @@ class PackageNotification(Base):
Integer, ForeignKey("Users.ID", ondelete="CASCADE"),
nullable=False)
User = relationship(
"User", backref=backref("package_notifications", lazy="dynamic"),
"User", backref=backref("notifications", lazy="dynamic"),
foreign_keys=[UserID])
PackageBaseID = Column(
@ -23,7 +23,7 @@ class PackageNotification(Base):
nullable=False)
PackageBase = relationship(
"PackageBase",
backref=backref("package_notifications", lazy="dynamic"),
backref=backref("notifications", lazy="dynamic"),
foreign_keys=[PackageBaseID])
__mapper_args__ = {"primary_key": [UserID, PackageBaseID]}