Exemplo n.º 1
0
    def _SearchUser(self):
        
        Utils.PrintStartLine()
        print('ALL CONTENT FOR USER ' , self.userID)

        # Get all content posted by this user (archived and online)
        onlineContent = OnlineContent.objects.filter(fromUser=self.user)
        archivedContent = ArchivedContent.objects.filter(fromUser=self.user)
        
        
        table = PrettyTable(['CID', 'Type', 'TimeCreated', 'NumReports', 'ModAction' , 'Online'])
        
        for content in onlineContent:
            numReports = Report.objects.filter(contentID=).count()

        table.add_row([content.id, content.contentType, content.timeCreated, 
                       numReports, modActionType, True])

        
        for contentID in allContentIDs:
            online = False
            archived = False
            
            # If the content is online, get the content from live db
            if (Utils.ContentIsOnline(contentID)):
                content = PostableContent.objects.get(pk=contentID)
                online = True
                
                # If the content is also archived, set the archived flag
                if (Utils.ContentIsArchived(contentID)):
                    archived = True
            
            # Otherwise, get the content from the archive db
            else:
                content = ArchivedPostableContent.objects.get(pk=contentID)
                archived = True

            contentType = content.contentType
            timeCreated = Utils.GetPrettyFormatTimestamp(content.timeCreated)
            
            # Get the number of reports
            numReports = Report.objects.filter(cid=contentID).count()
            modActionType = Utils.GetMostRecentModActionResult(contentID)
            

        
        print(table)
        Utils.PrintEndLine()
Exemplo n.º 2
0
    def _PrintThreadReplies(self):
        replies = QueryManager.GetThreadReplies(self.contentID)

        print('PRINITING REPLIES FOR THEAD (CID ', self.contentID, ')')

        for re in replies:
            print(
                '--------------------------------------------------------------------------------'
            )
            print('REPLY (CID ', Utils.BinaryToUUID(re.cid.id), ')')
            print('TimeCreated: ',
                  Utils.GetPrettyFormatTimestamp(re.timeCreated))
            print('FromUser: '******'OpName: ', re.name)
            print('HasImage: ', bool(re.url))
            print('Text: ', re.text)

        Utils.PrintEndLine()
Exemplo n.º 3
0
    def _PrintMessage(self):
        if (self.archived):
            ms = QueryManager.GetObjectByID(ArchivedMessage, self.contentID)
        else:
            ms = QueryManager.GetObjectByID(Message, self.contentID)

        Utils.PrintStartLine()
        print('MESSAGE (CID ', self.contentID, ')')
        print('TimeCreated: ',
              Utils.GetPrettyFormatTimestamp(self.content.timeCreated))
        print('FromUser: '******'ToUser: '******'Text: ', ms.text)

        # Gather and print the mod info if the setting is set
        if (self.showModInfo):
            self._PrintModInfo(self.contentID)
        Utils.PrintEndLine()
Exemplo n.º 4
0
    def _PrintLocalPost(self):
        if (self.archived):
            lp = QueryManager.GetObjectByID(ArchivedLocalPost, self.contentID)
        else:
            lp = QueryManager.GetObjectByID(LocalPost, self.contentID)

        Utils.PrintStartLine()
        print('LOCALPOST (CID ', self.contentID, ')')
        print('TimeCreated: ',
              Utils.GetPrettyFormatTimestamp(self.content.timeCreated))
        print('FromUser: '******'GPS: (', lp.latitude, ' , ', lp.longitude, ')')
        print('Text: ', lp.text)

        # Gather and print the mod info if the setting is set
        if (self.showModInfo):
            self._PrintModInfo(self.contentID)
        Utils.PrintEndLine()
Exemplo n.º 5
0
    def _PrintReply(self):
        if (self.archived):
            re = QueryManager.GetObjectByID(ArchivedReply, self.contentID)
        else:
            re = QueryManager.GetObjectByID(Reply, self.contentID)

        Utils.PrintStartLine()
        print('REPLY (CID ', self.contentID, ')')
        print('TimeCreated: ',
              Utils.GetPrettyFormatTimestamp(self.content.timeCreated))
        print('FromUser: '******'OpName: ', re.name)
        print('HasImage: ', bool(re.url))
        print('Text: ', re.text)

        # Gather and print the mod info if the setting is set
        if (self.showModInfo):
            self._PrintModInfo()
        Utils.PrintEndLine()
Exemplo n.º 6
0
 def _DisplayUser(self):
     
     currentTime = time.time()
     
     Utils.PrintStartLine()
     
     # Get basic user info
     print('USER ', self.userID, 'details')
     print('TimeCreated: ', Utils.GetPrettyFormatTimestamp(self.user.timeCreated))
     print('TimeLastUsed: ', Utils.GetPrettyFormatTimestamp(self.user.timeLastUsed))
     
     # Look up how many people have blocked this user on local
     userLocalBlocks = Block.objects.filter(blockedUser=self.user).count()
     print(userLocalBlocks, 'users have blocked this user on local')
     
     # Look up and print all user bans for this user
     userBans = Ban.objects.filter(bannedUser=self.user)
     if (userBans):
         print('Global user bans found:')
         
         for index, ban in enumerate(userBans): # gets the index and the iterator value 
             
             # Check if the ban is current
             banIsCurrent = False
             if (ban.timeExpires > currentTime):
                 banIsCurrent = True
             
             # output info for each ban
             print('Ban ', (index + 1), ':')
             print('    Issued on: ', Utils.GetPrettyFormatTimestamp(ban.timeCreated))
             print('    Duration (hours): ', ban.banLengthHours) 
             print('    Expires: ', Utils.GetPrettyFormatTimestamp(ban.timeCreated + (ban.banLengthHours * Const.SECONDS_IN_HOUR)))
             if (banIsCurrent): 
                 print('    THIS BAN IS CURRENTLY IN EFFECT')
                 
     else:          
         print('No global bans found (past or current) for this user')
         
     Utils.PrintEndLine()
Exemplo n.º 7
0
 def _BanUser(self):
     
     Utils.PrintStartLine()
     print('Creating a new user ban...')
     print('Enter the ban length in hours (whole numbers only): ')
     
     # Take the ban length. No partial hours, only whole numbers
     banLength = input()
     
     # Check that ban length is good
     if (Utils.IsPositiveInt(banLength)):
                 
         # Check if this user is currently banned . If so, then exit
         if (QueryManager.UserIsBanned(self.user)):
             print('This user is currently under a ban already. Please run\
              this script on the user to verify')
             sys.exit(0)
             
         # Otherwise, confirm and create the ban
         else:
             print('Are you sure you want to ban user ', self.userID,\
                   ' for ', banLength, ' hours? (y/n)')
             response = input()
             
             if (response == 'Y' or response == 'y'):
                 Ban.objects.create(bannedUser=self.user,
                                    timeBanExpires=int(banLength) * Const.SECONDS_IN_HOUR)
             
                 print('Ban created successfully.  Please run this script on\
                     the user to verify')
             
             else:
                 print('Okay, exiting now')
     
     else:
         print('Ban length must be a positive int. Exiting.')
         sys.exit(0)
         
     Utils.PrintEndLine()
Exemplo n.º 8
0
    def _PrintThread(self):
        if (self.archived):
            th = QueryManager.GetObjectByID(ArchivedThread, self.contentID)
        else:
            th = QueryManager.GetObjectByID(Thread, self.contentID)

        Utils.PrintStartLine()
        print('THREAD (CID ', self.contentID, ')')
        print('TimeCreated: ',
              Utils.GetPrettyFormatTimestamp(self.content.timeCreated))
        print('FromUser: '******'Title: ', th.title)
        print('OpName: ', th.name)
        print('NumReplies: ', th.replyCount)
        print('Text: ', th.text)

        # Gather and print the mod info if the setting is set
        if (self.showModInfo):
            self._PrintModInfo(self.contentID)
        Utils.PrintEndLine()

        if (self.showFullThread):
            self._PrintThreadReplies(self.contentID)