def create(data):
    post_guid = data.pop('post_guid', None)
    data['post'] = post_guid and get(post_guid)
    obj = Discussion.create_one(**data)
    db.session.commit()

    return obj
Exemple #2
0
def create_mock_discussion(**kwargs):
    fake = Faker()
    discussion = Discussion.create_one(
        body=fake.sentences(),
        author=kwargs.get('author', create_mock_user()),
        enrollment=kwargs.get('enrollment'),
        post=kwargs.get('post'),
    )
    db.session.commit()
    return discussion