Commit 233dc06b authored by Jogi Hofmüller's avatar Jogi Hofmüller

Let AddHandler add new geruecht

parent a447a4cf
......@@ -139,9 +139,29 @@ class AddHandler(RestHandler):
def put(self):
sentence = tornado.escape.json_decode(self.request.body)
self.finish(json.dumps({'status': 'success', 'message': sentence}))
user = self.get_secure_cookie('user')
if not user:
user = 'anonymous'
data = tornado.escape.json_decode(self.request.body)
if data['type'] == 'name':
self.finish(json.dumps({'status': 'error', 'message': 'not implemented yet'}))
logmsg('AddHandler: adding new name not implemented yet')
if data['type'] == 'geruecht':
if len(data['payload']) < 20:
self.finish(json.dumps({'status': 'error', 'message': 'Fehler! Gerücht zu kurz.'}))
logmsg('AddHandler: refused to add new geruecht (too short)')
gdb.addNewGeruecht(data['payload'], user)
self.finish(json.dumps({'status': 'success', 'message': 'Gerücht hinzugefügt.'}))
logmsg('AddHandler: added new geruecht from remote_ip={}'.format(self.request.remote_ip))
# fallthrough
self.finish(json.dumps({'status': 'error', 'message': 'unknown type'}))
class LoginHandler(RestHandler):
def set_default_headers(self):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment