本文整理汇总了Python中flashcardapp.datacontroller.DataController.updateFlashcard方法的典型用法代码示例。如果您正苦于以下问题:Python DataController.updateFlashcard方法的具体用法?Python DataController.updateFlashcard怎么用?Python DataController.updateFlashcard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flashcardapp.datacontroller.DataController
的用法示例。
在下文中一共展示了DataController.updateFlashcard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_updateFlashcard
# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import updateFlashcard [as 别名]
def test_updateFlashcard(self):
"""
Docstring goes here
"""
numoftextsides = 3
data = {'cardId':4, 'term':"New Term",'defaultSideLabel_id':2,\
'otherSides': [{'labelId':8,'type':"text",'data':"None"},\
{'labelId':2,'type':"text",'data':"New Translation"}, \
{'labelId':13,'type':"text",'data':"Das Essen schmeckt mir."}]}
dc = DataController()
response = json.loads(dc.updateFlashcard(data, self.user))
self.assertTrue(response['updated'], response['message'])
self.assertEqual(response['message'], DataController.SUCCESS_STR)
flashcard = Flashcard.objects.get(pk=data['cardId'])
self.assertEquals(flashcard.term, data['term'])
self.assertEquals(flashcard.defaultSideLabel.Id, data['defaultSideLabel_id'])
self.assertEquals(len(flashcard.textside_set.all()), numoftextsides)
for tsinfo in data['otherSides']:
qs = flashcard.textside_set.filter(labelKey__Id=tsinfo['labelId'])
self.assertTrue(qs.exists())
for ts in qs:
self.assertEqual(ts.text, tsinfo['data'])
示例2: updateFlashcard
# 需要导入模块: from flashcardapp.datacontroller import DataController [as 别名]
# 或者: from flashcardapp.datacontroller.DataController import updateFlashcard [as 别名]
def updateFlashcard(request, flashcardData):
'''Ajax wrapper for the DataController function 'updateFlashcard'
*Takes*
A dictionary representing the updates to the flashcard
*Returns*
A json string declaring updated data success or failure
See the DataController documentation for more information
'''
dc = DataController()
return dc.updateFlashcard(flashcardData, request.user)