Skip to content
Snippets Groups Projects
Commit 2650b98e authored by Mart van Santen's avatar Mart van Santen
Browse files

Merge branch '129-allow-deletion-of-apps' into 'main'

Resolve "Allow deletion of apps"

Closes #129

See merge request !103
parents ae19bbb1 d52dcb0a
No related branches found
No related tags found
1 merge request!103Resolve "Allow deletion of apps"
Pipeline #38587 passed with stages
in 3 minutes and 41 seconds
...@@ -29,6 +29,7 @@ class App(db.Model): ...@@ -29,6 +29,7 @@ class App(db.Model):
# The URL is only stored in the DB for external applications; otherwise the # The URL is only stored in the DB for external applications; otherwise the
# URL is stored in a configmap (see get_url) # URL is stored in a configmap (see get_url)
url = db.Column(String(length=128), unique=False) url = db.Column(String(length=128), unique=False)
oauthclients = relationship("OAuthClientApp", back_populates="app")
def __init__(self, slug, name, external=False, url=None): def __init__(self, slug, name, external=False, url=None):
self.slug = slug self.slug = slug
...@@ -113,6 +114,10 @@ class App(db.Model): ...@@ -113,6 +114,10 @@ class App(db.Model):
# Delete all roles first # Delete all roles first
for role in self.roles: for role in self.roles:
db.session.delete(role) db.session.delete(role)
# Delete all related oauthclients
for auth in self.oauthclients:
db.session.delete(auth)
db.session.commit() db.session.commit()
db.session.delete(self) db.session.delete(self)
...@@ -316,7 +321,7 @@ class OAuthClientApp(db.Model): # pylint: disable=too-few-public-methods ...@@ -316,7 +321,7 @@ class OAuthClientApp(db.Model): # pylint: disable=too-few-public-methods
oauthclient_id = db.Column(String(length=64), primary_key=True) oauthclient_id = db.Column(String(length=64), primary_key=True)
app_id = db.Column(Integer, ForeignKey("app.id")) app_id = db.Column(Integer, ForeignKey("app.id"))
app = relationship("App") app = relationship("App", back_populates="oauthclients")
def __repr__(self): def __repr__(self):
return (f"oauthclient_id: {self.oauthclient_id}, app_id: {self.app_id}," return (f"oauthclient_id: {self.oauthclient_id}, app_id: {self.app_id},"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment