Fixed typo.
This commit is contained in:
parent
45fb349a7d
commit
26988e0987
1 changed files with 23 additions and 25 deletions
48
DBHelper.py
48
DBHelper.py
|
@ -19,11 +19,11 @@ storage = firebase.storage()
|
||||||
|
|
||||||
|
|
||||||
# Create account function which creates a new authentication info.
|
# Create account function which creates a new authentication info.
|
||||||
def create_account(username, password, confirmpassword):
|
def create_account(username, password, confirm_password):
|
||||||
email = username + "@hotmail.com"
|
email = username + "@hotmail.com"
|
||||||
if password == confirmpassword:
|
if password == confirm_password:
|
||||||
auth.create_user_with_email_and_password(email, password)
|
auth.create_user_with_email_and_password(email, password)
|
||||||
print("Account sucessfully created.")
|
print("Account successfully created.")
|
||||||
else:
|
else:
|
||||||
print("Confirmed password doesn't match to other password.")
|
print("Confirmed password doesn't match to other password.")
|
||||||
|
|
||||||
|
@ -39,76 +39,74 @@ def login(username, password):
|
||||||
|
|
||||||
|
|
||||||
# Uploads the data of specified user uploaded into firebase.
|
# Uploads the data of specified user uploaded into firebase.
|
||||||
def upload_data(userID, firstname, lastname, email, phone, address):
|
def upload_data(user_id, firstname, lastname, email, phone, address):
|
||||||
data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone, "Address": address}
|
data = {"First Name": firstname, "Last Name": lastname, "E-Mail": email, "Phone": phone, "Address": address}
|
||||||
db.child("Users").child(userID).set(data)
|
db.child("Users").child(user_id).set(data)
|
||||||
|
|
||||||
|
|
||||||
# Removes the data of specified user uploaded into firebase.
|
# Removes the data of specified user uploaded into firebase.
|
||||||
def remove_data(userID):
|
def remove_data(user_id):
|
||||||
db.child("Users").child(userID).remove()
|
db.child("Users").child(user_id).remove()
|
||||||
|
|
||||||
|
|
||||||
# Returns the first name or else an empty string.
|
# Returns the first name or else an empty string.
|
||||||
def get_firstname(userID):
|
def get_firstname(user_id):
|
||||||
firstname = ""
|
firstname = ""
|
||||||
users = db.child("Users").get()
|
users = db.child("Users").get()
|
||||||
for user in users.each():
|
for user in users.each():
|
||||||
if user.key() == userID:
|
if user.key() == user_id:
|
||||||
firstname = user.val()["First Name"]
|
firstname = user.val()["First Name"]
|
||||||
return firstname
|
return firstname
|
||||||
|
|
||||||
|
|
||||||
# Returns the last name or else an empty string.
|
# Returns the last name or else an empty string.
|
||||||
def get_lastname(userID):
|
def get_lastname(user_id):
|
||||||
lastname = ""
|
lastname = ""
|
||||||
users = db.child("Users").get()
|
users = db.child("Users").get()
|
||||||
for user in users.each():
|
for user in users.each():
|
||||||
if user.key() == userID:
|
if user.key() == user_id:
|
||||||
lastname = user.val()["Last Name"]
|
lastname = user.val()["Last Name"]
|
||||||
return lastname
|
return lastname
|
||||||
|
|
||||||
|
|
||||||
# Returns the e-mail or else an empty string.
|
# Returns the e-mail or else an empty string.
|
||||||
def get_email(userID):
|
def get_email(user_id):
|
||||||
email = ""
|
email = ""
|
||||||
users = db.child("Users").get()
|
users = db.child("Users").get()
|
||||||
for user in users.each():
|
for user in users.each():
|
||||||
if user.key() == userID:
|
if user.key() == user_id:
|
||||||
email = user.val()["E-Mail"]
|
email = user.val()["E-Mail"]
|
||||||
return email
|
return email
|
||||||
|
|
||||||
|
|
||||||
# Returns the phone or else an empty string.
|
# Returns the phone or else an empty string.
|
||||||
def get_phone(userID):
|
def get_phone(user_id):
|
||||||
phone = ""
|
phone = ""
|
||||||
users = db.child("Users").get()
|
users = db.child("Users").get()
|
||||||
for user in users.each():
|
for user in users.each():
|
||||||
if user.key() == userID:
|
if user.key() == user_id:
|
||||||
phone = user.val()["Phone"]
|
phone = user.val()["Phone"]
|
||||||
return phone
|
return phone
|
||||||
|
|
||||||
|
|
||||||
# Returns the address or else an empty string.
|
# Returns the address or else an empty string.
|
||||||
def get_address(userID):
|
def get_address(user_id):
|
||||||
address = ""
|
address = ""
|
||||||
users = db.child("Users").get()
|
users = db.child("Users").get()
|
||||||
for user in users.each():
|
for user in users.each():
|
||||||
if user.key() == userID:
|
if user.key() == user_id:
|
||||||
address = user.val()["Address"]
|
address = user.val()["Address"]
|
||||||
return address
|
return address
|
||||||
|
|
||||||
|
|
||||||
# Uploads the photo of user, input should be something like "example.png"
|
# Uploads the photo of user, input should be something like "example.png"
|
||||||
def upload_user_photo(userphoto):
|
def upload_user_photo(user_photo):
|
||||||
userphoto_str = str(userphoto)
|
storage.child("Photos_of_Users/" + user_photo).put("Photos_of_Users/" + user_photo)
|
||||||
storage.child("Photos_of_Users/" + str(userphoto)).put("Photos_of_Users/" + str(userphoto))
|
|
||||||
|
|
||||||
|
|
||||||
# Uploads the photo of thief, input should be something like "example.png"
|
# Uploads the photo of thief, input should be something like "example.png"
|
||||||
def upload_thief_photo(userphoto):
|
def upload_thief_photo(user_photo):
|
||||||
userphoto_str = str(userphoto)
|
storage.child("Photos_of_Thieves/" + user_photo).put("Photos_of_Thieves/" + user_photo)
|
||||||
storage.child("Photos_of_Thieves/" + str(userphoto)).put("Photos_of_Thieves/" + str(userphoto))
|
|
||||||
|
|
||||||
|
|
||||||
# Downloads all the user photos.
|
# Downloads all the user photos.
|
||||||
|
@ -122,5 +120,5 @@ def download_all_thief_photos(self):
|
||||||
|
|
||||||
|
|
||||||
# Deletes photo of the specified user.
|
# Deletes photo of the specified user.
|
||||||
def delete_user_photo(userphoto):
|
def delete_user_photo(user_photo):
|
||||||
storage.delete('Photos_of_Users/' + userphoto)
|
storage.delete('Photos_of_Users/' + user_photo)
|
||||||
|
|
Loading…
Reference in a new issue