예제 #1
0
 def set_data(data, name, child: str):
     try:
         db.child(child.capitalize()).child(name.capitalize()).set(data)
         return True
     except:
         Popup.display_error("Something went wrong")
         return False
예제 #2
0
    def press(self):

        if (self.nameOfProfession.text == "" or self.description.text == ""
                or self.availableFor.text == ""
                or self.primaryStatistics.text == ""
                or self.secondaryStatistics.text == ""
                or self.equipment.text == "" or self.weapon.text == ""
                or self.armor.text == ""):
            Popup.display_error('Please fill all of the blank spots')

        elif (len(self.primaryStatistics.text) != 16
              or len(self.secondaryStatistics.text) != 16):
            Popup.display_error('Wrong format in one of the boxes')

        else:
            data = {
                'name': self.nameOfProfession.text,
                'description': self.description.text,
                'availableFor': self.availableFor.text,
                'primaryStatistics': self.primaryStatistics.text,
                'secondaryStatistics': self.secondaryStatistics.text,
                'equipment': self.equipment.text,
                'weapon': self.weapon.text,
                'armor': self.armor.text
            }
            Handler.push_data(data, 'Professions')
            self.clearInputBoxes()
예제 #3
0
 def push_data(data, child: str):
     try:
         db.child(child.capitalize()).push(data)
         return True
     except:
         Popup.display_error("Something went wrong")
         return False
예제 #4
0
 def get_data(child: str):
     items = []
     try:
         database = db.child(child.capitalize()).get()
         for entity in database.each():
             items.append(entity.val())
     except:
         Popup.display_error("Something went wrong")
     return items
예제 #5
0
    def press(self):

        if self.nameOfSex.text == "":

            Popup.display_error('Please fill all of the blank spots')

        else:
            data = {'name': self.nameOfSex.text}
            Handler.push_data(data, 'Sex')
            self.clearInputBoxes()
예제 #6
0
 def update_data(data, name: str, child: str):
     try:
         database = db.child(child.capitalize()).get()
         for entity in database.each():
             if (entity.val()['name'] == name.lower()):
                 db.child(child.capitalize()).child(entity.key()).update(data)
                 return True
         return False
     except:
         Popup.display_error("Something went wrong")
         return False
예제 #7
0
 def delete_data(item, child: str):
     try:
         database = db.child(child.capitalize()).get()
         for entity in database.each():
             if item == entity.val():
                 print("BOOM")
                 db.child(child.capitalize()).child(entity.key()).remove()
                 return True
         return False
     except:
         Popup.display_error("Something went wrong")
         return False
예제 #8
0
    def press(self):

        if (self.nameOfStarSign.text == "" or self.description.text == ""):

            Popup.display_error('Please fill all of the blank spots')

        else:
            data = {
                'name': self.nameOfStarSign.text,
                'description': self.description.text
            }
            Handler.push_data(data, 'StarSigns')
            self.clearInputBoxes()
예제 #9
0
    def press(self):

        if (self.nameOfRace.text == "" or self.description.text == ""
                or self.primaryStatistics.text == ""
                or self.secondaryStatistics.text == ""
                or self.fpRoll.text == "" or self.wRoll.text == ""):
            Popup.display_error('Please fill all of the blank spots')

        elif (len(self.primaryStatistics.text) != 16
              or len(self.secondaryStatistics.text) != 16
              or len(self.wRoll.text) != 8 or len(self.fpRoll.text) != 3):
            Popup.display_error('Wrong format in one of the boxes')

        else:
            data = {
                'name': self.nameOfRace.text,
                'description': self.description.text,
                'primaryStatistics': self.primaryStatistics.text,
                'secondaryStatistics': self.secondaryStatistics.text,
                'wRoll': self.wRoll.text,
                'fpRoll': self.fpRoll.text
            }
            Handler.push_data(data, 'Races')
            self.clearInputBoxes()
예제 #10
0
 def login(self, email, password):
     try:
         self.user = auth.sign_in_with_email_and_password(email, password)
         Popup.display_info("You have successfully signed in!")
         return True
     except requests.HTTPError as e:
         error_json = e.args[1]
         error = json.loads(error_json)['error']['message']
         if error == "INVALID_EMAIL":
             Popup.display_error("Invalid email input")
         if error == "MISSING_PASSWORD":
             Popup.display_error("Please input a password")
         if error == "INVALID_PASSWORD":
             Popup.display_error("Invalid password input")
         return False
예제 #11
0
 def register(self, email, password, password_confirm):
     try:
         if password == password_confirm:
             auth.create_user_with_email_and_password(email, password)
             Popup.display_info(
                 "Registration was successful! You can try to log in now")
             return True
         else:
             Popup.display_error("Invalid password confirmation")
             return False
     except requests.HTTPError as e:
         error_json = e.args[1]
         error = json.loads(error_json)['error']['message']
         if error == "EMAIL_EXISTS":
             Popup.display_error("Email already exist")
         if error == "INVALID_EMAIL":
             Popup.display_error("Invalid email input")
         if error == "MISSING_PASSWORD":
             Popup.display_error("Please input a password")
         if error == "WEAK_PASSWORD : Password should be at least 6 characters":
             Popup.display_error("Your password is too weak")
         if error == "INVALID_PASSWORD":
             Popup.display_error("Invalid password input")
         return False