本文整理汇总了Python中ggrc.models.reflection.AttributeInfo.gather_publish_attrs方法的典型用法代码示例。如果您正苦于以下问题:Python AttributeInfo.gather_publish_attrs方法的具体用法?Python AttributeInfo.gather_publish_attrs怎么用?Python AttributeInfo.gather_publish_attrs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ggrc.models.reflection.AttributeInfo
的用法示例。
在下文中一共展示了AttributeInfo.gather_publish_attrs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: log_json
# 需要导入模块: from ggrc.models.reflection import AttributeInfo [as 别名]
# 或者: from ggrc.models.reflection.AttributeInfo import gather_publish_attrs [as 别名]
def log_json(self):
"""Get a dict with attributes and related objects of self.
This method converts additionally person-mapping attributes and owners
to person stubs.
"""
from ggrc import models
res = self.log_json_base()
for attr in self._people_log_mappings:
if hasattr(self, attr):
value = getattr(self, attr)
# hardcoded [:-3] is used to strip "_id" suffix
res[attr[:-3]] = self._person_stub(value) if value else None
for attr_name in AttributeInfo.gather_publish_attrs(self.__class__):
if is_attr_of_type(self, attr_name, models.Option):
attr = getattr(self, attr_name)
if attr:
stub = create_stub(attr)
stub["title"] = attr.title
else:
stub = None
res[attr_name] = stub
return res