Rapportsystem API - of D03N
Hovedprosjekt FiV Programmering 20-24
Loading...
Searching...
No Matches
new_sub_user.py
Go to the documentation of this file.
1import os
2#Gets current directory
3current_directory = os.getcwd()
4#imports sys
5import sys
6sys.path.append(os.path.join(current_directory))
7
8#Imports SQLAdminConnections modules
9from SQLAdminConnections import SQL_CreateNewLeaderUser as save_leader
10from SQLAdminConnections import SQL_CreateNewOperatorUser as save_operator
11from SQLAdminConnections import SQL_CreateNewAdminUser as save_admin
12
13#Takes in user object and saves it to database
15 def __init__(self, email, password, accountType, creatorAccount,key,rapportName = None):
16 self.email = email
17 self.password = password
18 self.accountType = accountType
19 self.creatorAccount = creatorAccount
20 self.rapportName = rapportName
21 self.key = key
22
23 #saves user to database
24 def saveToDB(self):
25
26 if self.accountType == 'leader':
27 save_leader.createNewLeaderUser(self.email, self.password, self.accountType, self.creatorAccount, self.key)
28 print("Leader account created successfully")
29 return True
30
31 if self.accountType == 'operator':
32 save_operator.createNewOperatorUser(self.email, self.password,self.accountType,self.creatorAccount, self.key, self.rapportName)
33 print("Operator account created successfully")
34 return True
35 return False
__init__(self, email, password, accountType, creatorAccount, key, rapportName=None)