本文整理匯總了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)