Ejemplo n.º 1
0
 def convert_with_links(rpc_audit_templates, limit, url=None, expand=False,
                        **kwargs):
     collection = AuditTemplateCollection()
     collection.audit_templates = \
         [AuditTemplate.convert_with_links(p, expand)
             for p in rpc_audit_templates]
     collection.next = collection.get_next(limit, url=url, **kwargs)
     return collection
Ejemplo n.º 2
0
    def convert_with_links(rpc_action_plans, limit, url=None, expand=False, **kwargs):
        collection = ActionPlanCollection()
        collection.action_plans = [ActionPlan.convert_with_links(p, expand) for p in rpc_action_plans]

        if "sort_key" in kwargs:
            reverse = False
            if kwargs["sort_key"] == "audit_uuid":
                if "sort_dir" in kwargs:
                    reverse = True if kwargs["sort_dir"] == "desc" else False
                collection.action_plans = sorted(
                    collection.action_plans, key=lambda action_plan: action_plan.audit_uuid, reverse=reverse
                )

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection
Ejemplo n.º 3
0
    def convert_with_links(goals, limit, url=None, expand=False, **kwargs):

        collection = GoalCollection()
        collection.goals = [Goal.convert_with_links(g, expand) for g in goals]

        if 'sort_key' in kwargs:
            reverse = False
            if kwargs['sort_key'] == 'strategy':
                if 'sort_dir' in kwargs:
                    reverse = True if kwargs['sort_dir'] == 'desc' else False
                collection.goals = sorted(collection.goals,
                                          key=lambda goal: goal.name,
                                          reverse=reverse)

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection
Ejemplo n.º 4
0
    def convert_with_links(rpc_audits, limit, url=None, expand=False,
                           **kwargs):
        collection = AuditCollection()
        collection.audits = [Audit.convert_with_links(p, expand)
                             for p in rpc_audits]

        if 'sort_key' in kwargs:
            reverse = False
            if kwargs['sort_key'] == 'audit_template_uuid':
                if 'sort_dir' in kwargs:
                    reverse = True if kwargs['sort_dir'] == 'desc' else False
                collection.audits = sorted(
                    collection.audits,
                    key=lambda audit: audit.audit_template_uuid,
                    reverse=reverse)

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection
Ejemplo n.º 5
0
    def convert_with_links(rpc_audits, limit, url=None, expand=False,
                           **kwargs):
        collection = AuditCollection()
        collection.audits = [Audit.convert_with_links(p, expand)
                             for p in rpc_audits]

        if 'sort_key' in kwargs:
            reverse = False
            if kwargs['sort_key'] == 'audit_template_uuid':
                if 'sort_dir' in kwargs:
                    reverse = True if kwargs['sort_dir'] == 'desc' else False
                collection.audits = sorted(
                    collection.audits,
                    key=lambda audit: audit.audit_template_uuid,
                    reverse=reverse)

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection
Ejemplo n.º 6
0
    def convert_with_links(goals, limit, url=None, expand=False,
                           **kwargs):

        collection = GoalCollection()
        collection.goals = [Goal.convert_with_links(g, expand) for g in goals]

        if 'sort_key' in kwargs:
            reverse = False
            if kwargs['sort_key'] == 'strategy':
                if 'sort_dir' in kwargs:
                    reverse = True if kwargs['sort_dir'] == 'desc' else False
                collection.goals = sorted(
                    collection.goals,
                    key=lambda goal: goal.name,
                    reverse=reverse)

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection
Ejemplo n.º 7
0
    def convert_with_links(actions, limit, url=None, expand=False,
                           **kwargs):

        collection = ActionCollection()
        collection.actions = [Action.convert_with_links(p, expand)
                              for p in actions]

        if 'sort_key' in kwargs:
            reverse = False
            if kwargs['sort_key'] == 'next_uuid':
                if 'sort_dir' in kwargs:
                    reverse = True if kwargs['sort_dir'] == 'desc' else False
                collection.actions = sorted(
                    collection.actions,
                    key=lambda action: action.next_uuid or '',
                    reverse=reverse)

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection
Ejemplo n.º 8
0
    def convert_with_links(actions, limit, url=None, expand=False, **kwargs):

        collection = ActionCollection()
        collection.actions = [
            Action.convert_with_links(p, expand) for p in actions
        ]

        if 'sort_key' in kwargs:
            reverse = False
            if kwargs['sort_key'] == 'next_uuid':
                if 'sort_dir' in kwargs:
                    reverse = True if kwargs['sort_dir'] == 'desc' else False
                collection.actions = sorted(
                    collection.actions,
                    key=lambda action: action.next_uuid or '',
                    reverse=reverse)

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection
Ejemplo n.º 9
0
    def convert_with_links(scoring_engines, limit, url=None, expand=False,
                           **kwargs):

        collection = ScoringEngineCollection()
        collection.scoring_engines = [ScoringEngine.convert_with_links(
            se, expand) for se in scoring_engines]

        if 'sort_key' in kwargs:
            reverse = False
            if kwargs['sort_key'] == 'name':
                if 'sort_dir' in kwargs:
                    reverse = True if kwargs['sort_dir'] == 'desc' else False
                collection.goals = sorted(
                    collection.scoring_engines,
                    key=lambda se: se.name,
                    reverse=reverse)

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection
Ejemplo n.º 10
0
    def convert_with_links(scoring_engines,
                           limit,
                           url=None,
                           expand=False,
                           **kwargs):

        collection = ScoringEngineCollection()
        collection.scoring_engines = [
            ScoringEngine.convert_with_links(se, expand)
            for se in scoring_engines
        ]

        if 'sort_key' in kwargs:
            reverse = False
            if kwargs['sort_key'] == 'name':
                if 'sort_dir' in kwargs:
                    reverse = True if kwargs['sort_dir'] == 'desc' else False
                collection.goals = sorted(collection.scoring_engines,
                                          key=lambda se: se.name,
                                          reverse=reverse)

        collection.next = collection.get_next(limit, url=url, **kwargs)
        return collection