Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase #95

Merged
merged 12 commits into from
Feb 7, 2024
5 changes: 4 additions & 1 deletion N_P_P.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from view_animals import view_animals
from common_functions import clear_screen, log_action, hash_password, get_mongodb_uri
from login import login
from client_database import client_database
from pymongo import MongoClient

get_mongodb_uri()
Expand Down Expand Up @@ -81,8 +82,10 @@ def main():
# Client Database
elif option == '2' and user_level >= 2:
log_action(current_user, "Entered 'Client Database'")
print("This feature is coming soon.")
time.sleep(2)
clear_screen()
client_database()


# Staff Portal
elif option == '3' and user_level == 3:
Expand Down
7 changes: 6 additions & 1 deletion add_animal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
from colorama import Fore, Style
from common_functions import clear_screen, log_action, get_mongodb_uri
from common_functions import clear_screen, log_action, get_mongodb_uri, print_animal_table, load_animal_data
from sudo_user import sudo_user
from pymongo import MongoClient

Expand All @@ -12,6 +12,9 @@
animals_collection = db['animals']

def add_animal():

animals = load_animal_data(animals_collection)

# Continuous loop for adding animals
while True:
clear_screen()
Expand All @@ -30,6 +33,8 @@ def add_animal():
if name.lower() == 'exit':
print("\nExiting..." + Style.RESET_ALL)
time.sleep(2)
clear_screen()
print_animal_table(animals)
break

species = input(Fore.GREEN + "Species: " + Style.RESET_ALL).strip().capitalize() # Capitalize the first letter
Expand Down
12 changes: 6 additions & 6 deletions admin_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import time
from colorama import Fore, Style
from common_functions import clear_screen, log_action
from register import register
from user_management import user_management

def admin_dashboard():
# Continuous loop for admin dashboard
while True:
clear_screen()
print(Fore.YELLOW + "\nADMIN Dashboard\n" + Style.RESET_ALL)
print("1. Register a new user")
print("2. User Management")
print(Fore.YELLOW + "\nADMIN Dashboard" + Style.RESET_ALL)
print("\n1. User Management")
print("2. Audit Logs")
print("3. Manage settings")
print("4. Logout")

option = input("\nPlease select an option: ")

# Check user input and perform corresponding action
if option == '1':
register()
elif option == '2':
user_management()
elif option == '2':
print("\nThis feature is under development.")
elif option == '3':
# ! Implement settings management
print("\nThis feature is under development.")
Expand Down
98 changes: 98 additions & 0 deletions client_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import time
from sudo_user import sudo_user
from colorama import Fore, Style
from common_functions import clear_screen
from customer_adoption_form_dog import adopt_dog_form

def modify_clint_database():
clear_screen()

print(Fore.CYAN + "\n📝 Modify Database 📝" + Style.RESET_ALL)
print("\n1. " + Fore.GREEN + "Add Client" + Style.RESET_ALL)
print("2. " + Fore.GREEN + "Modify Client" + Style.RESET_ALL)
print("3. " + Fore.GREEN + "Remove Client" + Style.RESET_ALL)
print("4. " + Fore.YELLOW + "Exit" + Style.RESET_ALL)

choice = input("\nPlease select an option: ")

if choice == '1':
adoption_form = input("\nOpen adoption form for dogs or cats? ")
if adoption_form not in ['dogs', 'cats']:
print(Fore.RED + "\nInvalid input. Please try again." + Style.RESET_ALL)
time.sleep(2)
clear_screen()
modify_clint_database()

if adoption_form == 'dogs':
print("\n Opening dog adoption form...")
time.sleep(2)
clear_screen()
adopt_dog_form()

elif adoption_form == 'cats':
print("\nThis feature is coming soon.")
time.sleep(2)
clear_screen()

elif choice == '2':
print("\nThis feature is coming soon.")
time.sleep(2)
clear_screen()

elif choice == '3':
print("\nThis feature is coming soon.")
time.sleep(2)
clear_screen()

elif choice == '4':
print("\nExiting Modify Database...")
time.sleep(1)
clear_screen()
return

else:
print(Fore.RED + "Invalid input. Please try again." + Style.RESET_ALL)
time.sleep(2)
clear_screen()
modify_clint_database()

def client_database():

clear_screen()

sudo_user()

print(Fore.CYAN + "\n🧑 Client Database 🧑" + Style.RESET_ALL)
print("\n1. " + Fore.GREEN + "🔍 Search" + Style.RESET_ALL)
print("2. " + Fore.GREEN + "📝 Modify Database" + Style.RESET_ALL)
print("3. " + Fore.GREEN + "📁 Export Database" + Style.RESET_ALL)
print("4. " + Fore.YELLOW + "🔐 Exit" + Style.RESET_ALL)
choice = input("\nPlease select an option: ")

if choice == '1':
print("This feature is coming soon.")
time.sleep(2)
clear_screen()

elif choice == '2':
time.sleep(1)
clear_screen()
modify_clint_database()

elif choice == '3':
print("This feature is coming soon.")
time.sleep(2)
clear_screen()

elif choice == '4':
print("Exiting Client Database...")
time.sleep(1)
clear_screen()
return

else:
print(Fore.RED + "\nInvalid input. Please try again." + Style.RESET_ALL)
time.sleep(2)
clear_screen()
client_database()

17 changes: 12 additions & 5 deletions common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import datetime
import configparser
import subprocess
import time
from colorama import Fore, Style

def clear_screen():
Expand Down Expand Up @@ -80,15 +81,21 @@ def get_mongodb_uri():
with open(config_file, 'w') as configfile:
config.write(configfile)
return uri

def get_input(prompt):
while True:
value = input(prompt)
if value: # if the string is not empty
return value
else:
print(Fore.RED + "\nThis field cannot be left blank. Please try again." + Style.RESET_ALL)
time.sleep(2)


#! One time use until proper implementation
# Function to print the table of animals
def print_animal_table(animals):
"""
Print a formatted table of animals with their attributes.
Args:
animals (dict): Dictionary containing animal data.
"""

# Print table header
print("\n🐾 " + Fore.CYAN + "List of Animals" + Style.RESET_ALL + " 🐾")
print("+-------------------------------------------------------------------------------------------+")
Expand Down
Loading
Loading