##// END OF EJS Templates
Fixed moving thread to bump limit. Fixed multipost in the not bumpable thread
neko259 -
r1134:d009a1d2 default
parent child Browse files
Show More
@@ -368,7 +368,7 class Post(models.Model, Viewable):
368 if self.id:
368 if self.id:
369 for thread in self.get_threads().all():
369 for thread in self.get_threads().all():
370 if thread.can_bump():
370 if thread.can_bump():
371 thread.update_bump_status()
371 thread.update_bump_status(exclude_posts=[self])
372 thread.last_edit_time = self.last_edit_time
372 thread.last_edit_time = self.last_edit_time
373
373
374 thread.save(update_fields=['last_edit_time', 'bumpable'])
374 thread.save(update_fields=['last_edit_time', 'bumpable'])
@@ -427,7 +427,7 class Post(models.Model, Viewable):
427 if thread.can_bump():
427 if thread.can_bump():
428 thread.update_bump_status()
428 thread.update_bump_status()
429
429
430 thread.last_edit_time = self.last_edit_time
430 thread.last_edit_time = self.last_edit_time
431 thread.save(update_fields=['last_edit_time', 'bumpable'])
431 thread.save(update_fields=['last_edit_time', 'bumpable'])
432
432
433 self.threads.add(thread)
433 self.threads.add(thread)
@@ -89,10 +89,10 class Thread(models.Model):
89 def has_post_limit(self) -> bool:
89 def has_post_limit(self) -> bool:
90 return self.max_posts > 0
90 return self.max_posts > 0
91
91
92 def update_bump_status(self):
92 def update_bump_status(self, exclude_posts=None):
93 if self.has_post_limit() and self.get_reply_count() >= self.max_posts:
93 if self.has_post_limit() and self.get_reply_count() >= self.max_posts:
94 self.bumpable = False
94 self.bumpable = False
95 self.update_posts_time()
95 self.update_posts_time(exclude_posts=exclude_posts)
96
96
97 def _get_cache_key(self):
97 def _get_cache_key(self):
98 return [datetime_to_epoch(self.last_edit_time)]
98 return [datetime_to_epoch(self.last_edit_time)]
@@ -208,13 +208,14 class Thread(models.Model):
208 def get_tag_url_list(self) -> list:
208 def get_tag_url_list(self) -> list:
209 return boards.models.Tag.objects.get_tag_url_list(self.get_tags())
209 return boards.models.Tag.objects.get_tag_url_list(self.get_tags())
210
210
211 def update_posts_time(self):
211 def update_posts_time(self, exclude_posts=None):
212 for post in self.post_set.all():
212 for post in self.post_set.all():
213 # Manual update is required because uids are generated on save
213 if exclude_posts is not None and post not in exclude_posts:
214 post.last_edit_time = self.last_edit_time
214 # Manual update is required because uids are generated on save
215 post.save(update_fields=['last_edit_time'])
215 post.last_edit_time = self.last_edit_time
216 post.save(update_fields=['last_edit_time'])
216
217
217 post.threads.update(last_edit_time=self.last_edit_time)
218 post.threads.update(last_edit_time=self.last_edit_time)
218
219
219 def notify_clients(self):
220 def notify_clients(self):
220 if not settings.WEBSOCKETS_ENABLED:
221 if not settings.WEBSOCKETS_ENABLED:
General Comments 0
You need to be logged in to leave comments. Login now