本文整理汇总了Python中timeline.Timeline.get_json方法的典型用法代码示例。如果您正苦于以下问题:Python Timeline.get_json方法的具体用法?Python Timeline.get_json怎么用?Python Timeline.get_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timeline.Timeline
的用法示例。
在下文中一共展示了Timeline.get_json方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: timeline_json
# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import get_json [as 别名]
def timeline_json():
headline = "Timeline Photo Headline"
text = "this is the text"
start_date = '2012,4,12'
# find settings
settings = Setting.query.order_by(desc(Setting.id)).all()
if len(settings) > 0:
setting = settings[0]
headline = setting.headline
text = setting.setting_text
start_date = setting.start_date.replace("-", ",")
# convert timeline's start date to datetime obj
album_start_date = datetime.datetime.strptime(start_date, "%Y,%m,%d")
# collect all photos
tl = Timeline(headline, text, start_date)
photos = Photo.query.filter(Photo.visibility == True).all()
for photo in photos:
dt = photo.start_date.replace("-", ",")
# convert photo's start date to datetime obj
photo_start_date = datetime.datetime.strptime(dt, "%Y,%m,%d")
days_in_album = (photo_start_date - album_start_date).days + 1
# get No.D after timeline's start date
asset_caption = _("Day %(value)d", value=days_in_album)
text = photo.photo_text + "<BR/><BR/><A href='%s'><i class='icon-zoom-in'></i>%s</A>" % (url_for("photos.show_html", filename=photo.filename), photo.filename)
tl.add_date(startDate=dt, headline=photo.headline, asset_media=url_for("photos.show_thumb", filename=photo.filename), text=text, asset_caption=asset_caption)
return tl.get_json()