本文整理匯總了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()