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


Python zinnia_tags.get_calendar_entries函数代码示例

本文整理汇总了Python中zinnia.templatetags.zinnia_tags.get_calendar_entries函数的典型用法代码示例。如果您正苦于以下问题:Python get_calendar_entries函数的具体用法?Python get_calendar_entries怎么用?Python get_calendar_entries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_calendar_entries函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_calendar_entries_object_context

    def test_get_calendar_entries_object_context(self):
        self.publish_entry()
        source_context = Context({'object': object()})
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context)
        self.assertEqual(
            context['previous_month'],
            self.make_local(self.entry.creation_date).date().replace(day=1))
        self.assertEqual(context['next_month'], None)

        params = {'title': 'My second entry',
                  'content': 'My second content',
                  'tags': 'zinnia, test',
                  'status': PUBLISHED,
                  'creation_date': datetime(2008, 1, 15),
                  'slug': 'my-second-entry'}
        second_entry = Entry.objects.create(**params)
        second_entry.sites.add(self.site)

        source_context = Context({'object': self.entry})
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context)
        self.assertEqual(
            context['previous_month'],
            self.make_local(second_entry.creation_date).date().replace(day=1))
        self.assertEqual(context['next_month'], None)

        source_context = Context({'object': second_entry})
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context)
        self.assertEqual(context['previous_month'], None)
        self.assertEqual(
            context['next_month'],
            self.make_local(self.entry.creation_date).date().replace(day=1))
开发者ID:ArturFis,项目名称:django-blog-zinnia,代码行数:34,代码来源:test_templatetags.py

示例2: test_get_calendar_entries_no_prev_next

 def test_get_calendar_entries_no_prev_next(self):
     self.publish_entry()
     source_context = Context()
     with self.assertNumQueries(2):
         context = get_calendar_entries(source_context, 2010, 1)
     self.assertEqual(context['previous_month'], None)
     self.assertEqual(context['next_month'], None)
开发者ID:ArturFis,项目名称:django-blog-zinnia,代码行数:7,代码来源:test_templatetags.py

示例3: test_get_calendar_entries_incomplete_year_month

    def test_get_calendar_entries_incomplete_year_month(self):
        self.publish_entry()
        source_context = Context()
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context, year=2009)
        self.assertEqual(
            context['previous_month'],
            self.make_local(self.entry.creation_date).date().replace(day=1))
        self.assertEqual(context['next_month'], None)

        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context, month=1)
        self.assertEqual(
            context['previous_month'],
            self.make_local(self.entry.creation_date).date().replace(day=1))
        self.assertEqual(context['next_month'], None)
开发者ID:ArturFis,项目名称:django-blog-zinnia,代码行数:16,代码来源:test_templatetags.py

示例4: test_get_calendar_entries_no_params

    def test_get_calendar_entries_no_params(self):
        source_context = Context()
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context)
        self.assertEqual(context['previous_month'], None)
        self.assertEqual(context['next_month'], None)
        self.assertEqual(context['template'],
                         'zinnia/tags/entries_calendar.html')

        self.publish_entry()
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context)
        self.assertEqual(
            context['previous_month'],
            self.make_local(self.entry.creation_date).date().replace(day=1))
        self.assertEqual(context['next_month'], None)
开发者ID:ArturFis,项目名称:django-blog-zinnia,代码行数:16,代码来源:test_templatetags.py

示例5: test_get_calendar_entries_day_context

 def test_get_calendar_entries_day_context(self):
     self.publish_entry()
     source_context = Context({'month': date(2009, 1, 15)})
     with self.assertNumQueries(2):
         context = get_calendar_entries(source_context)
     self.assertEqual(context['previous_month'], None)
     self.assertEqual(
         context['next_month'],
         self.make_local(self.entry.creation_date).date().replace(day=1))
开发者ID:ArturFis,项目名称:django-blog-zinnia,代码行数:9,代码来源:test_templatetags.py

示例6: test_get_calendar_entries_full_params

 def test_get_calendar_entries_full_params(self):
     self.publish_entry()
     source_context = Context()
     with self.assertNumQueries(2):
         context = get_calendar_entries(source_context, 2009, 1,
                                        template='custom_template.html')
     self.assertEqual(context['previous_month'], None)
     self.assertEqual(
         context['next_month'],
         self.make_local(self.entry.creation_date).date().replace(day=1))
     self.assertEqual(context['template'], 'custom_template.html')
开发者ID:ArturFis,项目名称:django-blog-zinnia,代码行数:11,代码来源:test_templatetags.py

示例7: test_get_calendar_entries

    def test_get_calendar_entries(self):
        source_context = Context()
        with self.assertNumQueries(3):
            context = get_calendar_entries(source_context)
        self.assertEquals(context['previous_month'], None)
        self.assertEquals(context['next_month'], None)
        self.assertEquals(context['template'], 'zinnia/tags/calendar.html')

        self.publish_entry()
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context,
                                           template='custom_template.html')
        self.assertEquals(context['previous_month'], datetime(2010, 1, 1))
        self.assertEquals(context['next_month'], None)
        self.assertEquals(context['template'], 'custom_template.html')

        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context, 2009, 1)
        self.assertEquals(context['previous_month'], None)
        self.assertEquals(context['next_month'], datetime(2010, 1, 1))

        source_context = Context({'month': datetime(2009, 1, 1)})
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context)
        self.assertEquals(context['previous_month'], None)
        self.assertEquals(context['next_month'], datetime(2010, 1, 1))

        source_context = Context({'month': datetime(2010, 1, 1)})
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context)
        self.assertEquals(context['previous_month'], None)
        self.assertEquals(context['next_month'], None)

        params = {'title': 'My second entry',
                  'content': 'My second content',
                  'tags': 'zinnia, test',
                  'status': PUBLISHED,
                  'creation_date': datetime(2008, 1, 1),
                  'slug': 'my-second-entry'}
        site = Site.objects.get_current()
        second_entry = Entry.objects.create(**params)
        second_entry.sites.add(site)

        source_context = Context()
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context, 2009, 1)
        self.assertEquals(context['previous_month'], datetime(2008, 1, 1))
        self.assertEquals(context['next_month'], datetime(2010, 1, 1))
        with self.assertNumQueries(2):
            context = get_calendar_entries(source_context)
        self.assertEquals(context['previous_month'], datetime(2010, 1, 1))
        self.assertEquals(context['next_month'], None)
开发者ID:VickiFu,项目名称:django-blog-zinnia,代码行数:52,代码来源:templatetags.py

示例8: test_get_calendar_entries

    def test_get_calendar_entries(self):
        source_context = Context()
        context = get_calendar_entries(source_context)
        self.assertEquals(context["previous_month"], None)
        self.assertEquals(context["next_month"], None)
        self.assertEquals(context["template"], "zinnia/tags/calendar.html")

        self.publish_entry()
        context = get_calendar_entries(source_context, template="custom_template.html")
        self.assertEquals(context["previous_month"], datetime(2010, 1, 1, tzinfo=timezone.utc))
        self.assertEquals(context["next_month"], None)
        self.assertEquals(context["template"], "custom_template.html")

        context = get_calendar_entries(source_context, 2009, 1)
        self.assertEquals(context["previous_month"], None)
        self.assertEquals(context["next_month"], datetime(2010, 1, 1, tzinfo=timezone.utc))
        source_context = Context({"month": datetime(2009, 1, 1)})
        context = get_calendar_entries(source_context)
        self.assertEquals(context["previous_month"], None)
        self.assertEquals(context["next_month"], datetime(2010, 1, 1, tzinfo=timezone.utc))

        source_context = Context({"month": datetime(2010, 1, 1)})
        context = get_calendar_entries(source_context)
        self.assertEquals(context["previous_month"], None)
        self.assertEquals(context["next_month"], None)

        params = {
            "title": "My second entry",
            "content": "My second content",
            "tags": "zinnia, test",
            "status": PUBLISHED,
            "creation_date": datetime(2008, 1, 1, tzinfo=timezone.utc),
            "slug": "my-second-entry",
        }
        site = Site.objects.get_current()
        second_entry = Entry.objects.create(**params)
        second_entry.sites.add(site)

        source_context = Context()
        context = get_calendar_entries(source_context, 2009, 1)
        self.assertEquals(context["previous_month"], datetime(2008, 1, 1, tzinfo=timezone.utc))
        self.assertEquals(context["next_month"], datetime(2010, 1, 1, tzinfo=timezone.utc))
        context = get_calendar_entries(source_context)
        self.assertEquals(context["previous_month"], datetime(2010, 1, 1, tzinfo=timezone.utc))
        self.assertEquals(context["next_month"], None)
开发者ID:aparo,项目名称:django-blog-zinnia,代码行数:45,代码来源:templatetags.py


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