added multiline append
This commit is contained in:
@@ -28,15 +28,12 @@ def edit():
|
||||
if "iid" in request.form:
|
||||
ilist_id = int(request.form["iid"])
|
||||
newname = request.form["name"]
|
||||
print(ilist_id)
|
||||
print(newname)
|
||||
double = False
|
||||
for d in ListOfItems.query.filter_by(owner_user_id=current_user.id, name=newname).all():
|
||||
if not d.id == ilist_id:
|
||||
# there is a duplicate name
|
||||
double = True
|
||||
if double:
|
||||
print("found double")
|
||||
return render_template("lists_edit.html", user=current_user, ilists=current_user.my_owned_lists(with_inactive=True), newlist=newlist, error_id=ilist_id)
|
||||
|
||||
# if id already exists, overwrite the existing list, else create a new one
|
||||
@@ -50,7 +47,6 @@ def edit():
|
||||
db.session.delete(item)
|
||||
db.session.delete(ilist)
|
||||
else:
|
||||
print("not to be deleted but updated")
|
||||
# update name
|
||||
ilist.name = newname
|
||||
# update active
|
||||
@@ -58,13 +54,10 @@ def edit():
|
||||
# sharing. there may be 0 or more chacboces named "sharing_<n>" where <N> is the user.id
|
||||
# first, remoe all the existing shares
|
||||
for s in Shared.query.filter_by(listofitem_id=ilist_id).all():
|
||||
print(f"deleting {s.user_id} - {s.listofitem_id}")
|
||||
db.session.delete(s)
|
||||
# and then rebuild them
|
||||
for u in not_current_user(current_user.id):
|
||||
print(f"tryin user {u.id}")
|
||||
if f"shares_{u.id}" in request.form:
|
||||
print(f"found sharebox: {u.id}")
|
||||
shared1 = Shared(user_id=u.id, listofitem_id=ilist_id)
|
||||
db.session.add(shared1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user