mirror of https://github.com/logos-co/open-law.git
fix deleting of users_books
This commit is contained in:
parent
4faf54e652
commit
e9af3f86de
File diff suppressed because one or more lines are too long
142831
app/static/js/main.js
142831
app/static/js/main.js
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,9 @@ bp = Blueprint("home", __name__, url_prefix="/home")
|
||||||
|
|
||||||
@bp.route("/", methods=["GET"])
|
@bp.route("/", methods=["GET"])
|
||||||
def get_all():
|
def get_all():
|
||||||
books: m.Book = m.Book.query.order_by(m.Book.id).limit(5)
|
books: m.Book = (
|
||||||
|
m.Book.query.filter_by(is_deleted=False).order_by(m.Book.id).limit(5)
|
||||||
|
)
|
||||||
interpretations = (
|
interpretations = (
|
||||||
db.session.query(
|
db.session.query(
|
||||||
m.Interpretation,
|
m.Interpretation,
|
||||||
|
|
|
@ -102,10 +102,12 @@ def create():
|
||||||
@login_required
|
@login_required
|
||||||
def profile_delete():
|
def profile_delete():
|
||||||
user: m.User = db.session.get(m.User, current_user.id)
|
user: m.User = db.session.get(m.User, current_user.id)
|
||||||
logout_user()
|
for book in user.books:
|
||||||
|
book.is_deleted = True
|
||||||
user.is_deleted = True
|
user.is_deleted = True
|
||||||
user.save()
|
|
||||||
log(log.INFO, "User deleted. User: [%s]", user)
|
log(log.INFO, "User deleted. User: [%s]", user)
|
||||||
|
user.save()
|
||||||
|
logout_user()
|
||||||
flash("User deleted!", "success")
|
flash("User deleted!", "success")
|
||||||
return redirect(url_for("home.get_all"))
|
return redirect(url_for("home.get_all"))
|
||||||
|
|
||||||
|
|
|
@ -117,3 +117,19 @@ def test_profile(client):
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
assert b"This field is required." in res2.data
|
assert b"This field is required." in res2.data
|
||||||
|
book = m.Book(
|
||||||
|
label="Book label",
|
||||||
|
about="Book about",
|
||||||
|
user_id=user.id,
|
||||||
|
)
|
||||||
|
book.save()
|
||||||
|
assert book
|
||||||
|
|
||||||
|
# delete_profile
|
||||||
|
res = client.post(
|
||||||
|
"/user/profile_delete",
|
||||||
|
follow_redirects=True,
|
||||||
|
)
|
||||||
|
assert res
|
||||||
|
assert user.is_deleted
|
||||||
|
assert user.books[0].is_deleted
|
||||||
|
|
Loading…
Reference in New Issue