本文整理汇总了Python中models.Book.get_latest方法的典型用法代码示例。如果您正苦于以下问题:Python Book.get_latest方法的具体用法?Python Book.get_latest怎么用?Python Book.get_latest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Book
的用法示例。
在下文中一共展示了Book.get_latest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get_latest [as 别名]
def get(self):
auth_level = self.is_user_authorized()
if auth_level == models.AUTH_LEVEL_REGISTERED_USER:
self.redirect('/account/activate/reminder/')
elif auth_level == models.AUTH_LEVEL_ACTIVATED_USER:
today = datetime.utcnow()
request_year = self.request.get('year')
request_month = self.request.get('month')
if not request_year or not request_month:
year = today.year
month = today.month
articles = Article.get_latest_published_student()
else:
year = dec(request_year)
month = dec(request_month)
articles = Article.get_all_published_student_articles_for_month(year, month)
books = Book.get_latest(count=10)
response = render_template('blog_students.html',
year_list=models.BLOG_YEAR_LIST,
month_list=models.MONTH_LIST,
today=today,
requested_year=year,
requested_month=month,
articles=articles,
books=books)
self.response.out.write(response)
else:
response = render_template('index.html')
self.response.out.write(response)
示例2: get
# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import get_latest [as 别名]
def get(self):
auth_level = self.is_user_authorized()
if auth_level == models.AUTH_LEVEL_REGISTERED_USER:
self.redirect("/account/activate/reminder/")
elif auth_level == models.AUTH_LEVEL_ACTIVATED_USER:
today = datetime.utcnow()
year = self.request.get("year")
month = self.request.get("month")
if not year or not month:
year = today.year
month = today.month
else:
year = dec(year)
month = dec(month)
articles = Article.get_all_published_for_month(year, month)
books = Book.get_latest(count=10)
response = render_template(
"blog.html",
year_list=models.BLOG_YEAR_LIST,
month_list=models.MONTH_LIST,
today=today,
requested_year=year,
requested_month=month,
articles=articles,
books=books,
)
self.response.out.write(response)
else:
response = render_template("index.html")
self.response.out.write(response)