diff --git a/boards/views/api.py b/boards/views/api.py --- a/boards/views/api.py +++ b/boards/views/api.py @@ -12,6 +12,10 @@ from boards.views import _datetime_to_ep __author__ = 'neko259' +PARAMETER_TRUNCATED = 'truncated' +PARAMETER_TAG = 'tag' +PARAMETER_OFFSET = 'offset' + @transaction.atomic def api_get_threaddiff(request, thread_id, last_update_time): @@ -86,10 +90,10 @@ def get_post(request, post_id): thread = post.thread_new context = RequestContext(request) - context["post"] = post - context["can_bump"] = thread.can_bump() - if "truncated" in request.GET: - context["truncated"] = True + context['post'] = post + context['can_bump'] = thread.can_bump() + if PARAMETER_TRUNCATED in request.GET: + context[PARAMETER_TRUNCATED] = True return render(request, 'boards/post.html', context) @@ -101,16 +105,16 @@ def api_get_threads(request, count): tag, offset (from which thread to get results) """ - if 'tag' in request.GET: - tag_name = request.GET['tag'] + if PARAMETER_TAG in request.GET: + tag_name = request.GET[PARAMETER_TAG] if tag_name is not None: tag = get_object_or_404(Tag, name=tag_name) threads = tag.threads.filter(archived=False) else: threads = Thread.objects.filter(archived=False) - if 'offset' in request.GET: - offset = request.GET['offset'] + if PARAMETER_OFFSET in request.GET: + offset = request.GET[PARAMETER_OFFSET] offset = int(offset) if offset is not None else 0 else: offset = 0