Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
0
 def get_file_object(self,
                     node,
                     path,
                     provider,
                     check_object_permissions=True):
     obj = get_file_object(node=node,
                           path=path,
                           provider=provider,
                           request=self.request)
     if provider == 'osfstorage':
         if check_object_permissions:
             self.check_object_permissions(self.request, obj)
     return obj
Esempio n. 4
0
 def get_file_object(self, target, path, provider, check_object_permissions=True):
     obj = get_file_object(target=target, path=path, provider=provider, request=self.request)
     if provider == 'osfstorage':
         if check_object_permissions:
             self.check_object_permissions(self.request, obj)
     return obj