Beispiel #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_', ' '))
Beispiel #2
0
    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)