changeset 933:e4c13a995e0b

pages (common/blog): data post (i.e. new comments) is now handled
author Goffi <goffi@goffi.org>
date Mon, 17 Apr 2017 20:44:10 +0200
parents af6a62e21053
children a21fee7e30ee
files src/pages/common/blog/page_meta.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/pages/common/blog/page_meta.py	Mon Apr 17 20:43:12 2017 +0200
+++ b/src/pages/common/blog/page_meta.py	Mon Apr 17 20:44:10 2017 +0200
@@ -95,3 +95,22 @@
 
     template_data = request.template_data
     template_data[u'items'] = items
+    template_data[u'allow_commenting'] = u'simple'
+
+
+@defer.inlineCallbacks
+def on_data_post(self, request):
+    profile = self.getProfile(request)
+    if profile is None:
+        self.pageError(request, C.HTTP_UNAUTHORIZED)
+    service, node, body = self.getPostedData(request, (u'service', u'node', u'body'))
+    if not body:
+        self.pageError(request, C.HTTP_BAD_REQUEST)
+    comment_data = {u"content": body}
+    try:
+        yield self.host.bridge.mbSend(service, node, comment_data, profile)
+    except Exception as e:
+        if u"forbidden" in unicode(e):
+            self.pageError(request, 401)
+        else:
+            raise e