Add deleteDecks function

This commit is contained in:
David Bailey 2017-08-13 10:05:56 +01:00
parent 6da8481b07
commit 99d70cc2a4
2 changed files with 34 additions and 0 deletions

View File

@ -568,6 +568,14 @@ class AnkiBridge:
self.stopEditing()
def deleteDecks(self, decks, cardsToo=False):
self.startEditing()
for deck in decks:
id = self.collection().decks.id(deck)
self.collection().decks.rem(id, cardsToo)
self.stopEditing()
def cardsToNotes(self, cards):
return self.collection().db.list('select distinct nid from cards where id in ' + anki.utils.ids2str(cards))
@ -861,6 +869,11 @@ class AnkiConnect:
return self.anki.changeDeck(cards, deck)
@webApi
def deleteDecks(self, decks, cardsToo=False):
return self.anki.deleteDecks(decks, cardsToo)
@webApi
def cardsToNotes(self, cards):
return self.anki.cardsToNotes(cards)

View File

@ -554,6 +554,27 @@ Below is a list of currently supported actions. Requests with invalid actions or
```
null
```
* **deleteDecks**
Deletes decks with the given names. If `cardsToo` is `true` (defaults to `false` if unspecified), the cards within
the deleted decks will also be deleted; otherwise they will be moved to the default deck.
*Sample request*:
```
{
"action": "deleteDecks",
"params": {
"decks": ["Japanese::JLPT N5", "Easy Spanish"],
"cardsToo": true
}
}
```
*Sample response*:
```
null
```
* **cardsToNotes**