##// END OF EJS Templates
Moved get_post to an API views module
neko259 -
r491:3cc935fe 1.6-dev
parent child Browse files
Show More
@@ -1,7 +1,7 b''
1 1 from django.conf.urls import patterns, url, include
2 2 from boards import views
3 3 from boards.rss import AllThreadsFeed, TagThreadsFeed, ThreadPostsFeed
4 from boards.views.api import api_get_threaddiff
4 from boards.views.api import api_get_threaddiff, get_post
5 5
6 6 js_info_dict = {
7 7 'packages': ('boards',),
@@ -57,7 +57,7 b" urlpatterns = patterns('',"
57 57 url(r'^jsi18n/$', 'boards.views.cached_js_catalog', js_info_dict, name='js_info_dict'),
58 58
59 59 # API
60 url(r'^api/post/(?P<post_id>\w+)/$', views.get_post, name="get_post"),
60 url(r'^api/post/(?P<post_id>\w+)/$', get_post, name="get_post"),
61 61 url(r'^api/diff_thread/(?P<thread_id>\w+)/(?P<last_update_time>\w+)/$',
62 62 api_get_threaddiff, name="get_thread_diff"),
63 63 )
@@ -1,6 +1,8 b''
1 1 from datetime import datetime, timedelta
2
2 3 from django.db.models import Count
3 4
5
4 6 OLD_USER_AGE_DAYS = 90
5 7
6 8 __author__ = 'neko259'
@@ -454,20 +456,6 b' def api_get_post(request, post_id):'
454 456 return HttpResponse(content=json)
455 457
456 458
457 def get_post(request, post_id):
458 """Get the html of a post. Used for popups."""
459
460 post = get_object_or_404(Post, id=post_id)
461 thread = post.thread_new
462
463 context = RequestContext(request)
464 context["post"] = post
465 context["can_bump"] = thread.can_bump()
466 if "truncated" in request.GET:
467 context["truncated"] = True
468
469 return render(request, 'boards/post.html', context)
470
471 459 @cache_page(86400)
472 460 def cached_js_catalog(request, domain='djangojs', packages=None):
473 461 return javascript_catalog(request, domain, packages)
@@ -2,11 +2,12 b' from datetime import datetime'
2 2 import json
3 3 from django.db import transaction
4 4 from django.http import HttpResponse
5 from django.shortcuts import get_object_or_404
5 from django.shortcuts import get_object_or_404, render
6 from django.template import RequestContext
6 7 from django.utils import timezone
7 8 from boards.forms import ThreadForm, PlainErrorList
8 9 from boards.models import Post
9 from boards.views import get_post, _datetime_to_epoch, _new_post, \
10 from boards.views import _datetime_to_epoch, _new_post, \
10 11 _ban_current_user
11 12
12 13 __author__ = 'neko259'
@@ -73,3 +74,16 b' def api_get_threaddiff(request, thread_i'
73 74 # }
74 75 #
75 76 # return HttpResponse(content=json.dumps(response))
77 def get_post(request, post_id):
78 """Get the html of a post. Used for popups."""
79
80 post = get_object_or_404(Post, id=post_id)
81 thread = post.thread_new
82
83 context = RequestContext(request)
84 context["post"] = post
85 context["can_bump"] = thread.can_bump()
86 if "truncated" in request.GET:
87 context["truncated"] = True
88
89 return render(request, 'boards/post.html', context) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now