示例#1
0
文件: views.py 项目: scooley/osf.io
    def get_log(self):
        log = NodeLog.load(self.kwargs.get('log_id'))
        if not log:
            raise NotFound(
                detail='No log matching that log_id could be found.')

        self.check_object_permissions(self.request, log)
        return log
示例#2
0
文件: views.py 项目: 545zhou/osf.io
    def get_log(self):
        log = NodeLog.load(self.kwargs.get('log_id'))
        if not log:
            raise NotFound(
                detail='No log matching that log_id could be found.'
            )

        self.check_object_permissions(self.request, log)
        return log
示例#3
0
 def get_queryset(self):
     log = NodeLog.load(self.kwargs.get('log_id'))
     if not log:
         raise NotFound(
             detail='No log matching that log_id could be found.')
     else:
         auth_user = get_user_auth(self.request)
         return [
             node for node in log.node__logged if node.can_view(auth_user)
         ]
def get_registered_from(registration):
    """
    Gets node registration was registered from.  Handles deleted registrations where registered_from is null.

    """
    if registration.registered_from:
        return registration.registered_from_id
    else:
        first_log_id = db['node'].find_one({'_id': registration._id})['logs'][0]
        log = NodeLog.load(first_log_id)
        return log.params.get('node') or log.params.get('project')
def get_registered_from(registration):
    """
    Gets node registration was registered from.  Handles deleted registrations where registered_from is null.

    """
    if registration.registered_from:
        return registration.registered_from_id
    else:
        first_log_id = db['node'].find_one({'_id':
                                            registration._id})['logs'][0]
        log = NodeLog.load(first_log_id)
        return log.params.get('node') or log.params.get('project')
示例#6
0
文件: views.py 项目: mauromsl/osf.io
 def get_queryset(self):
     log = NodeLog.load(self.kwargs.get('log_id'))
     if not log:
         raise NotFound(
             detail='No log matching that log_id could be found.'
         )
     else:
         auth_user = get_user_auth(self.request)
         return [
             node for node in log.node__logged
             if node.can_view(auth_user)
         ]
示例#7
0
def main():
    total = NodeLog.objects.all().count()
    count = 0
    page_size = 50000
    with transaction.atomic():
        qs = NodeLog.objects.all().order_by('-date').select_related(
            'user').select_related('node').select_related(
                'user___guid').select_related('node___guid')
        with server_side_cursors(qs, itersize=page_size):
            for log in qs.iterator():
                modm_nodelog = MODMNodeLog.load(log.guid)
                if modm_nodelog is not None:
                    modm_node = modm_nodelog.node
                    modm_user = modm_nodelog.user
                    if log.user is not None and log.user._guid.guid != modm_user._id:
                        print 'User doesn\'t match on log {}; {} != {}'.format(
                            log.guid, modm_user._id, log.user._guid.guid)
                    if log.node is not None and log.node._guid.guid != modm_nodelog.node._id:
                        print 'Node doesn\'t match on log {}; {} != {}'.format(
                            log.guid, modm_nodelog.node._id,
                            log.node._guid.guid)
                    if log.date is not None and pytz.utc.localize(
                            modm_nodelog.date) != log.date:
                        print 'Date doesn\'t match on log {}'.format(log.guid)
                    if log.action is not None and log.action != modm_nodelog.action:
                        print 'Action doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.action, log.action)
                    if log.params is not None and log.params != modm_nodelog.params:
                        print 'Params doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.params, log.params)
                    if log.should_hide is not None and log.should_hide != modm_nodelog.should_hide:
                        print 'Should_hide does\'nt match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.should_hide,
                            log.should_hide)
                    if log.foreign_user is not None and log.foreign_user != '' and log.foreign_user != modm_nodelog.foreign_user:
                        print 'Foreign_user doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.foreign_user,
                            log.foreign_user)
                else:
                    print 'MODMNodeLog with id {} not found.'.format(log.guid)

                count += 1
                if count % page_size == 0:
                    MODMNodeLog._cache.clear()
                    MODMNodeLog._object_cache.clear()
                    print '{} through {}'.format(count, count + page_size)
示例#8
0
def main():
    total = NodeLog.objects.all().count()
    count = 0
    page_size = 50000
    with transaction.atomic():
        qs = NodeLog.objects.all().order_by('-date').select_related('user').select_related('node').select_related('user___guid').select_related('node___guid')
        with server_side_cursors(qs, itersize=page_size):
            for log in qs.iterator():
                modm_nodelog = MODMNodeLog.load(log.guid)
                if modm_nodelog is not None:
                    modm_node = modm_nodelog.node
                    modm_user = modm_nodelog.user
                    if log.user is not None and log.user._guid.guid != modm_user._id:
                        print 'User doesn\'t match on log {}; {} != {}'.format(
                            log.guid, modm_user._id, log.user._guid.guid)
                    if log.node is not None and log.node._guid.guid != modm_nodelog.node._id:
                        print 'Node doesn\'t match on log {}; {} != {}'.format(
                            log.guid, modm_nodelog.node._id, log.node._guid.guid)
                    if log.date is not None and pytz.utc.localize(
                            modm_nodelog.date) != log.date:
                        print 'Date doesn\'t match on log {}'.format(log.guid)
                    if log.action is not None and log.action != modm_nodelog.action:
                        print 'Action doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.action, log.action)
                    if log.params is not None and log.params != modm_nodelog.params:
                        print 'Params doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.params, log.params)
                    if log.should_hide is not None and log.should_hide != modm_nodelog.should_hide:
                        print 'Should_hide does\'nt match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.should_hide, log.should_hide)
                    if log.foreign_user is not None and log.foreign_user != '' and log.foreign_user != modm_nodelog.foreign_user:
                        print 'Foreign_user doesn\'t match on log {}; `{}` != `{}`'.format(
                            log.guid, modm_nodelog.foreign_user, log.foreign_user)
                else:
                    print 'MODMNodeLog with id {} not found.'.format(log.guid)

                count += 1
                if count % page_size == 0:
                    MODMNodeLog._cache.clear()
                    MODMNodeLog._object_cache.clear()
                    print '{} through {}'.format(count, count + page_size)