Example #1
0
    def _GetContent(self):

        # check online and archive tables
        if (QueryManager.ContentIsOnline(self.contentID)):
            self.content = OnlineContent.objects.get(id=self.contentID)
        elif (QueryManager.ContentIsArchived(self.contentID)):
            self.content = ArchivedContent.objects.get(id=self.contentID)
            self.archived = True
        else:
            print('Content does not exist in online or archive tables')
            sys.exit(0)

        # Display a warning note to user about archived content
        if (self.archived):
            print('Note: Specified content is archived (not online). Therefore\
                    content can only be displayed (no moderation actions can be\
                    taken)')
Example #2
0
def _ArchiveReply(content):
    import JokrBackend.DataCollection.QueryManager as QueryManager

    # Check if the reply exists in the archive
    # If it does not, then continue. Otherwise, do nothing
    if (not QueryManager.ContentIsArchived(content.id)):
        
        # Get the online reply    
        onlineReply = Reply.objects.get(pk=content.id)
        
        # Check and get the parent thread if it is archived
        try:
            archivedThread = ArchivedThread.objects.get(pk=onlineReply.parentThread)
                    
        # If the parent thread is not archived, we need to archive it first
        # before we can archive this reply.
        except ObjectDoesNotExist:
            
            # Get the online parent thread
            onlineThread = Thread.objects.get(pk=onlineReply.parentThread)

            # Archive the online thread
            archivedThread = ArchivedThread.objects.create(id=onlineThread.id,
                                                  timeOriginalCreated=onlineThread.timeCreated,
                                                  fromUser=onlineThread.fromUser,
                                                  fromSession=onlineThread.fromSession,
                                                  key=onlineThread.key,
                                                  contentType=onlineThread.contentType,
                                                  fav=onlineThread.fav,
                                                  arn=onlineThread.arn,
                                                  text=onlineThread.text) 
            
        # Archive the reply and link it to the archived thread
        ArchivedReply.objects.create(id=onlineReply.id,
                                    timeOriginalCreated=onlineReply.timeCreated,
                                    fromUser=onlineReply.fromUser,
                                    fromSession=onlineReply.fromSession,
                                    key=onlineReply.key,
                                    contentType=onlineReply.contentType,
                                    fav=onlineReply.fav,
                                    parentThread=archivedThread,
                                    text=onlineReply.text)
Example #3
0
    def _PrintModInfo(self, contentID):
        numReports = Report.objects.filter(
            cid=Utils.UUIDToBinary(contentID)).count()
        online = False
        archived = False
        modActionType = ''

        if (QueryManager.ContentIsOnline(contentID)):
            online = True
        if (QueryManager.ContentIsArchived(contentID)):
            archived = True

        # Get the mod action associated with the piece of content, if there is one
        modActionType = QueryManager.GetMostRecentModActionResult(contentID)

        print('NumReports: ', numReports)
        print('Online: ', online)
        print('Archived: ', archived)
        print('Most recent mod action: ', 'N/A' if not modActionType else
              modActionType)  # ternary operator in python ;)