Exemple #1
0
    def get_comment_recursive(self, comment_dict, comments):
        if len(comment_dict["child_comments"]) is 0:
            comment = CommentNode(id=comment_dict["_id"].binary.hex(),
                                  author=comment_dict["author"],
                                  text=comment_dict["text"],
                                  parent_id=comment_dict["parentId"],
                                  discussion_id=comment_dict["discussionId"],
                                  extra_data=comment_dict["extra_data"],
                                  depth=comment_dict["depth"],
                                  timestamp=comment_dict["timestamp"],
                                  child_comments=[],
                                  is_alert=comment_dict["is_alert"])
            return comment

        child_list = []
        for comment_id in comment_dict["child_comments"]:
            child_comment_dict = comments[comment_id]
            child_list.append(
                self.get_comment_recursive(child_comment_dict, comments))

        comment = CommentNode(id=comment_dict["_id"].binary.hex(),
                              author=comment_dict["author"],
                              text=comment_dict["text"],
                              parent_id=comment_dict["parentId"],
                              discussion_id=comment_dict["discussionId"],
                              extra_data=comment_dict["extra_data"],
                              depth=comment_dict["depth"],
                              timestamp=comment_dict["timestamp"],
                              child_comments=child_list,
                              is_alert=comment_dict["is_alert"])
        return comment
Exemple #2
0
 def change_configuration(self, configuration_dict):
     comment = CommentNode(author=configuration_dict["author"],
                           text=configuration_dict["text"],
                           parent_id=configuration_dict["parentId"],
                           discussion_id=configuration_dict["discussionId"],
                           depth=configuration_dict["depth"],
                           comment_type="configuration",
                           child_comments=[],
                           extra_data=configuration_dict["extra_data"])
     comment.set_id(self.db_management.add_comment(comment))
     response = {"comment": comment}
     return response
Exemple #3
0
    def add_alert(self, alert_dict):
        comment = CommentNode(author=alert_dict["author"],
                              text=alert_dict["text"],
                              parent_id=alert_dict["parentId"],
                              discussion_id=alert_dict["discussionId"],
                              depth=alert_dict["depth"],
                              comment_type="alert",
                              child_comments=[],
                              extra_data=alert_dict["extra_data"])
        comment.set_id(self.db_management.add_comment(comment))
        response = {"comment": comment}

        return response
Exemple #4
0
    def add_comment(self, comment_dict):
        comment = CommentNode(author=comment_dict["author"],
                              text=comment_dict["text"],
                              parent_id=comment_dict["parentId"],
                              discussion_id=comment_dict["discussionId"],
                              depth=comment_dict["depth"],
                              is_alert=False,
                              child_comments=[])
        # Call KaminAI
        # KaminAI(comment)
        comment.set_id(self.db_management.add_comment(comment))
        response = {"comment": comment}  # , "KaminAIresult": kamin_response

        return response