##// END OF EJS Templates
Return id of the post created via API
neko259 -
r1996:2e4c8272 default
parent child Browse files
Show More
@@ -88,13 +88,13 b' def api_add_post(request, opening_post_i'
88 Adds a post and return the JSON response for it
88 Adds a post and return the JSON response for it
89 """
89 """
90
90
91 # TODO Allow thread creation here too, without specifying opening post
91 opening_post = get_object_or_404(Post, id=opening_post_id)
92 opening_post = get_object_or_404(Post, id=opening_post_id)
92
93
93 logger.info('Adding post via api...')
94
95 status = STATUS_OK
94 status = STATUS_OK
96 errors = []
95 errors = []
97
96
97 post = None
98 if request.method == 'POST':
98 if request.method == 'POST':
99 form = PostForm(request.POST, request.FILES, error_class=PlainErrorList)
99 form = PostForm(request.POST, request.FILES, error_class=PlainErrorList)
100 form.session = request.session
100 form.session = request.session
@@ -113,12 +113,17 b' def api_add_post(request, opening_post_i'
113 else:
113 else:
114 status = STATUS_ERROR
114 status = STATUS_ERROR
115 errors = form.as_json_errors()
115 errors = form.as_json_errors()
116 else:
117 status = STATUS_ERROR
116
118
117 response = {
119 response = {
118 'status': status,
120 'status': status,
119 'errors': errors,
121 'errors': errors,
120 }
122 }
121
123
124 if post:
125 response['post_id'] = post.id
126
122 return HttpResponse(content=json.dumps(response))
127 return HttpResponse(content=json.dumps(response))
123
128
124
129
General Comments 0
You need to be logged in to leave comments. Login now