diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-02-02 12:47:49 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-02-02 12:47:49 +0100 |
commit | a80ff9994c49b3aaba7d3f0bbf6317107fcf39bb (patch) | |
tree | 1ebe1c0b4ca15b4826adf8e930f0cd945510c2bb /portato/db/sql.py | |
parent | 7d7cccefa1373570791bde516dd90f5055888481 (diff) | |
download | portato-a80ff9994c49b3aaba7d3f0bbf6317107fcf39bb.tar.gz portato-a80ff9994c49b3aaba7d3f0bbf6317107fcf39bb.tar.bz2 portato-a80ff9994c49b3aaba7d3f0bbf6317107fcf39bb.zip |
Do not show categories which only hold disabled packages
Diffstat (limited to '')
-rw-r--r-- | portato/db/sql.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/portato/db/sql.py b/portato/db/sql.py index b406981..cac5c97 100644 --- a/portato/db/sql.py +++ b/portato/db/sql.py @@ -169,15 +169,19 @@ class SQLDatabase (Database): connection.commit() @con - def get_cat (self, category = None, byName = True, connection = None): + def get_cat (self, category = None, byName = True, showDisabled = False, connection = None): sort = "ORDER BY name" if not byName: sort = "ORDER BY inst DESC, name" + disabled = "1=1" + if not showDisabled: + disabled = "disabled = 0" + if not category or category == self.ALL: - c = connection.execute("SELECT cat, name, inst, disabled FROM packages WHERE 1=1 %s %s" % (self.restrict, sort)) + c = connection.execute("SELECT cat, name, inst, disabled FROM packages WHERE %s %s %s" % (disabled, self.restrict, sort)) else: - c = connection.execute("SELECT cat, name, inst, disabled FROM packages WHERE cat = ? %s %s" % (self.restrict ,sort), (category,)) + c = connection.execute("SELECT cat, name, inst, disabled FROM packages WHERE cat = ? AND %s %s %s" % (disabled, self.restrict ,sort), (category,)) for pkg in c: yield PkgData(pkg["cat"], pkg["name"], pkg["inst"], pkg["disabled"]) @@ -191,7 +195,7 @@ class SQLDatabase (Database): else: where = "1 = 1" - c = connection.execute("SELECT cat FROM packages WHERE %s %s GROUP BY cat" % (where, self.restrict)) + c = connection.execute("SELECT cat FROM packages WHERE disabled = 0 AND %s %s GROUP BY cat" % (where, self.restrict)) l = c.fetchall() c.close() |