コード例 #1
0
def download_comments_to_database():
    with open('data/comment.json', 'r') as jsonfile:
        data = json.load(jsonfile)

    for datum in data:
        Comment.create(email_address=None,
                       type_of_organization=datum.get('Type of Organization'),
                       name=datum.get('Name'),
                       text=datum.get('Comment').replace('_x000D_', ' '))
コード例 #2
0
ファイル: addcomment.py プロジェクト: maulikfojdar/post-it
    def post(self, post_id):
        if not self.user:
            self.render('/login')
            return

        comment_text = self.request.get("comment_text")
        # check if there is anything entered in the comment text area
        if comment_text:
            # add comment to the comments database and refresh page
            Comment.create(post_id, comment_text, self.user.name)
            time.sleep(0.1)
            self.redirect('/post/' + post_id)