diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -57,14 +57,13 @@ class PostManager(models.Manager): def delete_post(self, post): children = self.filter(parent=post.id) - for child in children: - self.delete_post(child) + + map(self.delete_post, children) post.delete() def delete_posts_by_ip(self, ip): posts = self.filter(poster_ip=ip) - for post in posts: - self.delete_post(post) + map(self.delete_post, posts) def get_threads(self, tag=None, page=ALL_PAGES, order_by='-last_edit_time'): @@ -133,8 +132,7 @@ class PostManager(models.Manager): num_threads_to_delete = thread_count - settings.MAX_THREAD_COUNT old_threads = threads[thread_count - num_threads_to_delete:] - for thread in old_threads: - self.delete_post(thread) + map(self.delete_post, old_threads) def _bump_thread(self, thread_id): thread = self.get(id=thread_id) @@ -172,8 +170,6 @@ class Tag(models.Model): objects = TagManager() name = models.CharField(max_length=100) - # TODO Connect the tag to its posts to check the number of threads for - # the tag. def __unicode__(self): return self.name @@ -235,6 +231,13 @@ class Post(models.Model): return '#' + str(self.id) + ' ' + self.title + ' (' + \ self.text.raw[:50] + ')' + def get_title(self): + title = self.title + if len(title) == 0: + title = self.text.raw[:20] + + return title + def _get_replies(self): return Post.objects.filter(parent=self.id) @@ -249,14 +252,6 @@ class Post(models.Model): return images_count - def get_gets_count(self): - gets_count = 1 if self.is_get() else 0 - for reply in self._get_replies(): - if reply.is_get(): - gets_count += 1 - - return gets_count - def can_bump(self): """Check if the thread can be bumped by replying""" @@ -314,7 +309,7 @@ class User(models.Model): return RANK_MODERATOR >= self.rank def __unicode__(self): - return self.user_id + return self.user_id + '(' + self.rank + ')' class Setting(models.Model): diff --git a/boards/templates/boards/base.html b/boards/templates/boards/base.html --- a/boards/templates/boards/base.html +++ b/boards/templates/boards/base.html @@ -28,10 +28,11 @@
diff --git a/boards/templates/boards/posting_general.html b/boards/templates/boards/posting_general.html --- a/boards/templates/boards/posting_general.html +++ b/boards/templates/boards/posting_general.html @@ -160,7 +160,7 @@ {% block metapanel %}