Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
News_Service_ALLP1/main.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
58 lines (38 sloc)
1.74 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Database import DatabaseManager # to manage data in .csv files using Pandas | |
from EmailManager import EmailManager # to send email to subscribed users | |
from UserInterface import UserInterface # to handle user interaction | |
import sys # for system calls (Exit) https://docs.python.org/3/library/sys.html | |
def main(): | |
dm = DatabaseManager() # handles operations on Database | |
email = EmailManager() # send e-mails | |
ui = UserInterface() # shows menus and asks for input from user | |
dm.checkDatabaseExists() # check if the database folder and database files are present or not. Create files if they don't exist | |
ui.mainMenu() # shows the main menu | |
select = int(input('>> ')) | |
if select == 1: # opens the admin panel | |
if ui.adminLogin(): # if admin true | |
print("Welcome admin") | |
ui.adminMenu() # shows admin menu | |
else: | |
print("Wrong username or password, please retry") | |
elif select == 2: # User login | |
re = ui.userLogin() # checks if user exists | |
if re[0]: # if login is successful | |
ui.userMenu(re[1]) # shows user menu | |
else: | |
print("User not exists or wrong password") # raises the error | |
elif select == 3: | |
ui.userSignUp() # registration menu and control panel | |
elif select == 4: # sends e-mails | |
re = ui.adminLogin() # login admin | |
if re: # if login is successful | |
print("Welcome admin") | |
email.sendEmails() # starts sending e-mails | |
else: | |
print("Wrong Username or Password") | |
elif select == 5: | |
print("Thanks for using News Service") # exits the system | |
sys.exit() # exits the system | |
if __name__ == '__main__': | |
while True: | |
main() | |