def archive_article(user, list_id, article_id):
# Retrieve the articled and list to be deleted
try:
# Check resource
the_article = Article.objects.get(id=ObjectId(article_id))
the_list = List.objects.get(Q(id=ObjectId(list_id)) & Q(articles=the_article))
# Remove the article from the list
List.objects(id=the_list.id).update_one(pull__articles=the_article)
# Remove the vote as well
Vote.objects(article=the_article, list=the_list).delete()
except Exception as e:
return type(e).__name__
the_list.reload()
return the_list
评论列表
文章目录