コード例 #1
0
 def signUpCallback(self):
     if len(self.usernameTextInput.text.strip()) == 0 \
         or len(self.passwordTextInput.text.strip()) == 0\
             or len(self.repeatPasswordTextInput.text.strip()) == 0:
         Alert(title="Input Error", text='Empty Fields are not Allowed Here! Try Again')
         return
     if not self.passwordTextInput.text.strip() ==\
         self.repeatPasswordTextInput.text.strip():
         Alert(title="Input Error", text='Passwords do not match! Try Again')
         return
     try:
         resultCode = signUp(readToken(), 
                         self.usernameTextInput.text.strip(), 
                         self.passwordTextInput.text.strip())
         if resultCode == INVALID_TOKEN_CODE:
             removeToken()
             self.app.screenManager.current = LOGIN_SCREEN
             Alert(title="Authentication Error", text='Please Login Again')
         elif resultCode == INVALID_CODE:
             Alert(title="Input Error", text='User with this Username Already Exists!')
         elif resultCode == POST_SUCCESS_CODE:
             self.app.screenManager.current = MENU_SCREEN
             Alert(title="Success", text='New Clerk Successfully Registered')
         else:
             self.app.screenManager.current = MENU_SCREEN
             Alert(title="Register Error", text='Please Try Again Later')
     except Exception:
         Alert(title="Connection Error", text='Connection Error, Try Again Later')
コード例 #2
0
 def createAccountCallback(self):
     if len(self.firstNameTextInput.text.strip()) == 0 \
         or len(self.lastNameTextInput.text.strip()) == 0\
             or len(self.phoneNumberTextInput.text.strip()) == 0\
                 or len(self.nationalCodeTextInput.text.strip()) == 0:
         Alert(title="Input Error",
               text='Empty Fields are not Allowed Here! Try Again')
         return
     try:
         resultCode = createAccount(readToken(), \
             self.firstNameTextInput.text.strip(), \
                 self.lastNameTextInput.text.strip(), \
                     self.phoneNumberTextInput.text.strip(), \
                         self.nationalCodeTextInput.text.strip())
         if resultCode == INVALID_TOKEN_CODE:
             removeToken()
             self.app.screenManager.current = LOGIN_SCREEN
             Alert(title="Authentication Error", text='Please Login Again')
         elif resultCode == DUPLICATE_CODE:
             Alert(title="Input Error",
                   text='Owner with this ID Already Exists!')
         elif resultCode == POST_SUCCESS_CODE:
             self.app.screenManager.current = MENU_SCREEN
             Alert(title="Success", text='New Account Successfully Created')
         else:
             self.app.screenManager.current = MENU_SCREEN
             Alert(title="Create Account Error",
                   text='Please Try Again Later')
     except Exception:
         Alert(title="Connection Error",
               text='Connection Error, Try Again Later')
コード例 #3
0
 def __init__(self, app, **kwargs):
     super(TransactionsListScreen, self).__init__(**kwargs)
     self.app = app
     self.ids.rv.data = []
     result = getAllTransactions(readToken())
     self.allResults = []
     if result == None:
         removeToken()
         self.app.screenManager.current = LOGIN_SCREEN
         Alert(title="Authentication Error", text='Please Login Again')
     else:
         self.allResults = result[:]
コード例 #4
0
    def showLogsCallback(self, accountID, ownerName):
        logs = getAccountLogs(readToken(), int(accountID))
        if logs == None:
            removeToken()
            self.app.screenManager.current = LOGIN_SCREEN
            Alert(title="Authentication Error", text='Please Login Again')
            return
        currentCredit = logs['currentCredit']
        logs = logs['logs']

        if len(logs) == 0:
            Alert(title="Account Logs", text='There are no logs to show!', time=3, linesNumber=1)
            return

        logsPopup = ShowLogsPopUp(logs, currentCredit, accountID, ownerName)
        popUpWindow = Popup(title="Logs", content=logsPopup, size_hint = (None, None), size=(400,400))
        popUpWindow.open()
        return
コード例 #5
0
    def createTransactionCallback(self):
        fromAccount = self.fromAccountTextInput.text.strip()
        toAccount = self.toAccountTextInput.text.strip()
        if len(fromAccount) == 0 and len(toAccount) == 0:
            Alert(title="Input Error",
                  text='Both Account Fields can not be Empty')
            return
        if fromAccount == '':
            fromAccount = None
        if toAccount == '':
            toAccount = None

        amount = self.transactionAmountTextInput.text.strip()
        if len(amount) == 0:
            Alert(title="Input Error", text='Amount Field can not be Empty')
            return

        cash = False
        if fromAccount == None or toAccount == None:
            cash = True

        try:
            result = createTransaction(
                readToken(), float(amount), fromAccount, toAccount,
                self.transactionDescribtionTextInput.text.strip(), cash)
            if type(result) == str:
                Alert(title="Input Error(s)", text=result, time=3)
                return
            if result == None:
                removeToken()
                self.app.screenManager.current = LOGIN_SCREEN
                Alert(title="Authentication Error", text='Please Login Again')
                return

            self.app.screenManager.current = MENU_SCREEN
            Alert(title="Success",
                  text='Transaction Successfully Created With ID: ' +
                  str(result['id']),
                  time=3)

        except Exception:
            Alert(title="Connection Error",
                  text='Connection Error, Try Again Later')
コード例 #6
0
 def logoutCallback(self):
     removeToken()
     self.app.screenManager.current = LOGIN_SCREEN