Exemplo n.º 1
0
def public_dashboard_records(project_id):
    (traffic, created) = TrafficModel.objects.get_or_create(created_at=str(datetime.datetime.utcnow()), service="cloud", endpoint="/public/dashboard/records/<project_id>")
    if not created:
        traffic.interactions += 1 
        traffic.save()
        
    if fk.request.method == 'GET':
        p = ProjectModel.objects.with_id(project_id)
        if p.access == 'public':
            project = {"project":json.loads(p.summary_json())}
            records = RecordModel.objects(project=p)
            records_object = []
            for record in records:
                if record.access == 'public':
                    record_object = {"id":str(record.id), "created":str(record.created_at), "updated":str(record.updated_at), "status":str(record.status)}
                    diffs = []
                    founds = DiffModel.objects(record_from=record)
                    if founds != None:
                        for diff in founds:
                            diffs.append(diff.info())
                    founds = DiffModel.objects(record_to=record)
                    if founds != None:
                        for diff in founds:
                            diffs.append(diff.info()) 

                    record_object['diffs'] = len(diffs)
                    records_object.append(record_object)

            project["activity"] = {"number":len(records), "records":records_object}
            return fk.Response(json.dumps(project, sort_keys=True, indent=4, separators=(',', ': ')), mimetype='application/json')
        else:
            return fk.redirect('http://0.0.0.0:5000/error-401/?action=dashboard_failed')
    else:
        return fk.redirect('http://0.0.0.0:5000/error-405/')  
Exemplo n.º 2
0
def public_record_diff(record_id):
    (traffic, created) = TrafficModel.objects.get_or_create(created_at=str(datetime.datetime.utcnow()), service="cloud", endpoint="/public/dashboard/record/diff/<record_id>")
    if not created:
        traffic.interactions += 1 
        traffic.save()
        
    if fk.request.method == 'GET':
        try:
            record = RecordModel.objects.with_id(record_id)
        except:
            print str(traceback.print_exc())
        if record is None:
            return fk.redirect('http://0.0.0.0:5000/error-204/')
        else:
            if record.access == 'public':
                diffs = []
                founds = DiffModel.objects(record_from=record)
                if founds != None:
                    for diff in founds:
                        diffs.append(diff.info())
                founds = DiffModel.objects(record_to=record)
                if founds != None:
                    for diff in founds:
                        diffs.append(diff.info())  
                record_info = record.info()
                record_info['diffs'] = diffs          
                return fk.Response(json.dumps(record_info, sort_keys=True, indent=4, separators=(',', ': ')), mimetype='application/json')
            else:
                return fk.redirect('http://0.0.0.0:5000/error-401/?action=dashboard_failed')
    else:
        return fk.redirect('http://0.0.0.0:5000/error-405/')
Exemplo n.º 3
0
def diff_create(hash_session):
    logTraffic(CLOUD_URL, endpoint='/private/<hash_session>/diff/create')
    if fk.request.method == 'POST':
        access_resp = access_manager.check_cloud(hash_session)
        current_user = access_resp[1]
        if current_user is None:
            return fk.Response('Unauthorized action on this endpoint.',
                               status.HTTP_401_UNAUTHORIZED)
        else:
            logAccess(CLOUD_URL, 'cloud',
                      '/private/<hash_session>/diff/create')
            if fk.request.data:
                data = json.loads(fk.request.data)
                record_from_id = data.get("record_from", "")
                record_to_id = data.get("record_to", "")
                method = data.get("method", "undefined")
                proposition = data.get("proposition", "undefined")
                status = data.get("status", "undefined")
                comments = data.get("comments", [])

                if record_from_id == "" or record_to_id == "":
                    return cloud_response(
                        400, 'Diff not created.',
                        "Both record from and to be provided.")
                else:
                    try:
                        record_from = RecordModel.objects.with_id(
                            record_from_id)
                        record_to = RecordModel.objects.with_id(record_to_id)
                        if record_to and record_from:
                            diff = DiffModel(created_at=str(
                                datetime.datetime.utcnow()),
                                             sender=current_user,
                                             targeted=current_user,
                                             record_from=record_from,
                                             record_to=record_to)
                            diff.method = method
                            diff.proposition = proposition
                            diff.status = status
                            diff.comments = comments
                            diff.save()
                            return cloud_response(
                                201, 'Diff successfully created.',
                                "The diff was created.")
                        else:
                            return fk.Response(
                                'Both record from and to have to exist.',
                                status.HTTP_404_NOT_FOUND)
                    except:
                        return fk.Response(
                            str(traceback.print_exc()),
                            status.HTTP_500_INTERNAL_SERVER_ERROR)
            else:
                return fk.Response('No content provided for the creation.',
                                   status.HTTP_204_NO_CONTENT)
    else:
        return fk.redirect('{0}:{1}/error/?code=405'.format(
            VIEW_HOST, VIEW_PORT))
Exemplo n.º 4
0
def query_basic(words, page, filtr, current_user):
    filtrs = filter2filters(filtr)
    raw = []
    if "user" not in filtrs:
        raw.extend([u for u in UserModel.objects().order_by('+created_at') if all(w in str(u.extended()).lower() for w in words)])
        # _users = UserModel.objects(Q(email__in=words)|Q(email__in=words)|)
        # _users_P = ProfileModel.objects()
        pagination_logs.append("{0} -- query_basic: {1}".format(datetime.datetime.utcnow(), raw))
    if "tool" not in filtrs:
        raw.extend([u for u in ApplicationModel.objects().order_by('+created_at') if all(w in str(u.extended()).lower() for w in words)])
        pagination_logs.append("{0} -- query_basic: {1}".format(datetime.datetime.utcnow(), raw))
    if "project" not in filtrs:
        raw.extend([u for u in ProjectModel.objects().order_by('+created_at') if all(w in str(u.extended()).lower() for w in words) and (u.access == 'public' or current_user and (current_user == u.owner or current_user.group == "admin"))])

        pagination_logs.append("{0} -- query_basic: {1}".format(datetime.datetime.utcnow(), raw))
    if "record" not in filtrs:
        raw.extend([u for u in RecordModel.objects().order_by('+created_at') if all(w in str(u.extended()).lower() for w in words) and (u.access == 'public' or (current_user and u.project) and (current_user == u.project.owner or current_user.group == "admin"))])
        pagination_logs.append("{0} -- query_basic: {1}".format(datetime.datetime.utcnow(), raw))
    if "diff" not in filtrs:
        raw.extend([u for u in DiffModel.objects().order_by('+created_at') if all(w in str(u.extended()).lower() for w in words) and ((u.record_from.access == 'public' and u.record_to.access == 'public') or (current_user and (current_user.group == "admin" or current_user == u.record_from.project.owner or current_user == u.record_to.project.owner)))])
        pagination_logs.append("{0} -- query_basic: {1}".format(datetime.datetime.utcnow(), raw))
    if "env" not in filtrs:
        raw.extend([u for u in EnvironmentModel.objects().order_by('+created_at') if all(w in str(u.extended()).lower() for w in words) and (len(ProjectModel.objects(history=str(u.id))) > 0 and (ProjectModel.objects(history=str(u.id))[0].access == 'public' or current_user and (current_user == ProjectModel.objects(history=str(u.id))[0].owner or current_user.group == "admin")))])
        pagination_logs.append("{0} -- query_basic: {1}".format(datetime.datetime.utcnow(), raw))
    return raw2dict(raw, page)
Exemplo n.º 5
0
 def tearDown(self):
     # Delete all documents
     # Stop mongodb instance.
     for traffic in TrafficModel.objects():
       traffic.delete()
     for stat in StatModel.objects():
       stat.delete()
     for bundle in BundleModel.objects():
       bundle.delete()
     for version in VersionModel.objects():
       version.delete()
     for user in UserModel.objects():
       user.delete()
     for file in FileModel.objects():
       file.delete()
     for profile in ProfileModel.objects():
       profile.delete()
     for message in MessageModel.objects():
       message.delete()
     for project in ProjectModel.objects():
       project.delete()
     for comment in CommentModel.objects():
       comment.delete()
     for application in ApplicationModel.objects():
       application.delete()
     for access in AccessModel.objects():
       access.delete()
     for environment in EnvironmentModel.objects():
       environment.delete()
     for record in RecordModel.objects():
       record.delete()
     for record in RecordBodyModel.objects():
       record.delete()
     for diff in DiffModel.objects():
       diff.delete()
Exemplo n.º 6
0
def public_diffs():
    logTraffic(endpoint='/admin/diffs')
    if fk.request.method == 'GET':
        diffs = DiffModel.objects()
        diffs_dict = {'total_diffs':len(diffs), 'diffs':[]}
        for diff in diffs:
            diffs_dict['diffs'].append(diff.extended())
        return api_response(200, 'Diffs list', diffs_dict)
    else:
        return api_response(405, 'Method not allowed', 'This endpoint supports only a GET method.')
Exemplo n.º 7
0
def record_diff(hash_session, record_id):
    (traffic, created) = TrafficModel.objects.get_or_create(created_at=str(datetime.datetime.utcnow()), service="cloud", endpoint="/private/dashboard/record/diff/<record_id>")
    if not created:
        traffic.interactions += 1 
        traffic.save()
        
    if fk.request.method == 'GET':
        current_user = UserModel.objects(session=hash_session).first()
        print fk.request.path
        if current_user is not None:
            allowance = current_user.allowed("%s%s"%(fk.request.headers.get('User-Agent'),fk.request.remote_addr))
            print "Allowance: "+allowance
            if allowance == hash_session:
                try:
                    record = RecordModel.objects.with_id(record_id)
                except:
                    print str(traceback.print_exc())
                if record is None:
                    return fk.redirect('http://0.0.0.0:5000/error-204/')
                else:
                    if (record.project.owner == current_user) or record.access == 'public':
                        diffs = []
                        founds = DiffModel.objects(record_from=record)
                        if founds != None:
                            for diff in founds:
                                diffs.append(diff.info())
                        founds = DiffModel.objects(record_to=record)
                        if founds != None:
                            for diff in founds:
                                diffs.append(diff.info())  
                        record_info = record.info()
                        record_info['diffs'] = diffs          
                        return fk.Response(json.dumps(record_info, sort_keys=True, indent=4, separators=(',', ': ')), mimetype='application/json')
                    else:
                        return fk.redirect('http://0.0.0.0:5000/error-401/?action=dashboard_failed')
            else:
                return fk.redirect('http://0.0.0.0:5000/error-401/?action=dashboard_failed')
        else:
            return fk.redirect('http://0.0.0.0:5000/error-401/?action=dashboard_denied')
    else:
        return fk.redirect('http://0.0.0.0:5000/error-405/')
Exemplo n.º 8
0
def dashboard_records(hash_session, project_id):
    (traffic, created) = TrafficModel.objects.get_or_create(created_at=str(datetime.datetime.utcnow()), service="cloud", endpoint="/private/dashboard/records/<project_id>")
    if not created:
        traffic.interactions += 1 
        traffic.save()
        
    if fk.request.method == 'GET':
        current_user = UserModel.objects(session=hash_session).first()
        print fk.request.path
        if current_user is None:
            return fk.redirect('http://0.0.0.0:5000/error-401/?action=dashboard_denied')
        else:
            allowance = current_user.allowed("%s%s"%(fk.request.headers.get('User-Agent'),fk.request.remote_addr))
            print "Allowance: "+allowance
            if allowance == hash_session:
                p = ProjectModel.objects.with_id(project_id)
                project = {"project":json.loads(p.summary_json())}
                records = RecordModel.objects(project=p)
                records_object = []
                for record in records:
                    record_object = {"id":str(record.id), "created":str(record.created_at), "updated":str(record.updated_at), "status":str(record.status)}
                    diffs = []
                    founds = DiffModel.objects(record_from=record)
                    if founds != None:
                        for diff in founds:
                            diffs.append(diff.info())
                    founds = DiffModel.objects(record_to=record)
                    if founds != None:
                        for diff in founds:
                            diffs.append(diff.info()) 

                    record_object['diffs'] = len(diffs)
                    records_object.append(record_object)

                project["activity"] = {"number":len(records), "records":records_object}
                return fk.Response(json.dumps(project, sort_keys=True, indent=4, separators=(',', ': ')), mimetype='application/json')
            else:
                return fk.redirect('http://0.0.0.0:5000/error-401/?action=dashboard_failed')
    else:
        return fk.redirect('http://0.0.0.0:5000/error-405/')  
Exemplo n.º 9
0
def diff_create():
    logTraffic(CLOUD_URL, endpoint='/private/diff/create')
    hash_session = basicAuthSession(fk.request)
    if fk.request.method == 'POST':
        access_resp = access_manager.check_cloud(hash_session, ACC_SEC, CNT_SEC)
        current_user = access_resp[1]
        if current_user is None:
            return fk.Response('Unauthorized action on this endpoint.', status.HTTP_401_UNAUTHORIZED)
        else:
            logAccess(CLOUD_URL, 'cloud', '/private/diff/create')
            if fk.request.data:
                data = json.loads(fk.request.data)
                record_from_id = data.get("record_from", "")
                record_to_id = data.get("record_to", "")
                method = data.get("method", "undefined")
                proposition = data.get("proposition", "undefined")
                status = data.get("status", "undefined")
                comments = data.get("comments", [])

                if record_from_id == "" or record_to_id == "":
                    return cloud_response(400, 'Diff not created.', "Both record from and to be provided.")
                else:
                    try:
                        record_from = RecordModel.objects.with_id(record_from_id)
                        record_to = RecordModel.objects.with_id(record_to_id)
                        if current_user.group != "admin":
                            if record_from.project.owner == current_user:
                                sender_user = current_user
                                receiver_user = record_to.project.owner
                            else:
                                sender_user = record_to.project.owner
                                receiver_user = record_from.project.owner
                        else:
                            sender_user = record_from.project.owner
                            receiver_user = record_to.project.owner
                        if record_to and record_from:
                            diff = DiffModel(created_at=str(datetime.datetime.utcnow()), sender=sender_user, targeted=receiver_user, record_from=record_from, record_to=record_to)
                            diff.method = method
                            diff.proposition = proposition
                            diff.status = status
                            diff.comments = comments
                            diff.save()
                            return cloud_response(201, 'Diff successfully created.', "The diff was created.")
                        else:
                            return fk.Response('Both record from and to have to exist.', status.HTTP_404_NOT_FOUND)
                    except:
                        return fk.Response(str(traceback.print_exc()), status.HTTP_500_INTERNAL_SERVER_ERROR)
            else:
                return fk.Response('No content provided for the creation.', status.HTTP_204_NO_CONTENT)
    else:
        return fk.redirect('{0}:{1}/error/?code=405'.format(VIEW_HOST, VIEW_PORT))
Exemplo n.º 10
0
def fetchDependencies(name, obj):
    deps = {}
    if name == "user":
        profiles = [el for el in ProfileModel.objects(user=obj)]
        deps["profile"] = profiles
        files = [el for el in FileModel.objects(owner=obj)]
        deps["file"] = files
        projects = [el for el in ProjectModel.objects(owner=obj)]
        deps["project"] = projects
        tools = [el for el in ApplicationModel.objects(developer=obj)]
        deps["tool"] = tools
    elif name == "version":
        envs = [el for el in EnvironmentModel.objects(version=obj)]
        deps["env"] = envs
    elif name == "record":
        diffs_from = [el for el in DiffModel.objects(record_from=obj)]
        deps["diff"] = diffs_from
        diffs_to = [el for el in DiffModel.objects(record_to=obj)]
        for rec in diffs_to:
            if rec not in deps["diff"]:
                deps["diff"].append(rec)
    elif name == "project":
        records = [el for el in RecordModel.objects(project=obj)]
        deps["record"] = records
    elif name == "file":
        projects = [
            pr for pr in ProjectModel.objects() if str(obj.id) in pr.resources
        ]
        logo_projects = [el for el in ProjectModel.objects(logo=obj)]
        for pr in logo_projects:
            if pr not in projects:
                projects.append(pr)
        deps["project"] = projects
        records = [
            rec for rec in RecordModel.objects()
            if str(obj.id) in rec.resources
        ]
        deps["record"] = records
        tools = [el for el in ApplicationModel.objects(logo=obj)]
        deps["tool"] = tools
        envs = [
            env for env in EnvironmentModel.objects()
            if str(obj.id) in env.resources
        ]
        deps["env"] = envs
        diffs = [
            dff for dff in DiffModel.objects() if str(obj.id) in dff.resources
        ]
        deps["diff"] = diffs
        profiles = [el for el in ProfileModel.objects(picture=obj)]
        deps["profile"] = profiles
    elif name == "env":
        records = [el for el in RecordModel.objects(environment=obj)]
        deps["record"] = records
        projects = [
            pr for pr in ProjectModel.objects() if str(obj.id) in pr.history
        ]
        deps["project"] = projects
    elif name == "bundle":
        envs = [el for el in EnvironmentModel.objects(bundle=obj)]
        deps["env"] = envs

    return deps
Exemplo n.º 11
0
def public_search():
    (traffic, created) = TrafficModel.objects.get_or_create(created_at=str(datetime.datetime.utcnow()), service="cloud", endpoint="/public/dashboard/search")
    if not created:
        traffic.interactions += 1 
        traffic.save()
        
    if fk.request.method == 'GET':
        if fk.request.args:
            query = fk.request.args.get("query").split(" ") #single word for now.
            users = []
            for user in UserModel.objects():
                profile = ProfileModel.objects(user=user)
                where = []
                if query in user.email:
                    where.append("email")
                if query in profile.fname:
                    where.append("fname")
                if query in profile.lname:
                    where.append("lname")
                if query in profile.organisation:
                    where.append("organisation")
                if query in profile.about:
                    where.append("about")
                if len(where) != 0:
                    users.append({"id":str(user.id), "email":user.email, "fname":profile.fname, "lname":profile.lname, "organisation":profile.organisation, "about":profile.about})
            projects = []
            records = []
            for project in ProjectModel.objects():
                if project.access == 'public':
                    where_project = []
                    if query in project.name:
                        where_project.append("name")
                    if query in project.goals:
                        where_project.append("goals")
                    if query in project.description:
                        where_project.append("description")
                    if query in project.group:
                        where_project.append("group")

                    if len(where_project) != 0:
                        projects.append({"user":str(project.owner.id), "id":str(project.id), "name":project.name, "created":str(project.created_at), "duration":str(project.duration)})
                    
                    for record in RecordModel.objects(project=project):
                        if record.access == 'public':
                            body = record.body
                            where_record = []
                            
                            if query in record.label:
                                where_record.append("label")
                            if query in str(json.dumps(record.system)):
                                where_record.append("system")
                            if query in str(json.dumps(record.program)):
                                where_record.append("program")
                            if query in str(json.dumps(record.inputs)):
                                where_record.append("inputs")
                            if query in str(json.dumps(record.outputs)):
                                where_record.append("outputs")
                            if query in str(json.dumps(record.dependencies)):
                                where_record.append("dependencies")
                            if query in record.status:
                                where_record.append("status")
                            if query in str(json.dumps(body.data)):
                                where_record.append("data")

                            if len(where_record) != 0:
                                records.append({"user":str(record.project.owner.id), "project":str(record.project.id), "id":str(record.id), "label":record.label, "created":str(record.created_at), "status":record.status})

            diffs = []
            for diff in DiffModel.objects():
                if diff.record_from.access == 'public' and diff.record_to.access == 'public':
                    where = []
                    if query in str(json.dumps(diff.diff)):
                        where.append("diff")
                    if query in diff.proposition:
                        where.append("proposition")
                    if query in diff.status:
                        where.append("status")
                    if query in str(json.dumps(diff.comments)):
                        where.append("comments")

                    if len(where) != 0:
                        diffs.append({"id":str(diff.id), "from":str(diff.record_from.id), "to":str(diff.record_to.id), "sender":str(diff.sender.id), "targeted":str(diff.targeted.id), "proposition":diff.proposition, "status":diff.status})
                
            return fk.Response(json.dumps({'users':{'count':len(users), 'result':users}, 'projects':{'count':len(projects), 'result':projects}, 'records':{'count':len(records), 'result':records}, 'diffs':{'count':len(diffs), 'result':diffs}}, sort_keys=True, indent=4, separators=(',', ': ')), mimetype='application/json')
        else:
            return fk.redirect('http://0.0.0.0:5000/error-400/')
    else:
        return fk.redirect('http://0.0.0.0:5000/error-405/')
Exemplo n.º 12
0
def reproducibility_assess(hash_session, record_id):
    (traffic, created) = TrafficModel.objects.get_or_create(created_at=str(datetime.datetime.utcnow()), service="cloud", endpoint="/private/dashboard/reproducibility/assess/<record_id>")
    if not created:
        traffic.interactions += 1 
        traffic.save()
        
    if fk.request.method == 'GET':
        current_user = UserModel.objects(session=hash_session).first()
        print fk.request.path
        if current_user is not None:
            try:
                record = RecordModel.objects.with_id(record_id)
            except:
                print str(traceback.print_exc())
            if record is None:
                return fk.redirect('http://0.0.0.0:5000/error-204/')
            else:
                if request.args:
                    if record.project.owner == current_user or record.access == 'public':
                        repeated = request.args.get('repeated', False)
                        reproduced = request.args.get('reproduced', False)
                        non_repeated = request.args.get('non-repeated', False)
                        non_reproduced = request.args.get('non-reproduced', False)
                        undefined = request.args.get('undefined', False)

                        repeats = []
                        n_repeats = []
                        reprods = []
                        n_reprods = []
                        undefs = []

                        diffs = []
                        diffs.extend(DiffModel.objects(record_from=record))
                        diffs.extend(DiffModel.objects(record_to=record))

                        for diff in diffs:
                            if diff.status == "agreed": #Only agreed for now.
                                if repeated and diff.proposition == "repeated":
                                    repeats.append(diff)
                                if non_repeated and diff.proposition == "non-repeated":
                                    n_repeats.append(diff)
                                if reproduced and diff.proposition == "reproduced":
                                    reprods.append(diff)
                                if non_reproduced and diff.proposition == "non-reproduced":
                                    n_reprods.append(diff)
                                if undefined and diff.proposition == "undefined":
                                    undefs.append(diff)
                        results = {"total":len(repeats)+len(n_repeats)+len(reprods)+len(n_reprods)+len(undefs)}
                        results["repeated"] = {"total":len(repeats), "diffs":[json.loads(d.to_json()) for d in repeats]}
                        results["non-repeated"] = {"total":len(n_repeats), "diffs":[json.loads(d.to_json()) for d in n_repeats]}
                        results["reproduced"] = {"total":len(reprods), "diffs":[json.loads(d.to_json()) for d in reprods]}
                        results["non-reproduced"] = {"total":len(n_reprods), "diffs":[json.loads(d.to_json()) for d in n_reprods]}
                        results["undefined"] = {"total":len(undefs), "diffs":[json.loads(d.to_json()) for d in undefs]}

                        return fk.Response(json.dumps(results, sort_keys=True, indent=4, separators=(',', ': ')), mimetype='application/json')
                    else:
                        return fk.redirect('http://0.0.0.0:5000/error-401/?action=repeats_failed')
                else:
                    return fk.redirect('http://0.0.0.0:5000/error-415/')
        else:
            return fk.redirect('http://0.0.0.0:5000/error-401/?action=view_denied')
    else:
        return fk.redirect('http://0.0.0.0:5000/error-405/')      
Exemplo n.º 13
0
def fetchDependencies(name, obj, offset, leftover, filtrs):
    deps = {}
    size = 0
    if name == "user":
        # profiles, size, offset, leftover = paginate(ProfileModel.objects(user=obj), offset, leftover, size)
        # deps["profile"] = profiles
        if "file" not in filtrs:
            files, size, offset, leftover = paginate(FileModel.objects(owner=obj), offset, leftover, size)
            deps["file"] = files
        if "project" not in filtrs:
            projects, size, offset, leftover = paginate(ProjectModel.objects(owner=obj), offset, leftover, size)
            deps["project"] = projects
        if "tool" not in filtrs:
            tools, size, offset, leftover = paginate(ApplicationModel.objects(developer=obj), offset, leftover, size)
            deps["tool"] = tools
    # elif name == "version":
    #     if "env" not in filtrs:
    #         envs, size, offset, leftover = paginate(EnvironmentModel.objects(version=obj), offset, leftover, size)
    #         deps["env"] = envs
    elif name == "record":
        if "diff" not in filtrs:
            diffs_from, size, offset, leftover = paginate(DiffModel.objects(record_from=obj), offset, leftover, size)
            deps["diff"] = diffs_from
            diffs_to = [el for el in DiffModel.objects(record_to=obj)]
            diffs_more = []
            for rec in diffs_to:
                if rec not in deps["diff"]:
                    diffs_more.append(rec)
            diffs_more, size, offset, leftover = paginate(diffs_more, offset, leftover, size)
            deps["diff"].extend(diffs_more)
    elif name == "project":
        if "record" not in filtrs:
            records, size, offset, leftover = paginate(RecordModel.objects(project=obj), offset, leftover, size)
            deps["record"] = records
    # elif name == "file":
    #     projects = [pr for pr in ProjectModel.objects() if str(obj.id) in pr.resources]
    #     logo_projects = [el for el in ProjectModel.objects(logo=obj)]
    #     for pr in logo_projects:
    #         if pr not in projects:
    #             projects.append(pr)
    #     projects, size, offset, leftover = paginate(projects, offset, leftover, size)
    #     deps["project"] = projects

    #     records = [rec for rec in RecordModel.objects() if str(obj.id) in rec.resources]
    #     records, size, offset, leftover = paginate(records, offset, leftover, size)
    #     deps["record"] = records

    #     tools, size, offset, leftover = paginate(ApplicationModel.objects(logo=obj), offset, leftover, size)
    #     deps["tool"] = tools

    #     envs = [env for env in EnvironmentModel.objects() if str(obj.id) in env.resources]
    #     envs, size, offset, leftover = paginate(envs, offset, leftover, size)
    #     deps["env"] = envs

    #     diffs = [dff for dff in DiffModel.objects() if str(obj.id) in dff.resources]
    #     diffs, size, offset, leftover = paginate(diffs, offset, leftover, size)
    #     deps["diff"] = diffs

    #     profiles, size, offset, leftover = paginate(ProfileModel.objects(picture=obj), offset, leftover, size)
    #     deps["profile"] = profiles
    elif name == "env":
        if "record" not in filtrs:
            records, size, offset, leftover = paginate(RecordModel.objects(environment=obj), offset, leftover, size)
            deps["record"] = records

        if "project" not in filtrs:
            projects = [pr for pr in ProjectModel.objects if str(obj.id) in pr.history]
            projects, size, offset, leftover = paginate(projects, offset, leftover, size)
            deps["project"] = projects
    # elif name == "bundle":
    #     envs, size, offset, leftover = paginate(EnvironmentModel.objects(bundle=obj), offset, leftover, size)
    #     deps["env"] = envs
    pagination_logs.append("{0} -- fetchDependencies: {1}, {2}, {3}, {4}".format(datetime.datetime.utcnow(), size, offset, leftover))
    return deps, size, offset, leftover