Beispiel #1
0
    def get(need_other=None):
        groups = CITypeGroup.get_by()
        group_types = set()
        for group in groups:
            for t in sorted(CITypeGroupItem.get_by(group_id=group['id']), key=lambda x: x['order']):
                group.setdefault("ci_types", []).append(CITypeCache.get(t['type_id']).to_dict())
                group_types.add(t["type_id"])

        if need_other:
            ci_types = CITypeManager.get_ci_types()
            other_types = dict(ci_types=[ci_type for ci_type in ci_types if ci_type["id"] not in group_types])
            groups.append(other_types)

        return groups
Beispiel #2
0
 def add(name):
     CITypeGroup.get_by(name=name, first=True) and abort(
         400, "Group {0} does exist".format(name))
     return CITypeGroup.create(name=name)