Fix bug with mana filters.
This commit is contained in:
@@ -234,7 +234,7 @@ class CardVaultDB:
|
|||||||
filter_rarity = filters["rarity"]
|
filter_rarity = filters["rarity"]
|
||||||
filer_type = filters["type"]
|
filer_type = filters["type"]
|
||||||
filter_set = filters["set"]
|
filter_set = filters["set"]
|
||||||
filter_mana = filters["mana"].split(',')
|
filter_mana = filters["mana"]
|
||||||
filter_mana.sort(key=lambda val: util.color_sort_order[val[0]])
|
filter_mana.sort(key=lambda val: util.color_sort_order[val[0]])
|
||||||
|
|
||||||
sql = 'SELECT * FROM cards WHERE `name` LIKE ?'
|
sql = 'SELECT * FROM cards WHERE `name` LIKE ?'
|
||||||
@@ -313,7 +313,7 @@ class CardVaultDB:
|
|||||||
output.append(util.card_colors[color])
|
output.append(util.card_colors[color])
|
||||||
else:
|
else:
|
||||||
output.append("C")
|
output.append("C")
|
||||||
# TODO extrafilter_colorsct symbols from card text
|
# TODO extract symbols from card text
|
||||||
|
|
||||||
return "-".join(output)
|
return "-".join(output)
|
||||||
|
|
||||||
|
|||||||
@@ -179,15 +179,13 @@ class SearchHandlers:
|
|||||||
|
|
||||||
def get_filters(self) -> dict:
|
def get_filters(self) -> dict:
|
||||||
""" Read selected filters from UI and return values as dict """
|
""" Read selected filters from UI and return values as dict """
|
||||||
output = {}
|
output = {"mana": []}
|
||||||
# Mana colors
|
|
||||||
color_list = []
|
|
||||||
# Go through mana color buttons an get the active filters
|
|
||||||
for button in self.app.ui.get_object("manaFilterGrid").get_children():
|
for button in self.app.ui.get_object("manaFilterGrid").get_children():
|
||||||
if isinstance(button, Gtk.ToggleButton):
|
if isinstance(button, Gtk.ToggleButton):
|
||||||
if button.get_active():
|
if button.get_active():
|
||||||
color_list.append(button.get_name())
|
output["mana"].append(button.get_name())
|
||||||
output["mana"] = ",".join(color_list)
|
|
||||||
# Rarity
|
# Rarity
|
||||||
combo = self.app.ui.get_object("rarityCombo")
|
combo = self.app.ui.get_object("rarityCombo")
|
||||||
output["rarity"] = self._get_combo_value(combo)
|
output["rarity"] = self._get_combo_value(combo)
|
||||||
@@ -204,6 +202,7 @@ class SearchHandlers:
|
|||||||
|
|
||||||
def search_cards(self, term: str, filters: dict) -> dict:
|
def search_cards(self, term: str, filters: dict) -> dict:
|
||||||
"""Return a dict of cards based on a search term and filters"""
|
"""Return a dict of cards based on a search term and filters"""
|
||||||
|
|
||||||
# Check if a local database can be used for searching
|
# Check if a local database can be used for searching
|
||||||
if self.app.config["local_db"]:
|
if self.app.config["local_db"]:
|
||||||
util.log("Starting local search for '" + term + "'", util.LogLevel.Info)
|
util.log("Starting local search for '" + term + "'", util.LogLevel.Info)
|
||||||
@@ -223,7 +222,7 @@ class SearchHandlers:
|
|||||||
util.log("Fetching card info ...", util.LogLevel.Info)
|
util.log("Fetching card info ...", util.LogLevel.Info)
|
||||||
start = time.time()
|
start = time.time()
|
||||||
data = Card.where(name=term) \
|
data = Card.where(name=term) \
|
||||||
.where(colorIdentity=filters["mana"]) \
|
.where(colorIdentity=",".join(filters["mana"])) \
|
||||||
.where(types=filters["type"]) \
|
.where(types=filters["type"]) \
|
||||||
.where(set=filters["set"]) \
|
.where(set=filters["set"]) \
|
||||||
.where(rarity=filters["rarity"]) \
|
.where(rarity=filters["rarity"]) \
|
||||||
|
|||||||
Reference in New Issue
Block a user