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

@ -127,9 +127,7 @@ async def make_single_context(request: Request,
context["comments"] = pkgbase.comments
context["is_maintainer"] = (request.user.is_authenticated()
and request.user.ID == pkgbase.MaintainerUID)
context["notified"] = request.user.package_notifications.filter(
PackageNotification.PackageBaseID == pkgbase.ID
).scalar()
context["notified"] = request.user.notified(pkgbase)
context["out_of_date"] = bool(pkgbase.OutOfDateTS)