Пример #1
0
def newComment():
	e = Event('web.newComment')
	comment = Comment()
	c_id = None
	key = request.form['k']
	user = utils.getKey(key)
	logging.error('Processing %s' % user)
	if user is not None:
		target_id = None
		parent = None
		pObject = None
		if 'b' in request.form:		
			target_id = request.form['b']
			parent = 'b'
			pObject = Blibb()
			logging.error('Processing %s' % target_id)
		elif 'i' in request.form:
			target_id = request.form['i']
			parent = 'i'
			pObject = Blitem()
			logging.error('Processing %s' % target_id)
		else:
			abort(404)
		
		text =  request.form['c']
		c_id = comment.insert(target_id, user, text, parent)
		pObject.incCommentsCounter(target_id)
		e.save()
	else:
		d = dict()
		d['error'] = "user not found"
		c_id = d
	return json.dumps(c_id,default=json_util.default)
Пример #2
0
def newComment():
    key = request.form['login_key']
    target_id = request.form['item_id']
    text = request.form['comment']
    user = get_user(key)
    if user is not None:
        if 'status' in user:
            del user['status']
        if 'id' in user:
            del user['id']
        if 'role' in user:
            del user['role']
        c_id = Comment.insert(target_id, user, text)
        Blitem.increase_comment_counter(target_id)
        return jsonify({'item': target_id, 'user': user, 'text': text, 'comment_id': c_id})

        #####
        ###     TODO: queue item_id + comment to be added to
        ###     assoc. blibb object
        #####

    return jsonify({'error': 'user not found'})
Пример #3
0
def getComments(username=None, slug=None, item_id=None):
    if is_valid_id(item_id):
        cs = Comment.get_comments_by_id(item_id)
        return jsonify({'comments': cs})
    abort(404)
Пример #4
0
	def getTagss(self,obj_id):
		c = Comment()
		cs = c.getCommentsById(obj_id,True)
		return cs
Пример #5
0
def getComments(parent_id=None):
	e = Event('web.getComments')
	comment = Comment()
	cs = comment.getCommentsById(parent_id,True)
	e.save()
	return cs
Пример #6
0
 def get_comments(self, obj_id):
     return Comment.get_comments_by_id(obj_id)
Пример #7
0
def getComments(parent_id=None):
    if is_valid_id(parent_id):
        cs = Comment.get_comments_by_id(parent_id)
        return jsonify({'comments': cs})
    abort(404)