Exemplo n.º 1
0
    def get_unread_comments_count(self, obj):
        user = get_user_auth(self.context['request']).user
        node_comments = Comment.find_n_unread(user=user, node=obj, page='node')

        return {
            'node': node_comments
        }
Exemplo n.º 2
0
    def get_unread_comments_count(self, obj):
        user = self.get_user_auth(self.context['request']).user
        node_comments = Comment.find_n_unread(user=user, node=obj, page='node')
        file_comments = self.get_unread_file_comments(obj)

        return {
            'total': node_comments + file_comments,
            'node': node_comments,
            'files': file_comments
        }
Exemplo n.º 3
0
    def get_unread_comments_count(self, obj):
        user = self.get_user_auth(self.context['request']).user
        node_comments = Comment.find_n_unread(user=user, node=obj, page='node')
        file_comments = self.get_unread_file_comments(obj)

        return {
            'total': node_comments + file_comments,
            'node': node_comments,
            'files': file_comments
        }
Exemplo n.º 4
0
 def get_unread_file_comments(self, obj):
     user = self.get_user_auth(self.context['request']).user
     n_unread = 0
     commented_files = File.find(Q('_id', 'in', obj.commented_files.keys()))
     for file_obj in commented_files:
         if obj.get_addon(file_obj.provider):
             try:
                 self.context['view'].get_file_object(obj, file_obj.path, file_obj.provider, check_object_permissions=False)
             except (exceptions.NotFound, exceptions.PermissionDenied):
                 continue
             n_unread += Comment.find_n_unread(user, obj, page='files', root_id=file_obj._id)
     return n_unread
Exemplo n.º 5
0
 def get_unread_file_comments(self, obj):
     user = self.get_user_auth(self.context['request']).user
     n_unread = 0
     commented_files = File.find(Q('_id', 'in', obj.commented_files.keys()))
     for file_obj in commented_files:
         if obj.get_addon(file_obj.provider):
             try:
                 get_file_object(node=obj,
                                 path=file_obj.path,
                                 provider=file_obj.provider,
                                 request=self.context['request'])
             except (exceptions.NotFound, exceptions.PermissionDenied):
                 continue
             n_unread += Comment.find_n_unread(user,
                                               obj,
                                               page='files',
                                               root_id=file_obj._id)
     return n_unread