예제 #1
0
 def unban_collaborator(self, collabID):
     """
     Unbans a collaborator found in the database and publishes all the documents pertaining to said collaborator.
     
     Parameters
     ----------
     collabID : string
         ID of the collaborator to be unbanned.
     
     Returns
     -------
     Collaborator
         Collaborator object of the item that matched the ID or None if the collaborator was not found.
     """
     try:
         collaborator.objects(id=collabID).update_one(set__banned=False,
                                                      full_result=True)
         collab = collaborator.objects.get(id=collabID)
     except DoesNotExist:
         return None
     try:
         document_case.objects(creatoriD=collab.id).update(
             set__published=True, full_result=True)
         self.email_manager.email_collaborator(email=collab.email,
                                               email_type='unban')
     except:
         pass
     return collab
    def publish_document(self, documentID):
        """
        Publishes the document with the given ID in the database.
        
        Parameters
        ----------
        documentID : string
            ID of the document to be published.
        
        Returns
        -------
        DocumentCase
            DocumentCase object of the item that matched the ID or None if the document was not found.

        """
        try:
            document_case.objects(id=documentID).update_one(
                set__published=True, full_result=True)
            doc: document_case = document_case.objects.get(id=documentID)

            # Automatically fetches collaborator since its a reference field
            collab: collaborator = doc.creatoriD

            self.email_manager.email_collaborator(doc_title=doc.title,
                                                  email=collab.email,
                                                  email_type='publish')
        except DoesNotExist:
            return None

        return doc
예제 #3
0
    def remove_tag(self, tagID):
        """
        Removes a Tag from the database.
        
        Parameters
        ----------
        tagID : string
            Id of the tag to be removed.
        
        Returns
        -------
        Dictionary
            Dictionary of the tag removed None if no tag was found.

        """
        tagVar = tag.objects(id=tagID).first()
        if tagVar is None:
            return None
        tagVar.delete()
        try:
            document_case.objects().update(pull__tagsDoc=tagVar.tagItem)
        except:
            pass
        return tagVar