def test_get_popular(self): reviews = db_review.get_popular() self.assertEqual(len(reviews), 0) db_review.create( entity_id="e7aad618-fa86-3983-9e77-405e21796eca", entity_type="release_group", user_id=self.user.id, text="Awesome", is_draft=False, license_id=self.license["id"], ) reviews = db_review.get_popular() self.assertEqual(len(reviews), 1) review = db_review.create( user_id=self.user.id, entity_id="e7aad618-fa86-3983-9e77-405e21796ece", entity_type="release_group", text="Not Awesome", is_draft=False, license_id=self.license["id"], language="en", ) db_review.set_hidden_state(review["id"], is_hidden=True) reviews = db_review.get_popular() self.assertEqual(len(reviews), 1) self.assertEqual(reviews[0]["is_hidden"], False)
def test_get_popular(self): reviews = db_review.get_popular() self.assertEqual(len(reviews), 0) # popular reviews should not contain reviews saved as drafts review = db_review.create( entity_id="e7aad618-fa86-3983-9e77-405e21796eca", entity_type="release_group", user_id=self.user.id, text="A draft", is_draft=True, license_id=self.license["id"], ) reviews = db_review.get_popular() self.assertEqual(len(reviews), 0) # publishing the drafted review; now it should be in popular reviews db_review.update( review_id=review["id"], drafted=True, text=review["text"], rating=review["rating"], is_draft=False, ) reviews = db_review.get_popular() self.assertEqual(len(reviews), 1) self.assertEqual(reviews[0]["is_draft"], False) # A hidden review should not be in popular reviews db_review.set_hidden_state(review["id"], is_hidden=True) reviews = db_review.get_popular() self.assertEqual(len(reviews), 0)
def test_get_popular(self): reviews = db_review.get_popular() self.assertEqual(len(reviews), 0) db_review.create( entity_id="e7aad618-fa86-3983-9e77-405e21796eca", entity_type="release_group", user_id=self.user.id, text="Awesome", is_draft=False, license_id=self.license["id"], ) reviews = db_review.get_popular() self.assertEqual(len(reviews), 1)
def index(): # Popular reviews popular_reviews = db_review.get_popular(6) for review in popular_reviews: # Preparing text for preview preview = markdown(review['text'], safe_mode="escape") review['preview'] = ''.join(BeautifulSoup(preview, "html.parser").findAll(text=True)) # Recent reviews recent_reviews, _ = db_review.list_reviews(sort='created', limit=9) # Statistics review_count = format_number(db_review.get_count(is_draft=False)) user_count = format_number(db_users.total_count()) return render_template('index/index.html', popular_reviews=popular_reviews, recent_reviews=recent_reviews, reviews_total=review_count, users_total=user_count)
def index(): # Popular reviews popular_reviews = db_review.get_popular(6) for review in popular_reviews: # Preparing text for preview preview = markdown(review['text'], safe_mode="escape") review['preview'] = ''.join(BeautifulSoup(preview, "html.parser").findAll(text=True)) # Recent reviews recent_reviews, _ = db_review.list_reviews(sort='published_on', limit=9) # Statistics review_count = format_number(db_review.get_count(is_draft=False)) user_count = format_number(db_users.total_count()) return render_template('index/index.html', popular_reviews=popular_reviews, recent_reviews=recent_reviews, reviews_total=review_count, users_total=user_count)