def get_author_content(user_id): author_contents = AuthorContent.query.filter_by(userId=dehumanize(user_id)) return jsonify([ as_dict(author_content) for author_content in author_contents ])
def get_verdicts(): query = Verdict.query.order_by(desc(Verdict.scienceFeedbackPublishedDate)) content_id = request.args.get('contentId') keywords = request.args.get('keywords') if content_id is not None: query = query.filter_by(contentId=dehumanize(content_id)) if keywords is not None: query = keep_verdict_with_keywords(query, keywords) return listify(Verdict, includes=VERDICT_INCLUDES, page=request.args.get('page', 1), paginate=6, query=query)
def save_tags(review, humanized_tag_ids): tag_ids = [dehumanize(humanized_tag_id) for humanized_tag_id in humanized_tag_ids] for reviewTag in review.reviewTags: if reviewTag.tag.id not in tag_ids: ApiHandler.delete(reviewTag) review_tags = [] for tag_id in tag_ids: tag = Tag.query.get(tag_id) review_tag = ReviewTag.query.filter_by(tag=tag, review=review).first() if review_tag is None: review_tag = ReviewTag() review_tag.review = review review_tag.tag = tag review_tags.append(review_tag) if review_tags: ApiHandler.save(*review_tags)
def get_reviews(): check_has_role(current_user, 'EDITOR') query = Review.query content_id = request.args.get('contentId') if content_id is not None: query = query.filter_by(contentId=dehumanize(content_id)) keywords = request.args.get('keywords') if keywords is not None: query = get_reviews_join_query(query) query = get_reviews_query_with_keywords(query, keywords) return listify(Review, includes=REVIEW_INCLUDES, query=query, page=request.args.get('page', 1), paginate=10)
def get_user_article(user_id): user_articles = UserArticle.query.filter_by(userId=dehumanize(user_id)) return jsonify([ as_dict(user_article, includes=USER_ARTICLE_INCLUDES) for user_article in user_articles ])
def filter_reviews_with_article_id(query, article_id): query = query.filter_by(articleId=dehumanize(article_id)) return query