diff --git a/anki/deck.py b/anki/deck.py index 5b6bd333b..c21445d86 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -1134,8 +1134,9 @@ facts.modelId = :id""", id=model.id) else: mod = "" # tags - tags = dict(self.tagsList(priority="", where="and cards.id in %s" % - ids2str([x[0] for x in ids]))) + tags = dict(self.shortTagsList( + where="and cards.id in %s" % + ids2str([x[0] for x in ids]))) facts = {} # fields for k, g in groupby(self.s.all(""" @@ -1180,6 +1181,13 @@ cardModels.name %s from cards, facts, models, cardModels where cards.factId == facts.id and facts.modelId == models.id and cards.cardModelId = cardModels.id %s""" % (priority, where)) + def shortTagsList(self, where=""): + return self.s.all(""" +select cards.id, cards.tags || "," || facts.tags || "," || models.tags +from cards, facts, models where +cards.factId == facts.id and facts.modelId == models.id +%s""" % where) + def allTags(self): "Return a hash listing tags in model, fact and cards." return list(set(parseTags(",".join([x[1] for x in self.tagsList()])))) diff --git a/anki/models.py b/anki/models.py index d2fc82e27..7ce29c88a 100644 --- a/anki/models.py +++ b/anki/models.py @@ -119,6 +119,7 @@ def formatQA(cid, mid, fact, tags, cm): fields[k] = '%s' % ( hexifyID(v[0]), v[1]) fields['tags'] = canonifyTags(tags) + fields['Tags'] = fields['tags'] # render q & a ret = [] for (type, format) in (("question", cm.qformat),