Show More
@@ -18,6 +18,7 b' from boards import settings' | |||
|
18 | 18 | from boards.models import PostImage |
|
19 | 19 | from boards.models.base import Viewable |
|
20 | 20 | from boards import utils |
|
21 | from boards.models.post.export import get_exporter, DIFF_TYPE_JSON | |
|
21 | 22 | from boards.models.user import Notification, Ban |
|
22 | 23 | import boards.models.thread |
|
23 | 24 | |
@@ -354,9 +355,13 b' class Post(models.Model, Viewable):' | |||
|
354 | 355 | |
|
355 | 356 | return self.get_thread().get_opening_post_id() == self.id |
|
356 | 357 | |
|
358 | # TODO Remove this and use get_absolute_url method | |
|
357 | 359 | def get_url(self): |
|
358 | 360 | return self.url |
|
359 | 361 | |
|
362 | def get_absolute_url(self): | |
|
363 | return self.url | |
|
364 | ||
|
360 | 365 | def get_thread(self): |
|
361 | 366 | return self.thread |
|
362 | 367 | |
@@ -488,37 +493,15 b' class Post(models.Model, Viewable):' | |||
|
488 | 493 | API. |
|
489 | 494 | """ |
|
490 | 495 | |
|
491 | if format_type == DIFF_TYPE_HTML: | |
|
492 | if request is not None and PARAMETER_TRUNCATED in request.GET: | |
|
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 | |
|
496 | return get_exporter(format_type).export(self, request, | |
|
497 | include_last_update) | |
|
515 | 498 | |
|
516 | 499 | def notify_clients(self, recursive=True): |
|
517 | 500 | """ |
|
518 | 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 | 505 | return |
|
523 | 506 | |
|
524 | 507 | thread_ids = list() |
General Comments 0
You need to be logged in to leave comments.
Login now