Beispiel #1
0
 def _GetTableDataForReport(self, report):
     
     # Init data
     cid = Utils.StipUUIDDashes(report['contentID'])
     modActionID = report['modAction_id']  
     numReports = report['num_reports']
     contentType = report['contentType']
     timeCreated = ''
     fromUser = ''
     modActionType = ''
     online = False
 
     # Get the mod action from this report group if it exists                 
     try:
         modActionType = ModAction.objects.get(pk=modActionID).result
     except ObjectDoesNotExist:
         pass
     
     # Try to lookup the content from the online table
     onlineContent = QueryManager.GetObject(OnlineContent, id=cid)
     
     # If it is there, then use the info from it
     if (onlineContent):
         online = True
         contentType = onlineContent.contentType
         timeCreated = Utils.GetPrettyFormatTimestamp(onlineContent.timeCreated)
         fromUser = onlineContent.fromUser.id
         return [cid, contentType, timeCreated, fromUser, numReports, modActionType, online]
             
     # if the content is not online, then check the archives
     # (Only if the --excludeoffline flag is not set)       
     elif (not self.excludeOffline):                    
 
         # Try to get the archived content
         archivedContent = QueryManager.GetObject(ArchivedContent, pk=cid)
         
         if (archivedContent):
             contentType = archivedContent.contentType
             timeCreated = Utils.GetPrettyFormatTimestamp(archivedContent.timeCreated)
             fromUser = archivedContent.fromUser.id
             return [cid, contentType, timeCreated, fromUser, numReports, modActionType, online]
Beispiel #2
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()
Beispiel #3
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()
Beispiel #4
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()
Beispiel #5
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()
Beispiel #6
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()
Beispiel #7
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()
Beispiel #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)