From d52dcb0aa4032453d0fd6b08c9391fb61b67c56b Mon Sep 17 00:00:00 2001 From: Arie Peterson <arie@greenhost.nl> Date: Thu, 16 Mar 2023 16:06:50 +0100 Subject: [PATCH] Implement app.oauthclients using relationship --- backend/areas/apps/models.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/backend/areas/apps/models.py b/backend/areas/apps/models.py index 2db26ef1..73fd1550 100644 --- a/backend/areas/apps/models.py +++ b/backend/areas/apps/models.py @@ -29,6 +29,7 @@ class App(db.Model): # The URL is only stored in the DB for external applications; otherwise the # URL is stored in a configmap (see get_url) url = db.Column(String(length=128), unique=False) + oauthclients = relationship("OAuthClientApp", back_populates="app") def __init__(self, slug, name, external=False, url=None): self.slug = slug @@ -177,15 +178,6 @@ class App(db.Model): app_id=self.id ).all() - @property - def oauthclients(self): - """ - All oauth clients related to this app - """ - return OAuthClientApp.query.filter_by( - app_id=self.id - ).all() - @property def kustomization(self): """Returns the kustomization object for this app""" @@ -329,7 +321,7 @@ class OAuthClientApp(db.Model): # pylint: disable=too-few-public-methods oauthclient_id = db.Column(String(length=64), primary_key=True) app_id = db.Column(Integer, ForeignKey("app.id")) - app = relationship("App") + app = relationship("App", back_populates="oauthclients") def __repr__(self): return (f"oauthclient_id: {self.oauthclient_id}, app_id: {self.app_id}," -- GitLab