Commit 924da963 authored by Baptiste Mouterde's avatar Baptiste Mouterde Committed by ikoalaz
Browse files

comment: fix score function, add no-js form

parent be5f6485
......@@ -63,7 +63,6 @@ class CommentsController(BaseController):
args['parent'] = int(request.params['parent'])
else:
args['parent'] = ''
print request.params
for i in request.params:
label = i
value = request.params[label]
......@@ -219,10 +218,13 @@ class CommentsController(BaseController):
this handle the up on a comment, it will add +1 to the comment stamina
"""
log.debug('called by ajax with %s' % request.params)
msg = MsgServiceController()
return self.score(request.params['id'], request.params['value'])
return self._score(request.params['id'], request.params['value'])
def score(self):
log.debug('called by post with %s' %request.params)
return self._score(request.params['id'],request.params['value'])
def score(self, comment_id, good):
def _score(self, comment_id, good):
"""
this handle the up on a comment, it will add +1 to the comment stamina
''comment_id''
......@@ -231,6 +233,13 @@ class CommentsController(BaseController):
boolean, if true, 1 is added, if false, 1 is removed
"""
msg = MsgServiceController()
if not (str(good)=='True' or str(good)=='False' or str(good)=='true' or str(good)=='false'):
log.debug('bad data received : %s' %good)
return msg.call_msg('failure','bad type received, send bool')
if str(good)=='true' or str(good)=='True':
good=True
elif str(good)=='false' or str(good)=='False':
good=False
if not 'user_id' in session:
#no session found
log.debug("no session found, redirect to login")
......
Supports Markdown
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