exposing more information about note fields (#11)

This commit is contained in:
Alex Yatskov 2017-07-05 13:01:13 -07:00
parent c0d8d7f029
commit da7c1c8a45
2 changed files with 15 additions and 5 deletions

View File

@ -479,16 +479,19 @@ class AnkiBridge:
fields = {} fields = {}
for info in model['flds']: for info in model['flds']:
fields[info['name']] = note.fields[info['ord']] order = info['ord']
name = info['name']
fields[name] = {'value': note.fields[order], 'order': order}
if card is not None: if card is not None:
return { return {
'cardId': card.id, 'cardId': card.id,
'fields': fields, 'fields': fields,
'fieldOrder': card.ord,
'question': card._getQA()['q'], 'question': card._getQA()['q'],
'answer': card._getQA()['a'], 'answer': card._getQA()['a'],
'buttons': map(lambda b: b[0], self.window().reviewer._answerButtonList()), 'buttons': map(lambda b: b[0], reviewer._answerButtonList()),
'modelName': card.model()['name'], 'modelName': model['name'],
'deckName': self.deckNameFromId(card.did) 'deckName': self.deckNameFromId(card.did)
} }

View File

@ -334,9 +334,16 @@ Below is a list of currently supported actions. Requests with invalid actions or
"question": "front content", "question": "front content",
"deckName": "Default", "deckName": "Default",
"modelName": "Basic", "modelName": "Basic",
"fieldOrder": 0,
"fields": { "fields": {
"Front": "front content", "Front": {
"Back": "back content" "value": "front content",
"order": 0
},
"Back": {
"value": "back content",
"order": 1
}
}, },
"cardId": 1498938915662, "cardId": 1498938915662,
"buttons": [1, 2, 3] "buttons": [1, 2, 3]