def update_popularity(self):
     if self.is_published:
         self.popularity_points = calculate_popularity(self.publish_on, self.likes - self.dislikes)
         self.popularity_likes = calculate_popularity(self.publish_on, self.likes)
         self.popularity_dislikes = calculate_popularity(self.publish_on, self.dislikes)
     else:
         self.popularity_points = 0
         self.popularity_likes = 0
         self.popularity_dislikes = 0
Exemple #2
0
 def update_popularity(self):
     if self.is_published:
         self.popularity_points = calculate_popularity(
             self.publish_on,
             self.likes - self.dislikes,
         )
         self.popularity_likes = calculate_popularity(
             self.publish_on,
             self.likes,
         )
         self.popularity_dislikes = calculate_popularity(
             self.publish_on,
             self.dislikes,
         )
     else:
         self.popularity_points = 0
         self.popularity_likes = 0
         self.popularity_dislikes = 0