def user_registration(self): #retrieving all registered email no from user table user_id = self.get_user_id() if user_id is None: sql = "INSERT INTO users (name, email, password, mobile) VALUES (%s, %s, %s, %s)" val = (self.name, self.email, self.password, self.mobile) mycursor.execute(sql, val) mydb.commit() # if email already registered ask them to login again or reset password else: print( f'Account already created for {self.email} Please try to Login using your mobile number and password.\n Want to reset password?\n1. Yes\n2. No' ) reset_pass = int(input()) # Reset password Function if reset_pass == 1: new_pass = input("Enter your New pass: "******"UPDATE users set password = %s WHERE email = %s" val = (new_pass, self.email) mycursor.execute(sql, val) mydb.commit() print("Password Reset Successfully.") else: import index # due to mutual importing we are importing here just before methodcalling if self.role == "younger": younger = YoungerProfile(self.email, self.password) younger.sign_up(self.get_user_id()) elif self.role == "younger": elder = ElderProfile(self.email, self.password) elder.sign_up(self.get_user_id())
def welcome(): print( "Please select\n1. Login as Elder \n2. Login as Younger\n3. Register\n4. View all youngers who are taking care\n5. View who is taking care of older couple\n6. Exit" ) task = int(input()) if task == 1: mobile = input("Welcome Elder\nEnter Your Email: ") password = input("Enter Your Password: "******"Welcome younger\nEnter Your Email: ") password = input("Enter Your Password: "******"Register Yourself\nEnter Your Full Name: ") email = input("Enter your email: ") mobile = input("Enter Your Mobile Number: ") password = input("Enter Your Password: "******"select your role:\n1. Elder\n2. Younger\n")) try: if role == 1: role = "elder" break elif role == 2: role = "younger" break except: print(f'option not Valid! Please try again') user_signup = User(name, email, password, mobile, role) user_signup.user_registration() # display name of youngers who are taking care of elif task == 4: pass # enter elder's mobile number of email boh are unique here and display their take care name elif task == 5: pass elif task == 6: exit()
def welcome(): print( "Please select\n1. Login as Elder \n2. Login as Younger\n3. Register\n4. View all youngers who are taking care\n5. View who is taking care of older couple\n6. Exit" ) task = int(input()) if task == 1: mobile = input("Welcome Elder\nEnter Your Email: ") password = input("Enter Your Password: "******"Welcome younger\nEnter Your Email: ") password = input("Enter Your Password: "******"Register Yourself\nEnter Your Full Name: ") email = input("Enter your email: ") mobile = input("Enter Your Mobile Number: ") password = input("Enter Your Password: "******"select your role:\n1. Elder\n2. Younger\n")) try: if role == 1: role = "elder" break elif role == 2: role = "younger" break except: print(f'option not Valid! Please try again') user_signup = User(name, email, password, mobile, role) user_signup.user_registration() # display name of youngers who are taking care of elif task == 4: sql = '''SELECT `name` FROM users WHERE `PK_user_id` IN (SELECT FK_user_id FROM `youngers` WHERE `PK_younger_id` IN (SELECT `FK_younger_id` FROM elders))''' mycursor.execute(sql) user_data = mycursor.fetchall() for data in user_data: print(data) # pass # enter elder's mobile number of email both are unique here and display their take care name elif task == 5: print("Enter elders email id to check their take cares name") email_id = input() sql1 = "SELECT `FK_user_id` FROM elders WHERE `FK_user_id` IN (SELECT `PK_user_id` FROM users WHERE email = %s);" val = (email_id) mycursor.execute(sql1, val) elder_id = mycursor.fetchall() if not elder_id: print("No Elder or User found with this mail id") welcome() return sql2 = "SELECT `FK_younger_id` FROM request WHERE `request_status` = 1 AND `FK_elder_id` = %d;" val2 = (elder_id) mycursor.execute(sql2, val2) names = mycursor.fetchall() for name in names: print(name) elif task == 6: exit()
def welcome(): print( "Please select\n1. Login as Elder \n2. Login as Younger\n3. Register\n4. View all youngers who are taking care\n5. View who is taking care of older couple\n6. Exit" ) task = int(input()) if task == 1: mobile = input("Welcome Elder\nEnter Your Email: ") password = input("Enter Your Password: "******"Welcome younger\nEnter Your Email: ") password = input("Enter Your Password: "******"Register Yourself\nEnter Your Full Name: ") email = input("Enter your email: ") mobile = input("Enter Your Mobile Number: ") password = input("Enter Your Password: "******"select your role:\n1. Elder\n2. Younger\n")) try: if role == 1: role = "elder" break elif role == 2: role = "younger" break except: print(f'option not Valid! Please try again') user_signup = User(name, email, password, mobile, role) user_signup.user_registration() # display name of youngers who are taking care of elif task == 4: sql = 'select name from users where PK_user_id = (select FK_user_id from youngers where PK_younger_id = (select FK_younger_id from elders where FK_younger_id >= 1))' mycursor.execute(sql) print(mycursor.fetchone()) # enter elder's mobile number of email boh are unique here and display their take care name elif task == 5: print( "Enter Email or mobile number to find who is taking of the respective elder\n1.Email\n2.Mobile Number" ) choice = int(input()) if choice == 1: email = str(input('Enter the Email :')) sql = f'SELECT name FROM users WHERE PK_user_id = (SELECT FK_user_id FROM youngers where FK_user_id = (SELECT FK_younger_id FROM elders where FK_user_id = (SELECT PK_user_id FROM users where email = "{email}")))' mycursor.execute(sql) print(mycursor.fetchone()) elif choice == 2: mobile_no = str(input('Mobile No :')) sql = f'SELECT name FROM users WHERE PK_user_id = (SELECT FK_user_id FROM youngers where FK_user_id = (SELECT FK_younger_id FROM elders where FK_user_id = (SELECT PK_user_id FROM users where mobile = "{mobile_no}")))' mycursor.execute(sql) print(mycursor.fetchone()) #It will come out from the application, Run the application again if you want to go inside elif task == 6: return "\n\n\nWelcome to CareAll\n\n\n"
def welcome(): print( "Please select\n1. Login as Elder \n2. Login as Younger\n3. Register\n4. View all youngers who are taking care\n5. View who is taking care of older couple\n6. Exit" ) task = int(input()) if task == 1: mobile = input("Welcome Elder\nEnter Your Email: ") password = input("Enter Your Password: "******"Welcome younger\nEnter Your Email: ") password = input("Enter Your Password: "******"Register Yourself\nEnter Your Full Name: ") email = input("Enter your email: ") mobile = input("Enter Your Mobile Number: ") password = input("Enter Your Password: "******"select your role:\n1. Elder\n2. Younger\n")) try: if role == 1: role = "elder" break elif role == 2: role = "younger" break except: print(f'option not Valid! Please try again') user_signup = User(name.lower(), email, password, mobile, role) user_signup.user_registration() print("\n\n") welcome() # display name of youngers who are taking care of elif task == 4: sql = f'SELECT * FROM users,youngers where PK_user_id = FK_user_id' mycursor.execute(sql) younger_info = mycursor.fetchall() print("{:25} {:25} {:15} {:5}".format("name", "Email", "Contact", "Rating")) for younger in younger_info: print("{:25} {:25} {:15} {}".format(younger[1], younger[2], younger[4], younger[7])) elder_info(younger[0]) print("\n") print("\n\n") welcome() # enter elder's mobile number of email boh are unique here and display their take care name elif task == 5: sql = f'select a.name,a.email,a.mobile,b.name from users a,users b,elders e where a.PK_user_id = e.FK_user_id and b.name in (select name from users,youngers where PK_user_id = FK_user_id and PK_younger_id in (select FK_younger_id from elders,youngers where FK_younger_id = PK_younger_id and a.PK_user_id = elders.FK_user_id))' mycursor.execute(sql) care_info = mycursor.fetchall() print("{:25} {:25} {:15} {:25}".format("Elder Name", "Email", "Mobile", "Care taker Name")) for care in care_info: print("{:25} {:25} {:15} {:25}".format(care[0], care[1], care[2], care[3])) print("\n\n") welcome() elif task == 6: exit()
def welcome(): print( "Please select\n1. Login as Elder \n2. Login as Younger\n3. Register\n4. View all youngers who are taking care\n5. View who is taking care of older couple\n6. Exit" ) task = int(input()) if task == 1: mobile = input("Welcome Elder\nEnter Your Email: ") password = input("Enter Your Password: "******"Welcome younger\nEnter Your Email: ") password = input("Enter Your Password: "******"Register Yourself\nEnter Your Full Name: ") email = input("Enter your email: ") mobile = input("Enter Your Mobile Number: ") password = input("Enter Your Password: "******"select your role:\n1. Elder\n2. Younger\n")) try: if role == 1: role = "elder" break elif role == 2: role = "younger" break except: print(f'option not Valid! Please try again') user_signup = User(name, email, password, mobile, role) user_signup.user_registration() elif task == 4: sql = f'SELECT name from users where PK_user_id in (select FK_younger_ID from elders)' mycursor.execute(sql) younger_info = mycursor.fetchall() print(younger_info) print("This all youngeFolks are taking care of some older") for i in range(len(younger_info)): print(f'{i+1}. {younger_info[i][0]}') welcome() elif task == 5: elder_number = int(input("Please enter elder's mobile number.\n")) sql = f'SELECT PK_user_id from users where mobile={elder_number}' mycursor.execute(sql) user_id = mycursor.fetchone() sql = f'SELECT FK_younger_id, available from elders WHERE FK_user_id={user_id[0]}' mycursor.execute(sql) elder_detail = mycursor.fetchone() print(elder_detail) if elder_detail[1] == 0: sql = f'select name from users where PK_user_id={elder_detail[0]}' val = (elder_detail[0]) mycursor.execute(sql, val) younger_name = mycursor.fetchone() print(f'{younger_name[0]} is taking care of {elder_detail[0]}.') else: print(f'No one is taking care of {elder_detail[0]}') welcome() elif task == 6: exit()