Show More
@@ -88,13 +88,13 b' def api_add_post(request, opening_post_i' | |||
|
88 | 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 | 92 | opening_post = get_object_or_404(Post, id=opening_post_id) |
|
92 | 93 | |
|
93 | logger.info('Adding post via api...') | |
|
94 | ||
|
95 | 94 | status = STATUS_OK |
|
96 | 95 | errors = [] |
|
97 | 96 | |
|
97 | post = None | |
|
98 | 98 | if request.method == 'POST': |
|
99 | 99 | form = PostForm(request.POST, request.FILES, error_class=PlainErrorList) |
|
100 | 100 | form.session = request.session |
@@ -113,12 +113,17 b' def api_add_post(request, opening_post_i' | |||
|
113 | 113 | else: |
|
114 | 114 | status = STATUS_ERROR |
|
115 | 115 | errors = form.as_json_errors() |
|
116 | else: | |
|
117 | status = STATUS_ERROR | |
|
116 | 118 | |
|
117 | 119 | response = { |
|
118 | 120 | 'status': status, |
|
119 | 121 | 'errors': errors, |
|
120 | 122 | } |
|
121 | 123 | |
|
124 | if post: | |
|
125 | response['post_id'] = post.id | |
|
126 | ||
|
122 | 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