ListUsers: UAP and APP => Unapproved and Approved replaced
This commit is contained in:
parent
389b614de9
commit
a17d0ed30f
2 changed files with 15 additions and 14 deletions
|
@ -53,7 +53,8 @@ class Backup:
|
|||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
L = ListUsers.ListUsers(config['DEFAULT']['applications_db'], uap=args.unapproved, app=args.approved)
|
||||
L = ListUsers.ListUsers(config['DEFAULT']['applications_db'],
|
||||
unapproved=args.unapproved, approved=args.approved)
|
||||
fetch = L.getFetch()
|
||||
B = Backup(args.file)
|
||||
B.BackupToFile(fetch)
|
||||
|
|
|
@ -4,29 +4,22 @@ 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, uap: bool = False, app: bool = True):
|
||||
def __init__(self, db: str, unapproved: bool = False, approved: bool = True):
|
||||
self.db = SQLitedb(db)
|
||||
if uap: # only unapproved users
|
||||
if unapproved: # only unapproved users
|
||||
query = "SELECT * FROM `applications` WHERE `status` = '0'"
|
||||
elif app: # Approved users
|
||||
elif approved: # Approved users
|
||||
query = "SELECT * FROM `applications` WHERE `status` = '1'"
|
||||
else: # All users
|
||||
query = "SELECT * FROM `applications`"
|
||||
self.usersFetch = self.db.query(query)
|
||||
|
||||
def outputaslist(self) -> str:
|
||||
def output_as_list(self) -> str:
|
||||
list_str: str = ""
|
||||
query = "SELECT `username` FROM `applications` WHERE `status` = '1' ORDER BY timestamp ASC"
|
||||
self.usersFetch = self.db.query(query)
|
||||
|
@ -69,11 +62,18 @@ 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'], unapproved=args.unapproved, approved=args.approved)
|
||||
if args.list:
|
||||
ret = L.outputaslist()
|
||||
ret = L.output_as_list()
|
||||
else:
|
||||
fetch = L.getFetch()
|
||||
ret += "ID %-1s| Username %-5s| Mail %-20s| Name %-17s| Registered %-8s | State |\n" % (
|
||||
|
|
Loading…
Reference in a new issue