@ -4,23 +4,16 @@ from lib.sqlitedb import SQLitedb
import configparser
import lib . uis . default as default_cmd # Follows -u, -a, -f flags
default_cmd . argparser . description + = " - Lists Users from the Tilde database. "
default_cmd . argparser . add_argument ( ' --list ' , default = False , action = " store_true " ,
help = ' Output a newline seperated list of users ' , required = False )
args = default_cmd . argparser . parse_args ( )
config = configparser . ConfigParser ( )
config . read ( args . config )
class ListUsers :
db = None
usersFetch = None
def __init__ ( self , db : str , u ap: bool = False , app : bool = True ) :
def __init__ ( self , db : str , unapproved : bool = False , approved : bool = True ) :
self . db = SQLitedb ( db )
if u ap: # only unapproved users
if u n approved : # only unapproved users
query = " SELECT * FROM `applications` WHERE `status` = ' 0 ' "
elif app : # Approved users
elif app roved : # Approved users
query = " SELECT * FROM `applications` WHERE `status` = ' 1 ' "
else : # All users
query = " SELECT * FROM `applications` "
@ -69,9 +62,15 @@ print(t.draw())
) )
"""
if __name__ == " __main__ " :
default_cmd . argparser . description + = " - Lists Users from the Tilde database. "
default_cmd . argparser . add_argument ( ' --list ' , default = False , action = " store_true " ,
help = ' Output a newline seperated list of users ' , required = False )
args = default_cmd . argparser . parse_args ( )
config = configparser . ConfigParser ( )
config . read ( args . config )
try :
ret = " "
L = ListUsers ( config [ ' DEFAULT ' ] [ ' applications_db ' ] , uap = args . unapproved , app = args . approved )
L = ListUsers ( config [ ' DEFAULT ' ] [ ' applications_db ' ] , u n approved = args . unapproved , app roved = args . approved )
if args . list :
ret = L . outputaslist ( )
else :