本文整理汇总了Python中models.card.Card.get_latest_accepted方法的典型用法代码示例。如果您正苦于以下问题:Python Card.get_latest_accepted方法的具体用法?Python Card.get_latest_accepted怎么用?Python Card.get_latest_accepted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.card.Card
的用法示例。
在下文中一共展示了Card.get_latest_accepted方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_card_by_kind
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import get_latest_accepted [as 别名]
def get_card_by_kind(card_id):
"""
Given a card data, return a new card model to replace it by kind.
"""
card = Card.get_latest_accepted(card_id)
if not card:
return
data, kind = card.data, card.data.get('kind')
map = {
'audio': AudioCard,
'choice': ChoiceCard,
'embed': EmbedCard,
'formula': FormulaCard,
'match': MatchCard,
'number': NumberCard,
'page': PageCard,
'slideshow': SlideshowCard,
'upload': UploadCard,
'video': VideoCard,
'writing': WritingCard,
}
if kind in map:
return map[kind](data)
示例2: get_latest_accepted
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import get_latest_accepted [as 别名]
def get_latest_accepted(kind, entity_id):
"""
Given a kind and an entity_id, pull the latest accepted
version out of the database.
"""
if kind == 'card':
return Card.get_latest_accepted(entity_id)
# TODO-1 This needs to also get the right card kind...
elif kind == 'unit':
return Unit.get_latest_accepted(entity_id)
elif kind == 'set':
return Set.get_latest_accepted(entity_id)
示例3: flush_entities
# 需要导入模块: from models.card import Card [as 别名]
# 或者: from models.card.Card import get_latest_accepted [as 别名]
def flush_entities(descs):
"""
Given a list of kinds and entity_ids,
return a list filled out with entities.
"""
output = []
for desc in descs:
if desc['kind'] == 'card':
output.append(Card.get_latest_accepted(entity_id=desc['id']))
# TODO-1 This needs to also get the right card kind...
elif desc['kind'] == 'unit':
output.append(Unit.get_latest_accepted(entity_id=desc['id']))
elif desc['kind'] == 'set':
output.append(Set.get_latest_accepted(entity_id=desc['id']))
else:
output.append(None)
return output