예제 #1
0
    def unbanUser(self, userId):
        userData = users.getShortUserById(userId)
        first_name = userData.get('first_name')
        last_name = userData.get('last_name')
        if userId < 0:
            first_name = userData.get('name')
        userName = ""
        if not isinstance(first_name, str) and not isinstance(last_name, str):
            print('name not defined for userData: ' +
                  json.dumps(userData, indent=4))
            return False
        elif isinstance(first_name, str) and isinstance(last_name, str):
            userName = first_name + ' ' + last_name
        elif isinstance(first_name, str):
            userName = first_name
        else:
            userName = last_name

        locString = self.guiDelegate.localize_(
            args=['are_you_sure_for_unblock_username'
                  ], withResult=True) + userName + self.guiDelegate.localize_(
                      args=['are_you_sure_for_unblock_username_tile'],
                      withResult=True)
        dialogsManager = PyDialogsManager()
        index, cancelled = dialogsManager.showYesNoDialogWithMessage(
            locString, "unban_user_button", "cancel")
        if cancelled == True:
            return False
        return self.doUnbanUser(userId)
예제 #2
0
 def optionsTappedWithUserId(self, userId):
     try:
         dialogsManager = PyDialogsManager()
         items = []
         if userId > 0:
             items.append('report')
         items.append('block_user')
         index, cancelled = dialogsManager.showRowsDialogWithTitles(items)
         if cancelled:
             return
         if index == 0 and userId > 0:
             self.report('user', userId, 0)
         else:
             userData = users.getShortUserById(userId)
             first_name = userData.get('first_name')
             last_name = userData.get('last_name')
             if userId < 0:
                 first_name = userData.get('name')
             userName = ""
             if not isinstance(first_name, str) and not isinstance(
                     last_name, str):
                 print('name not defined for userData: ' +
                       json.dumps(userData, indent=4))
                 return
             elif isinstance(first_name, str) and isinstance(
                     last_name, str):
                 userName = first_name + ' ' + last_name
             elif isinstance(first_name, str):
                 userName = first_name
             else:
                 userName = last_name
             locString = self.guiDelegate.localize_(
                 args=['are_you_sure_for_block_username'
                       ], withResult=True) + userName + '?'
             index, cancelled = dialogsManager.showYesNoDialogWithMessage(
                 locString, "ban_user_button", "cancel")
             if cancelled == True:
                 return
             self.blockUser(userId)
     except Exception as e:
         print('optionsTappedWithUserId exception: ' + str(e))
         print(traceback.format_exc())