コード例 #1
0
def list_admin():
    os.system('cls')
    print(f"{'List admin':^50}")
    print("=" * 50)
    admins = load_admins()
    print(f"{'No':>4} {'Id':<20} {'Nama':<25}")
    for idx, admin in enumerate(admins):
        print(f"{(idx+1):>3}. {admin.id:<20} {admin.name:<25}")
    print()
    os.system('pause')
コード例 #2
0
def remove_admin():
    os.system('cls')
    print(f"{'Remove admin':^50}")
    print("=" * 50)
    admins = load_admins()
    admin_id = input_string("Masukkan Id: ")
    if admin_id in [admin.id for admin in admins]:
        admin_remove(admin_id)
        print("Admin berhasil dihapus")
    else:
        print("Id tidak ditemukan")
    print()
    os.system('pause')
コード例 #3
0
def edit_admin():
    os.system('cls')
    print(f"{'Edit password admin':^50}")
    print("=" * 50)
    admins = load_admins()
    admin_id = input_string("Masukkan Id:")
    if admin_id in [admin.id for admin in admins]:
        admin_new_password = input_password("Masukkan password baru: ")
        admin_edit(admin_id, admin_new_password)
        print("Password berhasil diedit")
    else:
        print("Id tidak ditemukan")
    print()
    os.system('pause')
コード例 #4
0
def add_admin():
    os.system('cls')
    print(f"{'Add admin baru':^50}")
    print("=" * 50)
    admins = load_admins()
    admin_name = input_string("Nama lengkap: ")
    admin_age = input_int("Umur: ")
    while True:
        admin_id = input_string("Id: ")
        if admin_id not in [admin.id for admin in admins]:
            break
        else:
            print("Id telah digunakan")
    admin_password = input_password("Password: "******"Admin berhasil ditambahkan")
    os.system('pause')
コード例 #5
0
def login_admin():
    os.system('cls')
    admins = load_admins()
    loop = True
    login = False
    print(f"{'Admin Login':^50}")
    print("=" * 50)
    while loop:
        admin_id = input_string("Id: ")
        for admin in admins:
            if admin.id == admin_id:
                login == True
                admin_pass = input_password("Password: "******"Logged in as admin")
                    loop = False
                    break
                else:
                    print("Password salah")
        if login == False:
            print("Id tidak ditemukan")