当前位置: 首页>>代码示例>>Python>>正文


Python Book.get_latest方法代码示例

本文整理汇总了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)
开发者ID:spaceone,项目名称:mils-secure,代码行数:33,代码来源:handlers.py

示例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)
开发者ID:atulg,项目名称:mils-secure,代码行数:34,代码来源:www.py


注:本文中的models.Book.get_latest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。