Compare commits
21 Commits
e1411e5890
...
main
Author | SHA1 | Date | |
---|---|---|---|
651d7e198c | |||
ba3da19b69 | |||
309d60e3d7 | |||
9bd0825a66 | |||
cc8e861859 | |||
94d13bb245 | |||
e184874163 | |||
f9dcf49ae1 | |||
0fc26b1900 | |||
159792c008 | |||
1f61f877fe | |||
048eea106e | |||
274549f04b | |||
8a09d27bf4 | |||
6398dcdf1b | |||
155a86ab06 | |||
87229a654e | |||
879ee79a90 | |||
2da5591e0e | |||
93796f613a | |||
b56b687f73 |
@@ -1,13 +0,0 @@
|
||||
from models.database import Database
|
||||
from models.user import User
|
||||
|
||||
class Auth:
|
||||
def check_auth(username, password):
|
||||
if username == "superadmin" and password == "Admin321!":
|
||||
su_user = User(None, -1, "superadmin", "", "", "", "", "", "", "", "", "SUPER_ADMIN")
|
||||
return su_user
|
||||
|
||||
user = User(Database.connection, None, username)
|
||||
if user.load_by_username() and user.password == password:
|
||||
return user
|
||||
return None
|
@@ -1,69 +0,0 @@
|
||||
from models.database import Database
|
||||
from models.user import User
|
||||
|
||||
class Search:
|
||||
@staticmethod
|
||||
def search_members(query):
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("""
|
||||
SELECT * FROM users WHERE
|
||||
id LIKE ? OR
|
||||
username LIKE ? OR
|
||||
firstname LIKE ? OR
|
||||
lastname LIKE ? OR
|
||||
email LIKE ? OR
|
||||
phone LIKE ?
|
||||
""", (f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%"))
|
||||
rows = cur.fetchall()
|
||||
|
||||
payload = []
|
||||
for row in rows:
|
||||
user = User(Database.connection)._set_row_values(row)
|
||||
if user.role == "MEMBER":
|
||||
payload.append(user)
|
||||
|
||||
return payload
|
||||
|
||||
@staticmethod
|
||||
def search_advisors(query):
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("""
|
||||
SELECT * FROM users WHERE
|
||||
id LIKE ? OR
|
||||
username LIKE ? OR
|
||||
firstname LIKE ? OR
|
||||
lastname LIKE ? OR
|
||||
email LIKE ? OR
|
||||
phone LIKE ?
|
||||
""", (f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%"))
|
||||
rows = cur.fetchall()
|
||||
|
||||
payload = []
|
||||
for row in rows:
|
||||
user = User(Database.connection)._set_row_values(row)
|
||||
if user.role == "ADVISOR":
|
||||
payload.append(user)
|
||||
|
||||
return payload
|
||||
|
||||
@staticmethod
|
||||
def search_admins(query):
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("""
|
||||
SELECT * FROM users WHERE
|
||||
id LIKE ? OR
|
||||
username LIKE ? OR
|
||||
firstname LIKE ? OR
|
||||
lastname LIKE ? OR
|
||||
email LIKE ? OR
|
||||
phone LIKE ?
|
||||
""", (f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%", f"%{query}%"))
|
||||
rows = cur.fetchall()
|
||||
|
||||
payload = []
|
||||
for row in rows:
|
||||
user = User(Database.connection)._set_row_values(row)
|
||||
if user.role == "SYSTEM_ADMIN":
|
||||
payload.append(user)
|
||||
|
||||
return payload
|
@@ -1,7 +0,0 @@
|
||||
|
||||
import os
|
||||
|
||||
class Utils:
|
||||
@staticmethod
|
||||
def clear_screen():
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
@@ -2,7 +2,7 @@ from venv import create
|
||||
from models.utils import DatabaseUtils
|
||||
from models.database import Database
|
||||
from services.search import Search
|
||||
from ui.input_menu import InputMenu, EMAIL_VALIDATOR
|
||||
from ui.input_menu import InputMenu
|
||||
from views.login_menu import LoginMenu
|
||||
from services.log import LogService
|
||||
|
||||
@@ -11,8 +11,4 @@ def main():
|
||||
DatabaseUtils.init_city_data()
|
||||
LoginMenu.display()
|
||||
|
||||
# test = InputMenu("test")
|
||||
# test.add_option("EMAIL", "email", "STR", "nick.leeman@hotmail.com", 0, 40, EMAIL_VALIDATOR)
|
||||
# test.do_input()
|
||||
# print(test.get_value("EMAIL"))
|
||||
main()
|
@@ -1,7 +1,7 @@
|
||||
import sqlite3
|
||||
|
||||
class City:
|
||||
def __init__(self, connection : sqlite3.Connection, id, name):
|
||||
def __init__(self, connection : sqlite3.Connection, id = None, name = None):
|
||||
self.connection = connection
|
||||
self.id = id
|
||||
self.name = name
|
||||
@@ -55,7 +55,7 @@ class City:
|
||||
|
||||
def delete(self):
|
||||
cur = self.connection.cursor()
|
||||
cur.execute("""DELETE FROM logs WHERE id = ?""", (self.id))
|
||||
cur.execute("""DELETE FROM cities WHERE id = ?""", (self.id))
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
return True
|
||||
@@ -63,3 +63,4 @@ class City:
|
||||
def _set_row_values(self, row):
|
||||
self.id = row[0]
|
||||
self.name = row[1]
|
||||
return self
|
@@ -16,6 +16,14 @@ class Database:
|
||||
Database._init_user_table()
|
||||
Database._init_city_table()
|
||||
|
||||
@staticmethod
|
||||
def delete_tables():
|
||||
cursor = Database.connection.cursor()
|
||||
cursor.execute("DROP TABLE logs")
|
||||
cursor.execute("DROP TABLE users")
|
||||
cursor.execute("DROP TABLE cities")
|
||||
cursor.close()
|
||||
|
||||
@staticmethod
|
||||
def _init_log_table():
|
||||
cursor = Database.connection.cursor()
|
@@ -1,5 +1,5 @@
|
||||
import sqlite3
|
||||
|
||||
from services.encryption import Encryption
|
||||
|
||||
class Log:
|
||||
def __init__(self, connection : sqlite3.Connection, id = None, username = None, date = None, time = None, description = None, additional_information = None, suspicious = None):
|
||||
@@ -26,26 +26,11 @@ class Log:
|
||||
|
||||
def save(self):
|
||||
cur = self.connection.cursor()
|
||||
|
||||
cur.execute("""
|
||||
INSERT INTO logs
|
||||
(id, username, date, time, description, additional_information, suspicious) VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
""", (self.id, self.username, self.date, self.time, self.description, self.additional_information, self.suspicious))
|
||||
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
return True
|
||||
|
||||
def update(self):
|
||||
cur = self.connection.cursor()
|
||||
cur.execute("""
|
||||
UPDATE logs SET
|
||||
username = ?,
|
||||
date = ?,
|
||||
description = ?,
|
||||
additional_information = ?,
|
||||
suspicious = ?
|
||||
WHERE id = ?
|
||||
""", (self.firstname, self.lastname, self.zipcode, self.city_id, self.email, self.phone, self.password, self.role, self.id))
|
||||
""", (self.id, Encryption.encrypt(self.username), Encryption.encrypt(self.date), Encryption.encrypt(self.time), Encryption.encrypt(self.description), Encryption.encrypt(self.additional_information), self.suspicious))
|
||||
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
@@ -60,9 +45,10 @@ class Log:
|
||||
|
||||
def _set_row_values(self, row):
|
||||
self.id = row[0]
|
||||
self.username = row[1]
|
||||
self.date = row[2]
|
||||
self.time = row[3]
|
||||
self.description = row[4]
|
||||
self.additional_information = row[5]
|
||||
self.username = Encryption.decrypt(row[1])
|
||||
self.date = Encryption.decrypt(row[2])
|
||||
self.time = Encryption.decrypt(row[3])
|
||||
self.description = Encryption.decrypt(row[4])
|
||||
self.additional_information = Encryption.decrypt(row[5])
|
||||
self.suspicious = row[6]
|
||||
return self
|
@@ -1,5 +1,7 @@
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
from models.database import Database
|
||||
from services.encryption import Encryption
|
||||
|
||||
class User:
|
||||
def __init__(self, connection : sqlite3.Connection, id = None, username = None, firstname = None, lastname = None, address = None, zipcode = None, city_id = None, email = None, phone = None, password = None, role = None):
|
||||
@@ -30,15 +32,21 @@ class User:
|
||||
|
||||
def load_by_username(self):
|
||||
cur = self.connection.cursor()
|
||||
row = cur.execute("SELECT * FROM users WHERE username = ?", (self.username,)).fetchone()
|
||||
|
||||
if row == None:
|
||||
return False
|
||||
rows = cur.execute("SELECT * FROM users").fetchall()
|
||||
|
||||
found_user = None
|
||||
for row in rows:
|
||||
user = User(Database.connection)._set_row_values(row)
|
||||
if user.username == self.username:
|
||||
self._set_row_values(row)
|
||||
found_user = user
|
||||
break
|
||||
|
||||
cur.close()
|
||||
if found_user:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def save(self):
|
||||
cur = self.connection.cursor()
|
||||
@@ -46,7 +54,7 @@ class User:
|
||||
cur.execute("""
|
||||
INSERT INTO users
|
||||
(id, username, firstname, lastname, address, zipcode, city_id, email, phone, password, role, created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (self.id, self.username, self.firstname, self.lastname, self.address, self.zipcode, self.city_id, self.email, self.phone, self.password, self.role, current_date))
|
||||
""", (self.id, Encryption.encrypt(self.username), Encryption.encrypt(self.firstname), Encryption.encrypt(self.lastname), Encryption.encrypt(self.address), Encryption.encrypt(self.zipcode), self.city_id, Encryption.encrypt(self.email), Encryption.encrypt(self.phone), Encryption.encrypt(self.password), Encryption.encrypt(self.role), current_date))
|
||||
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
@@ -67,7 +75,7 @@ class User:
|
||||
password = ?,
|
||||
role = ?
|
||||
WHERE id = ?
|
||||
""", (self.username, self.firstname, self.lastname, self.address, self.zipcode, self.city_id, self.email, self.phone, self.password, self.role, self.id))
|
||||
""", (Encryption.encrypt(self.username), Encryption.encrypt(self.firstname), Encryption.encrypt(self.lastname), Encryption.encrypt(self.address), Encryption.encrypt(self.zipcode), self.city_id, Encryption.encrypt(self.email), Encryption.encrypt(self.phone), Encryption.encrypt(self.password), self.role, self.id))
|
||||
|
||||
self.connection.commit()
|
||||
cur.close()
|
||||
@@ -82,15 +90,15 @@ class User:
|
||||
|
||||
def _set_row_values(self, row):
|
||||
self.id = row[0]
|
||||
self.username = row[1]
|
||||
self.firstname = row[2]
|
||||
self.lastname = row[3]
|
||||
self.address = row[4]
|
||||
self.zipcode = row[5]
|
||||
self.username = Encryption.decrypt(row[1])
|
||||
self.firstname = Encryption.decrypt(row[2])
|
||||
self.lastname = Encryption.decrypt(row[3])
|
||||
self.address = Encryption.decrypt(row[4])
|
||||
self.zipcode = Encryption.decrypt(row[5])
|
||||
self.city_id = row[6]
|
||||
self.email = row[7]
|
||||
self.phone = row[8]
|
||||
self.password = row[9]
|
||||
self.role = row[10]
|
||||
self.email = Encryption.decrypt(row[7])
|
||||
self.phone = Encryption.decrypt(row[8])
|
||||
self.password = Encryption.decrypt(row[9])
|
||||
self.role = Encryption.decrypt(row[10])
|
||||
self.created = row[11]
|
||||
return self
|
28
src/services/auth.py
Normal file
28
src/services/auth.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from models.database import Database
|
||||
from models.user import User
|
||||
from services.log import LogService
|
||||
|
||||
class Auth:
|
||||
failed_attempts = 0
|
||||
|
||||
@staticmethod
|
||||
def check_auth(username, password):
|
||||
if username == "superadmin" and password == "Admin321!":
|
||||
su_user = User(None, -1, "superadmin", "", "", "", "", "", "", "", "", "SUPER_ADMIN")
|
||||
LogService.create_log(username, "Logged in", "", False)
|
||||
Auth.failed_attempts = 0
|
||||
return su_user
|
||||
|
||||
user = User(Database.connection, None, username)
|
||||
if user.load_by_username() and user.password == password:
|
||||
LogService.create_log(username, "Logged in", "", False)
|
||||
Auth.failed_attempts = 0
|
||||
return user
|
||||
|
||||
if Auth.failed_attempts >= 3:
|
||||
LogService.create_log(username, "Multiple unsuccessful logins", "", True)
|
||||
else:
|
||||
LogService.create_log(username, "Unsuccessful login", f"Attempts: {Auth.failed_attempts}", False)
|
||||
|
||||
Auth.failed_attempts += 1
|
||||
return None
|
@@ -1,4 +1,6 @@
|
||||
class Encryption:
|
||||
ENCRYTPION_KEY = "MASTER_KEY"
|
||||
|
||||
@staticmethod
|
||||
def vigenere(text: str, key: str, encrypt=True):
|
||||
result = ''
|
||||
@@ -17,9 +19,9 @@ class Encryption:
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def encrypt(text: str, key: str):
|
||||
return Encryption.vigenere(text=text, key=key, encrypt=True)
|
||||
def encrypt(text: str):
|
||||
return Encryption.vigenere(text=text, key=Encryption.ENCRYTPION_KEY, encrypt=True)
|
||||
|
||||
@staticmethod
|
||||
def decrypt(text: str, key: str):
|
||||
return Encryption.vigenere(text=text, key=key, encrypt=False)
|
||||
def decrypt(text: str):
|
||||
return Encryption.vigenere(text=text, key=Encryption.ENCRYTPION_KEY, encrypt=False)
|
@@ -5,10 +5,21 @@ from models.database import Database
|
||||
|
||||
class LogService:
|
||||
@staticmethod
|
||||
def createlog(username, description, additional_information, suspicious):
|
||||
def create_log(username, description, additional_information, suspicious):
|
||||
now = datetime.now()
|
||||
date_string = now.strftime("%d-%m-%Y")
|
||||
time_string = now.strftime("%H:%M:%S")
|
||||
new_log = Log(Database.connection, None, username, date_string, time_string, description, additional_information, suspicious)
|
||||
|
||||
new_log.save()
|
||||
|
||||
@staticmethod
|
||||
def get_latest_logs():
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("SELECT * FROM logs ORDER BY id DESC LIMIT 100;")
|
||||
rows = cur.fetchall()
|
||||
logs = []
|
||||
for row in rows:
|
||||
log = Log(Database.connection)._set_row_values(row)
|
||||
logs.append(log)
|
||||
return logs
|
74
src/services/search.py
Normal file
74
src/services/search.py
Normal file
@@ -0,0 +1,74 @@
|
||||
from models.database import Database
|
||||
from models.user import User
|
||||
from models.city import City
|
||||
|
||||
class Search:
|
||||
@staticmethod
|
||||
def search_members(query):
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("""SELECT * FROM users""")
|
||||
rows = cur.fetchall()
|
||||
|
||||
payload = []
|
||||
for row in rows:
|
||||
user = User(Database.connection)._set_row_values(row)
|
||||
if str(user.id) == query:
|
||||
payload.append(user)
|
||||
continue
|
||||
|
||||
if user.role == "MEMBER":
|
||||
if user.username in query or user.firstname in query or user.lastname in query or user.email in query or user.phone in query:
|
||||
payload.append(user)
|
||||
|
||||
return payload
|
||||
|
||||
@staticmethod
|
||||
def search_advisors(query):
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("""SELECT * FROM users""")
|
||||
rows = cur.fetchall()
|
||||
|
||||
payload = []
|
||||
for row in rows:
|
||||
user = User(Database.connection)._set_row_values(row)
|
||||
if str(user.id) == user.id:
|
||||
payload.append(user)
|
||||
continue
|
||||
|
||||
if user.role == "ADVISOR":
|
||||
if user.username in query or user.firstname in query or user.lastname in query or user.email in query or user.phone in query:
|
||||
payload.append(user)
|
||||
|
||||
return payload
|
||||
|
||||
@staticmethod
|
||||
def search_admins(query):
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("""SELECT * FROM users""")
|
||||
rows = cur.fetchall()
|
||||
|
||||
payload = []
|
||||
for row in rows:
|
||||
user = User(Database.connection)._set_row_values(row)
|
||||
if str(user.id) == user.id:
|
||||
payload.append(user)
|
||||
continue
|
||||
|
||||
if user.role == "SYSTEM_ADMIN":
|
||||
if user.username in query or user.firstname in query or user.lastname in query or user.email in query or user.phone in query:
|
||||
payload.append(user)
|
||||
|
||||
return payload
|
||||
|
||||
@staticmethod
|
||||
def get_all_cites():
|
||||
cur = Database.connection.cursor()
|
||||
cur.execute("SELECT * FROM cities")
|
||||
rows = cur.fetchall()
|
||||
|
||||
payload = []
|
||||
for row in rows:
|
||||
city = City(Database.connection)._set_row_values(row)
|
||||
payload.append(city)
|
||||
|
||||
return payload
|
@@ -1,4 +1,3 @@
|
||||
from ast import Import
|
||||
from models.user import User
|
||||
|
||||
class State:
|
31
src/services/utils.py
Normal file
31
src/services/utils.py
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
import os
|
||||
from zipfile import ZipFile
|
||||
|
||||
from models.database import Database
|
||||
|
||||
class Utils:
|
||||
@staticmethod
|
||||
def clear_screen():
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
|
||||
@staticmethod
|
||||
def export_db():
|
||||
with open(f"./backup.sql", 'w') as f:
|
||||
for line in Database.connection.iterdump():
|
||||
f.write('%s\n' % line)
|
||||
|
||||
with ZipFile("backup.zip", "w") as zip:
|
||||
zip.write("backup.sql")
|
||||
|
||||
os.remove("./backup.sql")
|
||||
|
||||
@staticmethod
|
||||
def import_db():
|
||||
with ZipFile("backup.zip", 'r') as zip:
|
||||
zip.extractall("./")
|
||||
with open(f"./backup.sql", 'r') as f:
|
||||
str = f.read()
|
||||
Database.connection.executescript(str)
|
||||
|
||||
os.remove("./backup.sql")
|
@@ -34,6 +34,11 @@ class Validator:
|
||||
regex = re.compile(r'^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,31}$')
|
||||
return re.fullmatch(regex, input)
|
||||
|
||||
@staticmethod
|
||||
def check_postcode(input):
|
||||
regex = re.compile(r'\b\d{4}[A-Z]{2}\b')
|
||||
return re.fullmatch(regex, input)
|
||||
|
||||
class InputMenu:
|
||||
|
||||
def __init__(self, title):
|
@@ -1,7 +1,8 @@
|
||||
|
||||
from click import edit
|
||||
from models.database import Database
|
||||
from models.user import User
|
||||
from services.state import State
|
||||
from services.log import LogService
|
||||
from services.search import Search
|
||||
from ui.input_menu import InputMenu, Validator
|
||||
from ui.selection_menu import SelectionMenu
|
||||
@@ -43,6 +44,16 @@ class AdvisorMenu:
|
||||
|
||||
return users[select_form.get_value("INDEX")]
|
||||
|
||||
@staticmethod
|
||||
def select_city():
|
||||
menu = SelectionMenu("Select City")
|
||||
|
||||
cities = Search.get_all_cites()
|
||||
for city in cities:
|
||||
menu.add_option(city.name, city.id)
|
||||
|
||||
option = menu.display().input_option()
|
||||
return option
|
||||
|
||||
@staticmethod
|
||||
def add_advisor():
|
||||
@@ -51,13 +62,14 @@ class AdvisorMenu:
|
||||
form.add_option("FIRSTNAME", "Firstname", "STR", None, 1, 250, None)
|
||||
form.add_option("LASTNAME", "Lastname", "STR", None, 1, 250, None)
|
||||
form.add_option("ADDRESS", "Address", "STR", None, 1, 250, None)
|
||||
form.add_option("ZIPCODE", "Zipcode", "STR", None, 6, 6, None)
|
||||
form.add_option("CITY_ID", "City", "STR", None, 1, 250, None)
|
||||
form.add_option("ZIPCODE", "Zipcode", "STR", None, 6, 6, Validator.check_postcode)
|
||||
form.add_option("EMAIL", "Email", "STR", None, 1, 250, Validator.check_email)
|
||||
form.add_option("PHONE", "Phone (+31-6)", "STR", None, 8, 8, None)
|
||||
form.add_option("PASSWORD", "Password", "STR", None, 1, 255, Validator.check_password)
|
||||
form.do_input()
|
||||
|
||||
city_id = AdvisorMenu.select_city()
|
||||
|
||||
new_user = User(Database.connection,
|
||||
None,
|
||||
form.get_value("USERNAME"),
|
||||
@@ -65,7 +77,7 @@ class AdvisorMenu:
|
||||
form.get_value("LASTNAME"),
|
||||
form.get_value("ADDRESS"),
|
||||
form.get_value("ZIPCODE"),
|
||||
form.get_value("CITY_ID"),
|
||||
city_id,
|
||||
form.get_value("EMAIL"),
|
||||
"+31-6" + form.get_value("PHONE"),
|
||||
form.get_value("PASSWORD"),
|
||||
@@ -73,6 +85,7 @@ class AdvisorMenu:
|
||||
)
|
||||
|
||||
new_user.save()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Created advisor", f"Advisor: {new_user.username}", True)
|
||||
input("Added new Advisor! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
@@ -84,29 +97,51 @@ class AdvisorMenu:
|
||||
edit_form.add_option("FIRSTNAME", "Firstname", "STR", user.firstname, 1, 250, None)
|
||||
edit_form.add_option("LASTNAME", "Lastname", "STR", user.lastname, 1, 250, None)
|
||||
edit_form.add_option("ADDRESS", "Address", "STR", user.address, 1, 250, None)
|
||||
edit_form.add_option("ZIPCODE", "Zipcode", "STR", user.zipcode, 6, 6, None)
|
||||
edit_form.add_option("CITY_ID", "City", "STR", user.city_id, 1, 250, None)
|
||||
edit_form.add_option("ZIPCODE", "Zipcode", "STR", user.zipcode, 6, 6, Validator.check_postcode)
|
||||
edit_form.add_option("EMAIL", "Email", "STR", user.email, 1, 250, Validator.check_email)
|
||||
edit_form.add_option("PHONE", "Phone (+31-6)", "STR", user.phone, 8, 8, None)
|
||||
edit_form.add_option("PASSWORD", "Password", "STR", user.phone, 1, 255, Validator.check_password)
|
||||
edit_form.do_input()
|
||||
|
||||
select_menu = SelectionMenu("Do want to change the city?")
|
||||
select_menu.add_option("No", False).add_option("Yes", True).display()
|
||||
change_city = select_menu.input_option()
|
||||
if change_city:
|
||||
user.city_id = AdvisorMenu.select_city()
|
||||
|
||||
user.username = edit_form.get_value("USERNAME")
|
||||
user.firstname = edit_form.get_value("FIRSTNAME")
|
||||
user.lastname = edit_form.get_value("LASTNAME")
|
||||
user.address = edit_form.get_value("ADDRESS")
|
||||
user.zipcode = edit_form.get_value("ZIPCODE")
|
||||
user.city_id = edit_form.get_value("CITY_ID")
|
||||
user.email = edit_form.get_value("EMAIL")
|
||||
user.phone = edit_form.get_value("PHONE")
|
||||
user.password = edit_form.get_value("PASSWORD")
|
||||
|
||||
user.update()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Updated advisor", f"Advisor: {user.username}", True)
|
||||
input("Updated Advisor! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
def update_password_advisor():
|
||||
user = AdvisorMenu.search_advisor(False)
|
||||
if user == None:
|
||||
input("Advisor not found. Press any key to continue.")
|
||||
return
|
||||
|
||||
form = InputMenu("Update password")
|
||||
form.add_option("PASSWORD", "Password", "STR", None, 1, 255, Validator.check_password)
|
||||
form.do_input()
|
||||
user.password = form.get_value("PASSWORD")
|
||||
user.update()
|
||||
|
||||
LogService.create_log(State.CURRENT_USER.username, "Updated password of advisor", f"Advisor: {user.username}", True)
|
||||
input("Updated Advisor Password! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
def remove_advisor():
|
||||
user = AdvisorMenu.search_advisor(False)
|
||||
if user == None:
|
||||
input("Advisor not found. Press any key to continue.")
|
||||
return
|
||||
|
||||
confirm = SelectionMenu("Do you want to delete selected Advisor?")
|
||||
confirm.add_option("Yes", True).add_option("No", False).display()
|
||||
@@ -114,8 +149,9 @@ class AdvisorMenu:
|
||||
|
||||
if option == True:
|
||||
user.delete()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Deleted advisor", f"Advisor: {user.username}", True)
|
||||
input("Deleted Advisor! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
def browse_advisor():
|
||||
AdvisorMenu.search_member(True)
|
||||
AdvisorMenu.search_advisor(True)
|
32
src/views/backup_menu.py
Normal file
32
src/views/backup_menu.py
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
from os import path
|
||||
from models.database import Database
|
||||
from models.user import User
|
||||
from services.search import Search
|
||||
from services.utils import Utils
|
||||
from ui.input_menu import InputMenu, Validator
|
||||
from ui.selection_menu import SelectionMenu
|
||||
|
||||
class BackupMenu:
|
||||
@staticmethod
|
||||
def create_backup():
|
||||
print(f"Exporting database to file: backup.zip")
|
||||
Utils.export_db()
|
||||
input(f"Exported database. Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
def import_backup():
|
||||
menu = SelectionMenu("Import Backup? This will delete current database!")
|
||||
menu.add_option("Yes", True)
|
||||
menu.add_option("No", False)
|
||||
option = menu.display().input_option()
|
||||
|
||||
if option == False:
|
||||
return
|
||||
|
||||
print("Cleared current database.")
|
||||
Database.delete_tables()
|
||||
|
||||
print(f"Importing database from file: backup.zip")
|
||||
Utils.import_db()
|
||||
input(f"Imported database. Press any key to return.")
|
@@ -12,7 +12,7 @@ class LoginMenu:
|
||||
while True:
|
||||
Utils.clear_screen()
|
||||
login_form = InputMenu("Login Into Furnicur Family System")
|
||||
login_form.add_option("USERNAME", "Username", "STR", "superadmin", 1, 250, None).add_option("PASSWORD", "Password", "STR", "Admin321!", 1, 250, None).do_input()
|
||||
login_form.add_option("USERNAME", "Username", "STR", "", 1, 250, None).add_option("PASSWORD", "Password", "STR", "", 1, 250, None).do_input()
|
||||
|
||||
user = Auth.check_auth(login_form.get_value("USERNAME"), login_form.get_value("PASSWORD"))
|
||||
if user:
|
145
src/views/main_menu.py
Normal file
145
src/views/main_menu.py
Normal file
@@ -0,0 +1,145 @@
|
||||
import os
|
||||
from services.state import State
|
||||
from services.utils import Utils
|
||||
from ui.input_menu import InputMenu, Validator
|
||||
from ui.selection_menu import SelectionMenu
|
||||
from views.advisor_menu import AdvisorMenu
|
||||
from views.backup_menu import BackupMenu
|
||||
from views.member_menu import MemberMenu
|
||||
from views.system_admin_menu import SystemAdminMenu
|
||||
from services.log import LogService
|
||||
class MainMenu:
|
||||
@staticmethod
|
||||
def display():
|
||||
while True:
|
||||
Utils.clear_screen()
|
||||
main_menu = SelectionMenu(f"Welcome {State.CURRENT_USER.username}!")
|
||||
|
||||
if State.CURRENT_USER.role == "ADVISOR" or State.CURRENT_USER.role == "SYSTEM_ADMIN":
|
||||
main_menu.add_option("Update My Password", MainMenu.update_password)
|
||||
main_menu.add_option("Manage Members", MainMenu.manage_members)
|
||||
else:
|
||||
main_menu.add_option("Manage Members", MainMenu.manage_members)
|
||||
|
||||
if State.CURRENT_USER.role == "SYSTEM_ADMIN" or State.CURRENT_USER.role == "SUPER_ADMIN":
|
||||
main_menu.add_option("Manage Advisors", MainMenu.manage_advisors)
|
||||
main_menu.add_option("View logs", MainMenu.check_logs)
|
||||
main_menu.add_option("Manage Backups", MainMenu.manage_backups)
|
||||
|
||||
if State.CURRENT_USER.role == "SUPER_ADMIN":
|
||||
main_menu.add_option("Manage Admins", MainMenu.manage_admins)
|
||||
|
||||
main_menu.add_option("Exit...", None)
|
||||
|
||||
selected_option = main_menu.display().input_option()
|
||||
if selected_option == None:
|
||||
exit(0)
|
||||
|
||||
selected_option()
|
||||
|
||||
@staticmethod
|
||||
def update_password():
|
||||
Utils.clear_screen()
|
||||
|
||||
menu = SelectionMenu(f"Do you want to update your own password?")
|
||||
menu.add_option("Yes", True)
|
||||
menu.add_option("No", False)
|
||||
|
||||
selected_option = menu.display().input_option()
|
||||
if selected_option == False:
|
||||
return
|
||||
|
||||
form = InputMenu("Set new password")
|
||||
form.add_option("PASSWORD", "Password", "STR", None, 1, 255, Validator.check_password)
|
||||
form.do_input()
|
||||
State.CURRENT_USER.password = form.get_value("PASSWORD")
|
||||
State.CURRENT_USER.update()
|
||||
|
||||
input("Current password updated! Press any key to continue.")
|
||||
|
||||
@staticmethod
|
||||
def manage_members():
|
||||
Utils.clear_screen()
|
||||
|
||||
menu = SelectionMenu(f"Manage Members")
|
||||
menu.add_option("Add Member", MemberMenu.add_member)
|
||||
menu.add_option("Edit Member", MemberMenu.edit_member)
|
||||
|
||||
if State.CURRENT_USER.role == "SYSTEM_ADMIN" or State.CURRENT_USER.role == "SUPER_ADMIN":
|
||||
menu.add_option("Remove Member", MemberMenu.remove_member)
|
||||
|
||||
menu.add_option("Browse Member", MemberMenu.browse_member)
|
||||
menu.add_option("Back to main menu", None)
|
||||
|
||||
selected_option = menu.display().input_option()
|
||||
if selected_option == None:
|
||||
return
|
||||
|
||||
selected_option()
|
||||
|
||||
@staticmethod
|
||||
def manage_advisors():
|
||||
Utils.clear_screen()
|
||||
|
||||
menu = SelectionMenu(f"Manage Advisors")
|
||||
menu.add_option("Add Advisor", AdvisorMenu.add_advisor)
|
||||
menu.add_option("Edit Advisor", AdvisorMenu.edit_advisor)
|
||||
menu.add_option("Reset Password Advisor", AdvisorMenu.update_password_advisor)
|
||||
menu.add_option("Remove Advisor", AdvisorMenu.remove_advisor)
|
||||
menu.add_option("Browse Advisor", AdvisorMenu.browse_advisor)
|
||||
menu.add_option("Back to main menu", None)
|
||||
|
||||
selected_option = menu.display().input_option()
|
||||
if selected_option == None:
|
||||
return
|
||||
|
||||
selected_option()
|
||||
|
||||
@staticmethod
|
||||
def manage_admins():
|
||||
Utils.clear_screen()
|
||||
|
||||
menu = SelectionMenu(f"Manage System Admins")
|
||||
menu.add_option("Add System Admin", SystemAdminMenu.add_admin)
|
||||
menu.add_option("Edit System Admin", SystemAdminMenu.edit_admin)
|
||||
menu.add_option("Reset Password System Admin", SystemAdminMenu.update_password_admin)
|
||||
menu.add_option("Remove System Admin", SystemAdminMenu.remove_admin)
|
||||
menu.add_option("Browse System Admin", SystemAdminMenu.browse_admins)
|
||||
menu.add_option("Back to main menu", None)
|
||||
|
||||
selected_option = menu.display().input_option()
|
||||
if selected_option == None:
|
||||
return
|
||||
|
||||
selected_option()
|
||||
|
||||
@staticmethod
|
||||
def manage_backups():
|
||||
Utils.clear_screen()
|
||||
|
||||
menu = SelectionMenu(f"Manage Backups")
|
||||
menu.add_option("Create Backup", BackupMenu.create_backup)
|
||||
menu.add_option("Import Backup", BackupMenu.import_backup)
|
||||
menu.add_option("Back to main menu", None)
|
||||
|
||||
selected_option = menu.display().input_option()
|
||||
if selected_option == None:
|
||||
return
|
||||
|
||||
selected_option()
|
||||
|
||||
@staticmethod
|
||||
def check_logs():
|
||||
Utils.clear_screen()
|
||||
|
||||
logs = LogService.get_latest_logs()
|
||||
for log in logs:
|
||||
print(f"/--[ {log.id} ]---------")
|
||||
print(f"| Username: {log.username}")
|
||||
print(f"| Description: {log.description}")
|
||||
print(f"| Additional Information: {log.additional_information}")
|
||||
print(f"| Suspicious: {log.suspicious}")
|
||||
print(f"| Date: {log.date} {log.time}")
|
||||
print(f"\-------------\n")
|
||||
|
||||
input("Press any key to continue.")
|
@@ -1,9 +1,10 @@
|
||||
|
||||
from click import edit
|
||||
from models.database import Database
|
||||
from models.user import User
|
||||
from services.state import State
|
||||
from services.log import LogService
|
||||
from services.search import Search
|
||||
from ui.input_menu import InputMenu, EMAIL_VALIDATOR
|
||||
from ui.input_menu import InputMenu, Validator
|
||||
from ui.selection_menu import SelectionMenu
|
||||
|
||||
|
||||
@@ -44,18 +45,30 @@ class MemberMenu:
|
||||
return users[select_form.get_value("INDEX")]
|
||||
|
||||
|
||||
@staticmethod
|
||||
def select_city():
|
||||
menu = SelectionMenu("Select City")
|
||||
|
||||
cities = Search.get_all_cites()
|
||||
for city in cities:
|
||||
menu.add_option(city.name, city.id)
|
||||
|
||||
option = menu.display().input_option()
|
||||
return option
|
||||
|
||||
@staticmethod
|
||||
def add_member():
|
||||
form = InputMenu("Add new Member")
|
||||
form.add_option("FIRSTNAME", "Firstname", "STR", None, 1, 250, None)
|
||||
form.add_option("LASTNAME", "Lastname", "STR", None, 1, 250, None)
|
||||
form.add_option("ADDRESS", "Address", "STR", None, 1, 250, None)
|
||||
form.add_option("ZIPCODE", "Zipcode", "STR", None, 6, 6, None)
|
||||
form.add_option("CITY_ID", "City", "STR", None, 1, 250, None)
|
||||
form.add_option("EMAIL", "Email", "STR", None, 1, 250, EMAIL_VALIDATOR)
|
||||
form.add_option("ZIPCODE", "Zipcode", "STR", None, 6, 6, Validator.check_postcode)
|
||||
form.add_option("EMAIL", "Email", "STR", None, 1, 250, Validator.check_email)
|
||||
form.add_option("PHONE", "Phone (+31-6)", "STR", None, 8, 8, None)
|
||||
form.do_input()
|
||||
|
||||
city_id = MemberMenu.select_city()
|
||||
|
||||
new_user = User(Database.connection,
|
||||
None,
|
||||
"",
|
||||
@@ -63,7 +76,7 @@ class MemberMenu:
|
||||
form.get_value("LASTNAME"),
|
||||
form.get_value("ADDRESS"),
|
||||
form.get_value("ZIPCODE"),
|
||||
form.get_value("CITY_ID"),
|
||||
city_id,
|
||||
form.get_value("EMAIL"),
|
||||
"+31-6" + form.get_value("PHONE"),
|
||||
"",
|
||||
@@ -71,6 +84,7 @@ class MemberMenu:
|
||||
)
|
||||
|
||||
new_user.save()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Added member", f"Member: {new_user.firstname} {new_user.lastname}", False)
|
||||
input("Added new Member! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
@@ -81,12 +95,17 @@ class MemberMenu:
|
||||
edit_form.add_option("FIRSTNAME", "Firstname", "STR", user.firstname, 1, 250, None)
|
||||
edit_form.add_option("LASTNAME", "Lastname", "STR", user.lastname, 1, 250, None)
|
||||
edit_form.add_option("ADDRESS", "Address", "STR", user.address, 1, 250, None)
|
||||
edit_form.add_option("ZIPCODE", "Zipcode", "STR", user.zipcode, 6, 6, None)
|
||||
edit_form.add_option("CITY_ID", "City", "STR", user.city_id, 1, 250, None)
|
||||
edit_form.add_option("EMAIL", "Email", "STR", user.email, 1, 250, EMAIL_VALIDATOR)
|
||||
edit_form.add_option("ZIPCODE", "Zipcode", "STR", user.zipcode, 6, 6, Validator.check_postcode)
|
||||
edit_form.add_option("EMAIL", "Email", "STR", user.email, 1, 250, Validator.check_email)
|
||||
edit_form.add_option("PHONE", "Phone (+31-6)", "STR", user.phone, 8, 8, None)
|
||||
edit_form.do_input()
|
||||
|
||||
select_menu = SelectionMenu("Do want to change the city?")
|
||||
select_menu.add_option("No", False).add_option("Yes", True).display()
|
||||
change_city = select_menu.input_option()
|
||||
if change_city:
|
||||
user.city_id = MemberMenu.select_city()
|
||||
|
||||
user.firstname = edit_form.get_value("FIRSTNAME")
|
||||
user.lastname = edit_form.get_value("LASTNAME")
|
||||
user.address = edit_form.get_value("ADDRESS")
|
||||
@@ -96,18 +115,23 @@ class MemberMenu:
|
||||
user.phone = edit_form.get_value("PHONE")
|
||||
|
||||
user.update()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Updated member", f"Member: {user.firstname} {user.lastname}", False)
|
||||
input("Updated Member! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
def remove_member():
|
||||
user = MemberMenu.search_member(False)
|
||||
|
||||
if user == None:
|
||||
return
|
||||
|
||||
confirm = SelectionMenu("Do you want to delete selected Member?")
|
||||
confirm.add_option("Yes", True).add_option("No", False).display()
|
||||
option = confirm.input_option()
|
||||
|
||||
if option == True:
|
||||
user.delete()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Removed member", f"Member: {user.firstname} {user.lastname}", False)
|
||||
input("Deleted Member! Press any key to return.")
|
||||
|
||||
@staticmethod
|
@@ -1,7 +1,8 @@
|
||||
|
||||
from click import edit
|
||||
from models.database import Database
|
||||
from models.user import User
|
||||
from services.state import State
|
||||
from services.log import LogService
|
||||
from services.search import Search
|
||||
from ui.input_menu import InputMenu, Validator
|
||||
from ui.selection_menu import SelectionMenu
|
||||
@@ -43,6 +44,16 @@ class SystemAdminMenu:
|
||||
|
||||
return users[select_form.get_value("INDEX")]
|
||||
|
||||
@staticmethod
|
||||
def select_city():
|
||||
menu = SelectionMenu("Select City")
|
||||
|
||||
cities = Search.get_all_cites()
|
||||
for city in cities:
|
||||
menu.add_option(city.name, city.id)
|
||||
|
||||
option = menu.display().input_option()
|
||||
return option
|
||||
|
||||
@staticmethod
|
||||
def add_admin():
|
||||
@@ -51,21 +62,22 @@ class SystemAdminMenu:
|
||||
form.add_option("FIRSTNAME", "Firstname", "STR", None, 1, 250, None)
|
||||
form.add_option("LASTNAME", "Lastname", "STR", None, 1, 250, None)
|
||||
form.add_option("ADDRESS", "Address", "STR", None, 1, 250, None)
|
||||
form.add_option("ZIPCODE", "Zipcode", "STR", None, 6, 6, None)
|
||||
form.add_option("CITY_ID", "City", "STR", None, 1, 250, None)
|
||||
form.add_option("ZIPCODE", "Zipcode", "STR", None, 6, 6, Validator.check_postcode)
|
||||
form.add_option("EMAIL", "Email", "STR", None, 1, 250, Validator.check_email)
|
||||
form.add_option("PHONE", "Phone (+31-6)", "STR", None, 8, 8, None)
|
||||
form.add_option("PASSWORD", "Password", "STR", None, 1, 255, Validator.check_password)
|
||||
form.do_input()
|
||||
|
||||
city_id = SystemAdminMenu.select_city()
|
||||
|
||||
new_user = User(Database.connection,
|
||||
None,
|
||||
"",
|
||||
form.get_value("USERNAME"),
|
||||
form.get_value("FIRSTNAME"),
|
||||
form.get_value("LASTNAME"),
|
||||
form.get_value("ADDRESS"),
|
||||
form.get_value("ZIPCODE"),
|
||||
form.get_value("CITY_ID"),
|
||||
city_id,
|
||||
form.get_value("EMAIL"),
|
||||
"+31-6" + form.get_value("PHONE"),
|
||||
form.get_value("PASSWORD"),
|
||||
@@ -73,37 +85,60 @@ class SystemAdminMenu:
|
||||
)
|
||||
|
||||
new_user.save()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Added system admin", f"System Admin: {new_user.username}", False)
|
||||
input("Added new system admin! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
def edit_admin():
|
||||
user = SystemAdminMenu.search_admins(False)
|
||||
if user == None:
|
||||
input("Admin not found. Press any key to continue.")
|
||||
return
|
||||
|
||||
edit_form = InputMenu("Edit System Admin (Leave fields empty to not change)")
|
||||
edit_form.add_option("Username", "Username", "STR", user.username, 1, 250, Validator.check_username)
|
||||
edit_form.add_option("USERNAME", "Username", "STR", user.username, 1, 250, Validator.check_username)
|
||||
edit_form.add_option("FIRSTNAME", "Firstname", "STR", user.firstname, 1, 250, None)
|
||||
edit_form.add_option("LASTNAME", "Lastname", "STR", user.lastname, 1, 250, None)
|
||||
edit_form.add_option("ADDRESS", "Address", "STR", user.address, 1, 250, None)
|
||||
edit_form.add_option("ZIPCODE", "Zipcode", "STR", user.zipcode, 6, 6, None)
|
||||
edit_form.add_option("CITY_ID", "City", "STR", user.city_id, 1, 250, None)
|
||||
edit_form.add_option("ZIPCODE", "Zipcode", "STR", user.zipcode, 6, 6, Validator.check_postcode)
|
||||
edit_form.add_option("EMAIL", "Email", "STR", user.email, 1, 250, Validator.check_email)
|
||||
edit_form.add_option("PHONE", "Phone (+31-6)", "STR", user.phone, 8, 8, None)
|
||||
edit_form.add_option("PASSWORD", "Password", "STR", user.phone, 1, 255, Validator.check_password)
|
||||
edit_form.do_input()
|
||||
|
||||
select_menu = SelectionMenu("Do want to change the city?")
|
||||
select_menu.add_option("No", False).add_option("Yes", True).display()
|
||||
change_city = select_menu.input_option()
|
||||
if change_city:
|
||||
user.city_id = SystemAdminMenu.select_city()
|
||||
|
||||
user.username = edit_form.get_value("USERNAME")
|
||||
user.firstname = edit_form.get_value("FIRSTNAME")
|
||||
user.lastname = edit_form.get_value("LASTNAME")
|
||||
user.address = edit_form.get_value("ADDRESS")
|
||||
user.zipcode = edit_form.get_value("ZIPCODE")
|
||||
user.city_id = edit_form.get_value("CITY_ID")
|
||||
user.email = edit_form.get_value("EMAIL")
|
||||
user.phone = edit_form.get_value("PHONE")
|
||||
user.password = edit_form.get_value("PASSWORD")
|
||||
|
||||
user.update()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Updated system admin", f"System Admin: {user.username}", False)
|
||||
input("Updated System Admin! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
def update_password_admin():
|
||||
user = SystemAdminMenu.search_admins(False)
|
||||
if user == None:
|
||||
input("Admin not found. Press any key to continue.")
|
||||
return
|
||||
|
||||
form = InputMenu("Update password")
|
||||
form.add_option("PASSWORD", "Password", "STR", None, 1, 255, Validator.check_password)
|
||||
form.do_input()
|
||||
user.password = form.get_value("PASSWORD")
|
||||
user.update()
|
||||
|
||||
LogService.create_log(State.CURRENT_USER.username, "Updated password system admin", f"System Admin: {user.username}", False)
|
||||
input("Updated System Admin password! Press any key to return.")
|
||||
|
||||
@staticmethod
|
||||
def remove_admin():
|
||||
user = SystemAdminMenu.search_admins(False)
|
||||
@@ -114,6 +149,7 @@ class SystemAdminMenu:
|
||||
|
||||
if option == True:
|
||||
user.delete()
|
||||
LogService.create_log(State.CURRENT_USER.username, "Removed system admin", f"System Admin: {user.username}", False)
|
||||
input("Deleted advisor! Press any key to return.")
|
||||
|
||||
@staticmethod
|
@@ -1,86 +0,0 @@
|
||||
import os
|
||||
from services.state import State
|
||||
from services.utils import Utils
|
||||
from ui.selection_menu import SelectionMenu
|
||||
from views.member_menu import MemberMenu
|
||||
from views.system_admin_menu import SystemAdminMenu
|
||||
|
||||
class MainMenu:
|
||||
@staticmethod
|
||||
def display():
|
||||
while True:
|
||||
Utils.clear_screen()
|
||||
main_menu = SelectionMenu(f"Welcome {State.CURRENT_USER.username}!")
|
||||
|
||||
if State.CURRENT_USER.role == "ADVISOR" or State.CURRENT_USER.role == "SYSTEM_ADMIN":
|
||||
main_menu.add_option("Update My Password", None)
|
||||
main_menu.add_option("Manage Members", MainMenu.manage_members)
|
||||
else:
|
||||
main_menu.add_option("Manage Members", MainMenu.manage_members)
|
||||
|
||||
if State.CURRENT_USER.role == "SYSTEM_ADMIN" or State.CURRENT_USER.role == "SUPER_ADMIN":
|
||||
main_menu.add_option("Manage Advisors", MainMenu.manage_advisors)
|
||||
|
||||
if State.CURRENT_USER.role == "SUPER_ADMIN":
|
||||
main_menu.add_option("Manage Admins", MainMenu.manage_admins)
|
||||
|
||||
main_menu.add_option("Exit...", None)
|
||||
|
||||
selected_option = main_menu.display().input_option()
|
||||
if selected_option == None:
|
||||
exit(0)
|
||||
|
||||
selected_option()
|
||||
|
||||
@staticmethod
|
||||
def manage_members():
|
||||
Utils.clear_screen()
|
||||
|
||||
menu = SelectionMenu(f"Manage Members")
|
||||
menu.add_option("Add Member", MemberMenu.add_member)
|
||||
menu.add_option("Edit Member", MemberMenu.edit_member)
|
||||
menu.add_option("Remove Member", MemberMenu.remove_member)
|
||||
menu.add_option("Browse Member", MemberMenu.browse_member)
|
||||
menu.add_option("Back to main menu", None)
|
||||
|
||||
selected_option = menu.display().input_option()
|
||||
if selected_option == None:
|
||||
return
|
||||
|
||||
selected_option()
|
||||
|
||||
@staticmethod
|
||||
def manage_advisors():
|
||||
Utils.clear_screen()
|
||||
|
||||
menu = SelectionMenu(f"Manage Advisors")
|
||||
menu.add_option("Add Advisor", MemberMenu.add_member)
|
||||
menu.add_option("Edit Advisor", MemberMenu.edit_member)
|
||||
menu.add_option("Remove Advisor", MemberMenu.remove_member)
|
||||
menu.add_option("Browse Advisor", MemberMenu.browse_member)
|
||||
menu.add_option("Back to main menu", None)
|
||||
|
||||
selected_option = menu.display().input_option()
|
||||
if selected_option == None:
|
||||
return
|
||||
|
||||
selected_option()
|
||||
|
||||
@staticmethod
|
||||
def manage_admins():
|
||||
Utils.clear_screen()
|
||||
|
||||
menu = SelectionMenu(f"Manage System Admins")
|
||||
menu.add_option("Add System Admin", SystemAdminMenu.add_admin)
|
||||
menu.add_option("Edit System Admin", SystemAdminMenu.edit_admin)
|
||||
menu.add_option("Remove System Admin", SystemAdminMenu.remove_admin)
|
||||
menu.add_option("Browse System Admin", SystemAdminMenu.browse_admins)
|
||||
menu.add_option("Back to main menu", None)
|
||||
|
||||
selected_option = menu.display().input_option()
|
||||
if selected_option == None:
|
||||
return
|
||||
|
||||
selected_option()
|
||||
|
||||
|
Reference in New Issue
Block a user