-a Flag: default false, do action on only approved users

pull/4/head
Darksider3 5 years ago
parent c40ef4d40a
commit 6e86bf11bb

@ -8,12 +8,14 @@ class ListUsers:
db = None
usersFetch = None
def __init__(self, ap: bool):
def __init__(self, uap: bool = CFG.args.unapproved, a: bool = CFG.args.approved):
self.db = SQLitedb(CFG.REG_FILE)
if not ap:
query = "SELECT * FROM `applications` WHERE status = '1'"
else:
if uap: # only unapproved users
query = "SELECT * FROM `applications` WHERE status = '0'"
elif a: # Approved users
query = "SELECT * FROM `applications` WHERE status = '1'"
else: # All users
query = "SELECT * FROM `applications`"
self.usersFetch = self.db.query(query)
def prettyPrint(self):
@ -25,7 +27,7 @@ class ListUsers:
if __name__ == "__main__":
try:
L = ListUsers(CFG.args.unapproved)
L = ListUsers()
fetch = L.getFetch()
# MAYBE best solution: https://pypi.org/project/texttable/
# examle:

@ -12,7 +12,9 @@ argparser.add_argument('-c', '--config', default=cwd,
type=str, help='Path to configuration file', required=False)
# store_true just stores true when the command is supplied, so it doesn't need choices nor types
argparser.add_argument('-u', '--unapproved', default=False, action="store_true",
help='List only unapproved users', required=False)
help='only unapproved users. Default is only approved.', required=False)
argparser.add_argument('-a', '--approved', default=False, action="store_true",
help="Only approved Users.", required=False)
args = argparser.parse_args()
CONF_FILE = args.config

Loading…
Cancel
Save