Remove api method updateCompleteDeck
This method was broken and there are no issues regarding it on GitHub.
This commit is contained in:
parent
eac658716a
commit
d6061affad
70
README.md
70
README.md
@ -960,76 +960,6 @@ corresponding to when the API was available for use.
|
||||
}
|
||||
```
|
||||
|
||||
* **updateCompleteDeck**
|
||||
|
||||
Pastes all transmitted data into the database and reloads the collection.
|
||||
You can send a deckName and corresponding cards, notes and models.
|
||||
All cards are assumed to belong to the given deck.
|
||||
All notes referenced by given cards should be present.
|
||||
All models referenced by given notes should be present.
|
||||
|
||||
*Sample request*:
|
||||
```json
|
||||
{
|
||||
"action": "updateCompleteDeck",
|
||||
"version": 6,
|
||||
"params": {
|
||||
"data": {
|
||||
"deck": "test3",
|
||||
"cards": {
|
||||
"1485369472028": {
|
||||
"id": 1485369472028,
|
||||
"nid": 1485369340204,
|
||||
"ord": 0,
|
||||
"type": 0,
|
||||
"queue": 0,
|
||||
"due": 1186031,
|
||||
"factor": 0,
|
||||
"ivl": 0,
|
||||
"reps": 0,
|
||||
"lapses": 0,
|
||||
"left": 0
|
||||
}
|
||||
},
|
||||
"notes": {
|
||||
"1485369340204": {
|
||||
"id": 1485369340204,
|
||||
"mid": 1375786181313,
|
||||
"fields": [
|
||||
"frontValue",
|
||||
"backValue"
|
||||
],
|
||||
"tags": [
|
||||
"aTag"
|
||||
]
|
||||
}
|
||||
},
|
||||
"models": {
|
||||
"1375786181313": {
|
||||
"id": 1375786181313,
|
||||
"name": "anotherModel",
|
||||
"fields": [
|
||||
"Front",
|
||||
"Back"
|
||||
],
|
||||
"templateNames": [
|
||||
"Card 1"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Sample result*:
|
||||
```json
|
||||
{
|
||||
"result": null,
|
||||
"error": null
|
||||
}
|
||||
```
|
||||
|
||||
#### Graphical Actions
|
||||
|
||||
* **guiBrowse**
|
||||
|
@ -40,7 +40,6 @@ from anki.consts import MODEL_CLOZE
|
||||
from anki.exporting import AnkiPackageExporter
|
||||
from anki.importing import AnkiPackageImporter
|
||||
from anki.notes import Note
|
||||
from anki.utils import joinFields, intTime, guid64, fieldChecksum
|
||||
|
||||
try:
|
||||
from anki.rsbackend import NotFoundError
|
||||
@ -1286,45 +1285,6 @@ class AnkiConnect:
|
||||
) or 0
|
||||
|
||||
|
||||
@util.api()
|
||||
def updateCompleteDeck(self, data):
|
||||
self.startEditing()
|
||||
did = self.decks().id(data['deck'])
|
||||
self.decks().flush()
|
||||
model_manager = self.collection().models
|
||||
for _, card in data['cards'].items():
|
||||
self.database().execute(
|
||||
'replace into cards (id, nid, did, ord, type, queue, due, ivl, factor, reps, lapses, left, '
|
||||
'mod, usn, odue, odid, flags, data) '
|
||||
'values (' + '?,' * (12 + 6 - 1) + '?)',
|
||||
card['id'], card['nid'], did, card['ord'], card['type'], card['queue'], card['due'],
|
||||
card['ivl'], card['factor'], card['reps'], card['lapses'], card['left'],
|
||||
intTime(), -1, 0, 0, 0, 0
|
||||
)
|
||||
note = data['notes'][str(card['nid'])]
|
||||
tags = self.collection().tags.join(self.collection().tags.canonify(note['tags']))
|
||||
self.database().execute(
|
||||
'replace into notes(id, mid, tags, flds,'
|
||||
'guid, mod, usn, flags, data, sfld, csum) values (' + '?,' * (4 + 7 - 1) + '?)',
|
||||
note['id'], note['mid'], tags, joinFields(note['fields']),
|
||||
guid64(), intTime(), -1, 0, 0, '', fieldChecksum(note['fields'][0])
|
||||
)
|
||||
model = data['models'][str(note['mid'])]
|
||||
if not model_manager.get(model['id']):
|
||||
model_o = model_manager.new(model['name'])
|
||||
for field_name in model['fields']:
|
||||
field = model_manager.newField(field_name)
|
||||
model_manager.addField(model_o, field)
|
||||
for template_name in model['templateNames']:
|
||||
template = model_manager.newTemplate(template_name)
|
||||
model_manager.addTemplate(model_o, template)
|
||||
model_o['id'] = model['id']
|
||||
model_manager.update(model_o)
|
||||
model_manager.flush()
|
||||
|
||||
self.stopEditing()
|
||||
|
||||
|
||||
@util.api()
|
||||
def insertReviews(self, reviews):
|
||||
if len(reviews) > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user