コード例 #1
0
ファイル: api.py プロジェクト: nate-parrott/fast-news
def delete_bookmark(uid, article_id):
    id = Bookmark.id_for_bookmark(uid, article_id)
    bookmark = ndb.Key(Bookmark, id).get()
    if bookmark:
        bookmark.deleted = True
        bookmark.last_modified = datetime.datetime.now()
        bookmark.put()
コード例 #2
0
ファイル: api.py プロジェクト: nate-parrott/fast-news
def add_or_update_bookmark(uid, reading_pos, article_id=None, article_url=None):
    # provide EITHER article_id or article_url
    if not (article_id or article_url):
        logging.error("Attempt to update bookmark without article_id or article_url")
        return None
    if not article_id and article_url:
        article = ensure_article_at_url(article_url)
        if article:
            article_id = article.key.id()
        else:
            logging.error("Tried to get article {0} for bookmarking, but failed".format(article_url))
            return None

    id = Bookmark.id_for_bookmark(uid, article_id)
    bookmark, inserted = get_or_insert(Bookmark, id)
    bookmark.article = ndb.Key(Article, article_id)
    if reading_pos:
        bookmark.reading_position = reading_pos
    bookmark.last_modified = datetime.datetime.now()
    bookmark.uid = uid
    bookmark.deleted = False
    bookmark.put()
    return bookmark