def makePageFriendlyPost(post): tz = lambda d: dthelper.utcToTimezone(targetTimezone=config.TIMEZONE, date=d) parseFormat = "%Y-%m-%d %H:%M:%S%z" return { "id" : post["id"], "title" : post["title"], "authorId" : post["authorId"], "author" : post["author"], "slug" : post["slug"], "permalink" : "/post/{0}/{1}/{2}".format(post["publishedYear"], post["publishedMonth"], post["slug"]), "rawContent" : post["content"], "renderedContent" : renderMarkdown(rawMarkdown=post["content"]), "createdDateTime" : dthelper.formatDateTime(date=tz(post["createdDateTime"]), parseFormat=parseFormat), "publishedDateTime" : "" if post["publishedDateTime"] == None else dthelper.formatDateTime(date=tz(post["publishedDateTime"]), parseFormat=parseFormat), "publishedDate" : "" if post["publishedDateTime"] == None else dthelper.formatDate(date=tz(post["publishedDateTime"]), parseFormat=parseFormat), "publishedDateUSFormat": "" if post["publishedDateTime"] == None else dthelper.formatDate(date=tz(post["publishedDateTime"]), outputFormat="%m/%d/%Y", parseFormat=parseFormat), "publishedTime" : "" if post["publishedDateTime"] == None else dthelper.formatTime(date=tz(post["publishedDateTime"]), parseFormat=parseFormat), "publishedTime12Hour" : "" if post["publishedDateTime"] == None else dthelper.formatTime(date=tz(post["publishedDateTime"]), outputFormat="%I:%M %p", parseFormat=parseFormat), "publishedYear" : post["publishedYear"], "publishedMonth" : post["publishedMonth"], "postStatusId" : post["postStatusId"], "status" : post["status"], "tagList" : post["tagList"], "tags" : "" if not post["tagList"] else post["tagList"].split(","), "tagIdList" : post["tagIdList"], "tagIds" : "" if not post["tagIdList"] else post["tagIdList"].split(","), }
def makeAdminTableFriendlyPost(post): tz = lambda d: dthelper.utcToTimezone(targetTimezone=config.TIMEZONE, date=d) parseFormat = "%Y-%m-%d %H:%M:%S%z" return { "id" : post["id"], "title" : post["title"], "permalink" : "/post/{0}/{1}/{2}".format(post["publishedYear"], post["publishedMonth"], post["slug"]), "publishedDateTime" : "" if post["publishedDateTime"] == None else dthelper.formatDateTime(date=tz(post["publishedDateTime"]), parseFormat=parseFormat), "publishedDate" : "" if post["publishedDateTime"] == None else dthelper.formatDate(date=tz(post["publishedDateTime"]), parseFormat=parseFormat), "publishedDateUSFormat": "" if post["publishedDateTime"] == None else dthelper.formatDate(date=tz(post["publishedDateTime"]), outputFormat="%m/%d/%Y", parseFormat=parseFormat), "publishedTime" : "" if post["publishedDateTime"] == None else dthelper.formatTime(date=tz(post["publishedDateTime"]), parseFormat=parseFormat), "publishedTime12Hour" : "" if post["publishedDateTime"] == None else dthelper.formatTime(date=tz(post["publishedDateTime"]), outputFormat="%I:%M %p", parseFormat=parseFormat), "postStatusId" : post["postStatusId"], "status" : post["status"], "tagList" : post["tagList"], "tagIdList" : post["tagIdList"], }