##// END OF EJS Templates
Continue merge
neko259 -
r1158:05c160e3 decentral
parent child Browse files
Show More
@@ -18,6 +18,7 b' from boards import settings'
18 from boards.models import PostImage
18 from boards.models import PostImage
19 from boards.models.base import Viewable
19 from boards.models.base import Viewable
20 from boards import utils
20 from boards import utils
21 from boards.models.post.export import get_exporter, DIFF_TYPE_JSON
21 from boards.models.user import Notification, Ban
22 from boards.models.user import Notification, Ban
22 import boards.models.thread
23 import boards.models.thread
23
24
@@ -354,9 +355,13 b' class Post(models.Model, Viewable):'
354
355
355 return self.get_thread().get_opening_post_id() == self.id
356 return self.get_thread().get_opening_post_id() == self.id
356
357
358 # TODO Remove this and use get_absolute_url method
357 def get_url(self):
359 def get_url(self):
358 return self.url
360 return self.url
359
361
362 def get_absolute_url(self):
363 return self.url
364
360 def get_thread(self):
365 def get_thread(self):
361 return self.thread
366 return self.thread
362
367
@@ -488,37 +493,15 b' class Post(models.Model, Viewable):'
488 API.
493 API.
489 """
494 """
490
495
491 if format_type == DIFF_TYPE_HTML:
496 return get_exporter(format_type).export(self, request,
492 if request is not None and PARAMETER_TRUNCATED in request.GET:
497 include_last_update)
493 truncated = True
494 reply_link = False
495 else:
496 truncated = False
497 reply_link = True
498
499 return self.get_view(truncated=truncated, reply_link=reply_link,
500 moderator=utils.is_moderator(request))
501 elif format_type == DIFF_TYPE_JSON:
502 post_json = {
503 'id': self.id,
504 'title': self.title,
505 'text': self._text_rendered,
506 }
507 if self.images.exists():
508 post_image = self.get_first_image()
509 post_json['image'] = post_image.image.url
510 post_json['image_preview'] = post_image.image.url_200x150
511 if include_last_update:
512 post_json['bump_time'] = utils.datetime_to_epoch(
513 self.get_thread().bump_time)
514 return post_json
515
498
516 def notify_clients(self, recursive=True):
499 def notify_clients(self, recursive=True):
517 """
500 """
518 Sends post HTML data to the thread web socket.
501 Sends post HTML data to the thread web socket.
519 """
502 """
520
503
521 if not settings.WEBSOCKETS_ENABLED:
504 if not settings.get_bool('External', 'WebsocketsEnabled'):
522 return
505 return
523
506
524 thread_ids = list()
507 thread_ids = list()
General Comments 0
You need to be logged in to leave comments. Login now