예제 #1
0
    def search_attributes(cls, name=None, alias=None, page=1, page_size=None):
        """
        :param name: 
        :param alias: 
        :param page: 
        :param page_size: 
        :return: attribute, if name is None, then return all attributes
        """
        if name is not None:
            attrs = Attribute.get_by_like(name=name)
        elif alias is not None:
            attrs = Attribute.get_by_like(alias=alias)
        else:
            attrs = Attribute.get_by()

        numfound = len(attrs)
        attrs = attrs[(page - 1) * page_size:][:page_size]
        res = list()
        for attr in attrs:
            attr["is_choice"] and attr.update(
                dict(choice_value=cls.get_choice_values(
                    attr["id"], attr["value_type"])))
            res.append(attr)

        return numfound, res
예제 #2
0
파일: attribute.py 프로젝트: shuke163/cmdb
 def get_attributes(self, name=None):
     """
     :param name: 
     :return: attribute, if name is None, then return all attributes
     """
     attrs = Attribute.get_by_like(
         name=name) if name is not None else Attribute.get_by()
     res = list()
     for attr in attrs:
         attr["is_choice"] and attr.update(
             dict(choice_value=self.get_choice_values(
                 attr["id"], attr["value_type"])))
         res.append(attr)
     return res