Change behaviour of tag/suspend functions

This commit is contained in:
David Bailey 2017-08-03 22:21:59 +01:00
parent e8088146f3
commit a78d40457c
2 changed files with 20 additions and 23 deletions

View File

@ -375,18 +375,15 @@ class AnkiBridge:
return note
def addTags(self, query, tags, add=True):
notes = aqt.mw.col.findNotes(query)
def addTags(self, notes, tags, add=True):
aqt.mw.col.tags.bulkAdd(notes, tags, add)
def suspend(self, query, suspend=True):
cards = aqt.mw.col.findCards(query)
def suspend(self, cards, suspend=True):
if suspend:
suspendFunction = aqt.mw.col.sched.suspendCards
aqt.mw.col.sched.suspendCards(cards)
else:
suspendFunction = aqt.mw.col.sched.unsuspendCards
suspendFunction(cards)
aqt.mw.col.sched.unsuspendCards(cards)
def startEditing(self):
@ -677,23 +674,23 @@ class AnkiConnect:
@webApi
def addTags(self, query, tags, add=True):
return self.anki.addTags(query, tags, add)
def addTags(self, notes, tags, add=True):
return self.anki.addTags(notes, tags, add)
@webApi
def removeTags(self, query, tags):
return self.anki.addTags(query, tags, False)
def removeTags(self, notes, tags):
return self.anki.addTags(notes, tags, False)
@webApi
def suspend(self, query, suspend=True):
return self.anki.suspend(query, suspend)
def suspend(self, cards, suspend=True):
return self.anki.suspend(cards, suspend)
@webApi
def unsuspend(self, query):
return self.anki.suspend(query, False)
def unsuspend(self, cards):
return self.anki.suspend(cards, False)
@webApi

View File

@ -307,14 +307,14 @@ Below is a list of currently supported actions. Requests with invalid actions or
* **addTags**
Adds tags to notes matching a query (same syntax as **browse**/**guiBrowse**).
Adds tags to notes by note ID.
*Sample request*:
```
{
"action": "addTags",
"params": {
"query": "deck:French or deck:Spanish",
"notes": [1483959289817, 1483959291695],
"tags": "european-languages"
}
}
@ -327,14 +327,14 @@ Below is a list of currently supported actions. Requests with invalid actions or
* **removeTags**
Remove tags from notes matching a query (same syntax as **browse**/**guiBrowse**).
Remove tags from notes by note ID.
*Sample request*:
```
{
"action": "removeTags",
"params": {
"query": "deck:Japanese or deck:Chinese",
"notes": [1483959289817, 1483959291695],
"tags": "european-languages"
}
}
@ -347,14 +347,14 @@ Below is a list of currently supported actions. Requests with invalid actions or
* **suspend**
Suspend cards matching a query (same syntax as **browse**/**guiBrowse**).
Suspend cards by card ID.
*Sample request*:
```
{
"action": "suspend",
"params": {
"query": "tag:difficult"
"cards": [1483959291685, 1483959293217]
}
}
```
@ -366,14 +366,14 @@ Below is a list of currently supported actions. Requests with invalid actions or
* **unsuspend**
Unsuspend cards matching a query (same syntax as **browse**/**guiBrowse**).
Unsuspend cards by card ID.
*Sample request*:
```
{
"action": "unsuspend",
"params": {
"query": "tag:easy"
"cards": [1483959291685, 1483959293217]
}
}
```