delete now uses orphan cascade deletion instead of manual delete
This commit is contained in:
parent
120931dc4c
commit
722db5feae
@ -14,9 +14,9 @@ class User(UserMixin, db.Model):
|
|||||||
email = db.Column(db.String(120), index=True, unique=True)
|
email = db.Column(db.String(120), index=True, unique=True)
|
||||||
profile_pic = db.Column(db.String(256))
|
profile_pic = db.Column(db.String(256))
|
||||||
password_hash = db.Column(db.String(128))
|
password_hash = db.Column(db.String(128))
|
||||||
google_token = db.relationship('GoogleToken', uselist=False, backref = 'user')
|
google_token = db.relationship('GoogleToken', uselist=False, backref = 'user', cascade="all, delete-orphan")
|
||||||
calendars = db.relationship('Calendar', backref='user', lazy=True)
|
calendars = db.relationship('Calendar', backref='user', lazy=True, cascade="all, delete-orphan")
|
||||||
devices = db.relationship('Device', backref='user')
|
devices = db.relationship('Device', backref='user', cascade="all, delete-orphan")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<User {}>'.format(self.username)
|
return '<User {}>'.format(self.username)
|
||||||
|
@ -107,13 +107,13 @@ def deleteAccount():
|
|||||||
return redirect(url_for('account'))
|
return redirect(url_for('account'))
|
||||||
# TODO fix google delete account
|
# TODO fix google delete account
|
||||||
google.deleteAccount(current_user)
|
google.deleteAccount(current_user)
|
||||||
|
'''
|
||||||
for cal in current_user.calendars:
|
for cal in current_user.calendars:
|
||||||
db.session.delete(cal)
|
db.session.delete(cal)
|
||||||
for dev in current_user.devices:
|
for dev in current_user.devices:
|
||||||
db.session.delete(dev)
|
db.session.delete(dev)
|
||||||
|
|
||||||
db.session.delete(current_user.google_token)
|
db.session.delete(current_user.google_token)
|
||||||
|
'''
|
||||||
db.session.delete(current_user)
|
db.session.delete(current_user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
logout_user()
|
logout_user()
|
||||||
|
Loading…
Reference in New Issue
Block a user