fix issues and improve logic of removing tags
This commit is contained in:
@@ -376,13 +376,20 @@ def sub(pid=None, tag=None):
|
|||||||
if tag not in d:
|
if tag not in d:
|
||||||
return "user doesn't have the tag %s" % (tag, )
|
return "user doesn't have the tag %s" % (tag, )
|
||||||
else:
|
else:
|
||||||
d[tag].remove(pid)
|
if pid in d[tag]:
|
||||||
|
|
||||||
# write back to database
|
# remove this pid from the tag
|
||||||
tags_db[g.user] = d
|
d[tag].remove(pid)
|
||||||
|
|
||||||
print("removed from paper %s the tag %s for user %s" % (pid, tag, g.user))
|
# if this was the last paper in this tag, also delete the tag
|
||||||
return "ok: " + str(d) # return back the user library for debugging atm
|
if len(d[tag]) == 0:
|
||||||
|
del d[tag]
|
||||||
|
|
||||||
|
# write back the resulting dict to database
|
||||||
|
tags_db[g.user] = d
|
||||||
|
return "ok removed pid %s from tag %s" % (pid, tag)
|
||||||
|
else:
|
||||||
|
return "user doesn't have paper %s in tag %s" % (pid, tag)
|
||||||
|
|
||||||
@app.route('/del/<tag>')
|
@app.route('/del/<tag>')
|
||||||
def delete_tag(tag=None):
|
def delete_tag(tag=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user