Systemadminstratorpython
Systemadminstratorpython
password = ""
def login_menu():
while True:
print("======= Welcome Back =======\n")
print("---------Login----------------\n")
username = input("Enter username: ")
password = input("Enter Password: ")
# print(username)
# print(password)
data = load_data('users.txt') # data is a list of [username, password]
pairs
login_successful = False
if not login_successful:
print("Username or Password is Incorrect\n")
def logout():
print("....Logging out...\n")
username = ""
password = ""
login_menu()
# Promotions
promotions = load_data('promotions.txt')
promotions.append([destination, discount, start_date, end_date])
save_promotions('promotions.txt', promotions)
promotions = load_data('promotions.txt')
updated_promotions = [promo for promo in promotions if promo[0].lower() !=
destination.lower()]
if len(promotions) == len(updated_promotions):
print(f"No promotion found for destination {destination}.\n")
else:
save_promotions('promotions.txt', updated_promotions)
print(f"Promotion for {destination} removed.\n")
if choice == "1":
view_promotions()
elif choice == "2":
add_promotion()
elif choice == "3":
remove_promotion()
elif choice == "4":
break
else:
print("Invalid choice, please try again.\n")
if not recommendations:
print("No recommendations available.\n")
else:
for recommendation in recommendations:
print(f"Destination: {recommendation[0]}")
print(f"Recommendation: {recommendation[1]}\n")
print("\n")
if not promotions:
print("No promotions available.\n")
else:
for promo in promotions:
print(f"Destination: {promo[0]}")
print(f"Discount: {promo[1]} (Valid From: {promo[2]} to {promo[3]})\n")
print("\n")
if choice == "1":
view_trip_recommendations()
elif choice == "2":
view_recommended_promotions()
elif choice == "3":
break
else:
print("Invalid choice, please try again.\n")
#
#
def save_travellers(filename, travellers):
with open(filename, 'w') as file:
for traveller in travellers:
file.write(','.join(traveller) + '\n')
if not traveller_found:
print(f"No traveller found with ID {traveller_id}.\n")
save_travellers('travellers.txt', travellers)
#
# Function to save merchant data
def save_merchants(filename, merchants):
with open(filename, 'w') as file:
for merchant in merchants:
file.write(','.join(merchant) + '\n')
if not merchant_found:
print(f"No merchant found with ID {merchant_id}.\n")
save_merchants('merchants.txt', merchants)
if choice == "1":
traveller_id = input("Enter traveller ID: ")
block_traveller(traveller_id)
elif choice == "2":
# merchant_id = input("Enter merchant ID: ")
add_merchant()
elif choice == "3":
merchant_id = input("Enter merchant ID: ")
block_merchant(merchant_id)
else:
print("Invalid choice.\n")
def main_menu(user):
while True:
print(f"\n======== Admin: {user[0]} ========\n") # Print username
print("1. Manage Users")
print("2. Manage Promotions")
print("3. View Trip Recommendations")
print("4. Logout")
choice = input("Enter your choice: ")
if choice == "1":
manage_users()
elif choice == "2":
manage_promotions() # Placeholder function
elif choice == "3":
trip_recommendations() # Placeholder function
elif choice == "4":
logout() # Placeholder function
break
else:
print("Invalid choice, please try again.\n")