Exemple #1
0
 def _retreive_existing(self):
     try:
         pull_list = pull_notifications(self._user, self._connection)
         self._notifCache=pull_list
     except ValueError as err:
         err= ErrorWin(err)
         err.parent = self
         err.show()
         return
     if pull_list:
         for i in pull_list:
             ts = pull_list[i]['timestamp']
             datestring=datetime.fromtimestamp(ts/1e3).strftime('%Y-%m-%d %H:%M:%S')
             self._notifList.__add__([datestring, pull_list[i]['symbol'], pull_list[i]['price'], pull_list[i]['message']])
 def __loginAction(self):
     try:
         self._user = login(self._connection, self._email.value,
                            self._password.value)  #user also public
     except ValueError as error:
         self._password.value = ''
         err = ErrorWin(error)
         err.show()
         return
     #if self._user['displayname'] = '':
     #dispNameWin =
     if self.parent != None: self.parent.loadUser(self._user)
     if self._user != None:
         self.close()
Exemple #3
0
 def __deleteNotif(self):
     row = self._notifList.selected_row_index
     message = self._notifList.get_value(3, row)
     for i in self._notifCache:
         if self._notifCache[i]['message']== message:
             key= i
     try:
         del_notification(self._user, self._connection, key)
         self._notifList.__sub__(row)
     except ValueError as error:
         err= ErrorWin(error)
         err.parent = self
         err.show()
         return
 def __sendUpdate(self):
     #Notification.timestamp = self.timestamp
     Notification.symbol = self.symbol
     Notification.price = self._price_field.value
     Notification.message = self._message_field.value
     Notification.key = self.key
     try:
         update_notification(self._user, self._connection, Notification)
     except ValueError as error:
         err = ErrorWin(error)
         err.parent = self
         err.show()
         return
     if self.parent != None: self.parent._refresh()
     self._close()
 def __retreive_users(self):
     try:
         self._user_pull= pull_users(self._admin, self._connection)
     except ValueError as err:
         err=ErrorWin(err)
         err.parent=self
         err.show()
         return
     if self._user_pull!=None:
         admins = self._connection['Database'].child('admins').shallow().get(self._admin['idToken'])
         for user in self._user_pull:
             check = False
             if user in admins.val():
                 check = True
             self._userList.__add__([check, self._user_pull[user]['name'], self._user_pull[user]['email']])
    def __sendNotification(self):
        Notification.timestamp = datetime.now().timestamp()
        Notification.symbol = self._symbol_field.value
        Notification.price = self._price_field.value
        Notification.message = self._message_field.value
        try:
            post_notification(self._user, self._connection, Notification)
        except ValueError as error:
            err = ErrorWin(error)
            err.parent = self
            err.show()
            return

        except TypeError as type_err:
            err = ErrorWin('Connection or User Token Invalid')
            err.parent = self
            err.show()
            return

        if self.parent != None: self.parent._refresh()
        self._close()
 def __admin_power(self):
     if self.parent!=None: self.parent.persist_login()
     row = self._userList.selected_row_index
     email  = self._userList.get_value(2, row)
     for i in self._user_pull:
         if self._user_pull[i]['email'] == email:
             self._selected_uid = i
     if self._selected_uid == self._admin['localId']:
         err = ErrorWin('Action not allowed - Cannot remove self as admin.')
         err.parent= self
         err.show()
         return
     if self._userList.get_value(0, row)== 'true':#already admin
         conf= ConfirmWin('Are you sure you want to remove this admin?', self._userList.get_value(1, row))
         conf.parent = self
         conf.show()
         return
     else:
         conf= ConfirmWin('Are you sure you want to make this account admin?', self._userList.get_value(1, row))
         conf.parent = self
         conf.show()
         return