##// END OF EJS Templates
Api module refactoring, moved some values to the module scope
neko259 -
r501:aa88ad35 1.6-dev
parent child Browse files
Show More
@@ -12,6 +12,10 b' from boards.views import _datetime_to_ep'
12
12
13 __author__ = 'neko259'
13 __author__ = 'neko259'
14
14
15 PARAMETER_TRUNCATED = 'truncated'
16 PARAMETER_TAG = 'tag'
17 PARAMETER_OFFSET = 'offset'
18
15
19
16 @transaction.atomic
20 @transaction.atomic
17 def api_get_threaddiff(request, thread_id, last_update_time):
21 def api_get_threaddiff(request, thread_id, last_update_time):
@@ -86,10 +90,10 b' def get_post(request, post_id):'
86 thread = post.thread_new
90 thread = post.thread_new
87
91
88 context = RequestContext(request)
92 context = RequestContext(request)
89 context["post"] = post
93 context['post'] = post
90 context["can_bump"] = thread.can_bump()
94 context['can_bump'] = thread.can_bump()
91 if "truncated" in request.GET:
95 if PARAMETER_TRUNCATED in request.GET:
92 context["truncated"] = True
96 context[PARAMETER_TRUNCATED] = True
93
97
94 return render(request, 'boards/post.html', context)
98 return render(request, 'boards/post.html', context)
95
99
@@ -101,16 +105,16 b' def api_get_threads(request, count):'
101 tag, offset (from which thread to get results)
105 tag, offset (from which thread to get results)
102 """
106 """
103
107
104 if 'tag' in request.GET:
108 if PARAMETER_TAG in request.GET:
105 tag_name = request.GET['tag']
109 tag_name = request.GET[PARAMETER_TAG]
106 if tag_name is not None:
110 if tag_name is not None:
107 tag = get_object_or_404(Tag, name=tag_name)
111 tag = get_object_or_404(Tag, name=tag_name)
108 threads = tag.threads.filter(archived=False)
112 threads = tag.threads.filter(archived=False)
109 else:
113 else:
110 threads = Thread.objects.filter(archived=False)
114 threads = Thread.objects.filter(archived=False)
111
115
112 if 'offset' in request.GET:
116 if PARAMETER_OFFSET in request.GET:
113 offset = request.GET['offset']
117 offset = request.GET[PARAMETER_OFFSET]
114 offset = int(offset) if offset is not None else 0
118 offset = int(offset) if offset is not None else 0
115 else:
119 else:
116 offset = 0
120 offset = 0
General Comments 0
You need to be logged in to leave comments. Login now