示例#1
0
def save_idea_by_json(json_data, user):
    idea = Idea()
    idea.title = json_data['title']
    idea.description = json_data['description']
    idea.category = json_data['category']
    idea.tags = json_data['tags']
    idea.author = user
    return save_idea(idea)
示例#2
0
 def test_get_all_ideas(self):
     self.addTestModels()
     idea = Idea()
     idea.title = 'Testy Title'
     idea.description = 'Testy Description'
     idea.user_id = self.testUser.id
     self.addModel(idea)
     self.assertCountEqual([idea, self.testIdea], get_all_ideas())
示例#3
0
def add_idea(user):
    idea = Idea()
    idea.title = '{} Awesome Idea'.format(user.username)
    idea.description = 'Description of an awesome Idea of {} with the title {}'.format(user.username, idea.title)
    idea.category = 'Engineering'
    idea.tags = '{},tag-{},#{},{}'.format(user.name.lower(), user.name.lower(), user.name.lower(), idea.title)
    idea.user_id = user.id
    db.session.add(idea)
    db.session.commit()