コード例 #1
0
ファイル: feeds.py プロジェクト: Rikanishu/rdr
def feed_mark_unread_as_read():
    from rdr.modules.feeds.articles.unread import TotalUnreadArticlesSet

    unread_set = TotalUnreadArticlesSet(session_user.user)
    for article in unread_set.articles:
        article_status = ArticleStatus()
        article_status.user_id = session_user.user.id
        article_status.article_id = article.id
        article_status.status = ArticleStatus.STATUS_READ
        article_status.read_date = datetime.now()
        db.session.add(article_status)
    db.session.commit()
    return {"success": True}
コード例 #2
0
ファイル: feeds.py プロジェクト: Rikanishu/rdr
def feed_mark_all_as_read():
    from rdr.modules.feeds.articles.unread import FeedUnreadArticlesSet

    body = json.get_request_body()
    feed_id = body["feedId"]
    feed = Feed.query.filter(Feed.id == feed_id).first()
    if not feed:
        raise NotFound("Feed not found")
    unread_set = FeedUnreadArticlesSet(session_user.user, feed)
    for article in unread_set.articles:
        article_status = ArticleStatus()
        article_status.user_id = session_user.user.id
        article_status.article_id = article.id
        article_status.status = ArticleStatus.STATUS_READ
        article_status.read_date = datetime.now()
        db.session.add(article_status)
    db.session.commit()
    return {"success": True}
コード例 #3
0
ファイル: articles.py プロジェクト: Rikanishu/rdr
def article_mark_as_read():
    body = json.get_request_body()
    article_id = body['articleId']
    existed_status = ArticleStatus.query \
        .filter((ArticleStatus.article_id == article_id) & (ArticleStatus.user_id == session_user.user.id)) \
        .first()
    if existed_status:
        existed_status.status = ArticleStatus.STATUS_READ
    else:
        article_status = ArticleStatus()
        article_status.user_id = session_user.user.id
        article_status.article_id = article_id
        article_status.status = ArticleStatus.STATUS_READ
        article_status.read_date = datetime.now()
        db.session.add(article_status)
    db.session.commit()

    return {
        'success': True
    }