diff --git a/backend/areas/apps/models.py b/backend/areas/apps/models.py index 069c73751643f42af0619e65c7d6425d4802138d..972d7dd3702cd8c86e3fda123fff070cb1034413 100644 --- a/backend/areas/apps/models.py +++ b/backend/areas/apps/models.py @@ -113,6 +113,10 @@ class App(db.Model): # Delete all roles first for role in self.roles: db.session.delete(role) + + # Delete all related oathclient entries + for auth in self.oauthclients: + db.session.delete(auth) db.session.commit() db.session.delete(self) @@ -173,6 +177,15 @@ 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"""