Python app.models.Post() Examples

The following are 6 code examples of app.models.Post(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module app.models , or try the search function .
Example #1
Source File: sticky_comment_experiment_controller.py    From CivilServant with MIT License 6 votes vote down vote up
def archive_eligible_submissions(self, eligible_submissions):
        existing_post_ids = set([sub.id for sub in self.db_session.query(Post).filter(
            Post.id.in_(list(eligible_submissions.keys())))])

        # list of praw objects
        to_archive_posts = [eligible_submissions[sid] for sid in eligible_submissions if sid not in existing_post_ids]
            
        new_posts = []
        for post in to_archive_posts:
            post_info = post.json_dict if("json_dict" in dir(post)) else post['data'] ### TO HANDLE TEST FIXTURES
            new_post = Post(
                    id = post_info['id'],
                    subreddit_id = post_info['subreddit_id'].strip("t5_"), # janky
                    created = datetime.datetime.fromtimestamp(post_info['created_utc']),        
                    post_data = json.dumps(post_info))
            new_posts.append(new_post)
            #self.db_session.add(new_post)
        self.db_session.add_retryable(new_posts)
        #self.db_session.commit() 
Example #2
Source File: manage.py    From circleci-demo-python-flask with MIT License 5 votes vote down vote up
def make_shell_context():
    return dict(app=app, db=db, User=User, Follow=Follow, Role=Role,
                Permission=Permission, Post=Post, Comment=Comment) 
Example #3
Source File: manage.py    From Simpleblog with MIT License 5 votes vote down vote up
def make_shell_context():
    return dict(app=app, db=db, User=User, Role=Role, Post=Post, \
                Follow=Follow, Permission=Permission, Admin=Admin) 
Example #4
Source File: manage.py    From flasky-first-edition with MIT License 5 votes vote down vote up
def make_shell_context():
    return dict(app=app, db=db, User=User, Follow=Follow, Role=Role,
                Permission=Permission, Post=Post, Comment=Comment) 
Example #5
Source File: test_blog_client.py    From tutorial-flask with Apache License 2.0 5 votes vote down vote up
def test_index_with_posts(self):
        with self.app.app_context():
            admin = User.get_by_email('admin@xyz.com')
            post = Post(user_id=admin.id, title='Post de prueba', content='Lorem Ipsum')
            post.save()
        res = self.client.get('/')
        self.assertEqual(200, res.status_code)
        self.assertNotIn(b'No hay entradas', res.data) 
Example #6
Source File: manage.py    From flasky-with-celery with MIT License 5 votes vote down vote up
def make_shell_context():
    return dict(app=app, db=db, User=User, Follow=Follow, Role=Role,
                Permission=Permission, Post=Post, Comment=Comment)