Exemple #1
0
 def to_json(self):
     return {
         'id': self.id,
         'user_name': self.user.name,
         'user_url': self.user.stream_url,  # TODO: rename this to stream_url
         'user_avatar_url': self.user.avatar_url,
         'comment': util.sanitizeHTML(self.comment),
         'parentID': self.parentID,
         'time': str(self.creation_time)
     }
Exemple #2
0
def addComment():
    if request.method == 'POST':
        photoID = request.form.get('photoID')
        photo = Photo.query.get(photoID)
        if photo:
            comment_text = util.sanitizeHTML(request.form.get('comment'))
            parentID = request.form.get('parentID')
            comment = Comment(g.user, photo, comment_text, None, parentID)
            db.session.add(comment)
            db.session.commit()
            return jsonify(result = True, comment = json.dumps(comment.to_json()))
    return jsonify(result = False)