##// END OF EJS Templates
Move attribute names in api to constants
neko259 -
r1076:b0b20791 default
parent child Browse files
Show More
@@ -21,6 +21,8 b" PARAMETER_TAG = 'tag'"
21 PARAMETER_OFFSET = 'offset'
21 PARAMETER_OFFSET = 'offset'
22 PARAMETER_DIFF_TYPE = 'type'
22 PARAMETER_DIFF_TYPE = 'type'
23 PARAMETER_POST = 'post'
23 PARAMETER_POST = 'post'
24 PARAMETER_ADDED = 'added'
25 PARAMETER_UPDATED = 'updated'
24
26
25 DIFF_TYPE_HTML = 'html'
27 DIFF_TYPE_HTML = 'html'
26 DIFF_TYPE_JSON = 'json'
28 DIFF_TYPE_JSON = 'json'
@@ -46,8 +48,8 b' def api_get_threaddiff(request, thread_i'
46 timezone.get_current_timezone())
48 timezone.get_current_timezone())
47
49
48 json_data = {
50 json_data = {
49 'added': [],
51 PARAMETER_ADDED: [],
50 'updated': [],
52 PARAMETER_UPDATED: [],
51 'last_update': None,
53 'last_update': None,
52 }
54 }
53 added_posts = Post.objects.filter(threads__in=[thread],
55 added_posts = Post.objects.filter(threads__in=[thread],
@@ -60,9 +62,9 b' def api_get_threaddiff(request, thread_i'
60 diff_type = request.GET.get(PARAMETER_DIFF_TYPE, DIFF_TYPE_HTML)
62 diff_type = request.GET.get(PARAMETER_DIFF_TYPE, DIFF_TYPE_HTML)
61
63
62 for post in added_posts:
64 for post in added_posts:
63 json_data['added'].append(get_post_data(post.id, diff_type, request))
65 json_data[PARAMETER_ADDED].append(get_post_data(post.id, diff_type, request))
64 for post in updated_posts:
66 for post in updated_posts:
65 json_data['updated'].append(get_post_data(post.id, diff_type, request))
67 json_data[PARAMETER_UPDATED].append(get_post_data(post.id, diff_type, request))
66 json_data['last_update'] = datetime_to_epoch(thread.last_edit_time)
68 json_data['last_update'] = datetime_to_epoch(thread.last_edit_time)
67
69
68 return HttpResponse(content=json.dumps(json_data))
70 return HttpResponse(content=json.dumps(json_data))
General Comments 0
You need to be logged in to leave comments. Login now