Author: batiste.bieler
Date: Sun May 10 07:51:32 2009
New Revision: 522

Modified:
    trunk/pages/models.py
    trunk/pages/tests.py
    trunk/pages/utils.py
    trunk/pages/views.py

Log:
Fix the issue 100, add some doc and test

Modified: trunk/pages/models.py
==============================================================================
--- trunk/pages/models.py       (original)
+++ trunk/pages/models.py       Sun May 10 07:51:32 2009
@@ -93,7 +93,7 @@
          get the calculated status of the page based on published_date,
          published_end_date, and status
          """
-        if settings.PAGE_SHOW_START_DATE:
+        if settings.PAGE_SHOW_START_DATE and self.publication_date:
              if self.publication_date > datetime.now():
                  return self.DRAFT


Modified: trunk/pages/tests.py
==============================================================================
--- trunk/pages/tests.py        (original)
+++ trunk/pages/tests.py        Sun May 10 07:51:32 2009
@@ -616,8 +616,45 @@

          # Make sure the content response we got was in french
          self.assertTrue('Auteur' in response.content)
+
+    def test_21_view_context(self):
+        """
+        Test that the default view can only return the context
+        """

-
+        c = Client()
+        c.login(username= 'batiste', password='b')
+        page_data = self.get_new_page_data()
+        page_data['slug'] = 'page1'
+        # create a page for the example otherwise you will get a Http404  
error
+        response = c.post('/admin/pages/page/add/', page_data)
+        page1 = Content.objects.get_content_slug_by_slug('page1').page
+
+        from pages.views import details
+        from pages.utils import get_request_mock
+        request = get_request_mock()
+        context = details(request, only_context=True)
+        self.assertEqual(context['current_page'], page1)
+
+    def test_22_calculated_status_bug(self):
+        """
+        Test the issue 100
+        http://code.google.com/p/django-page-cms/issues/detail?id=100
+        """
+        setattr(settings, "PAGE_SHOW_START_DATE", True)
+        c = Client()
+        c.login(username= 'batiste', password='b')
+        page_data = self.get_new_page_data()
+        page_data['slug'] = 'page1'
+        # create a page for the example otherwise you will get a Http404  
error
+        response = c.post('/admin/pages/page/add/', page_data)
+        page1 = Content.objects.get_content_slug_by_slug('page1').page
+
+        page1.status = Page.DRAFT
+        page1.save()
+
+        page1.get_calculated_status()
+
      def assertOnlyContextException(self, view):
          """
          If an @auto_render-decorated view returns an HttpResponse and is  
called

Modified: trunk/pages/utils.py
==============================================================================
--- trunk/pages/utils.py        (original)
+++ trunk/pages/utils.py        Sun May 10 07:51:32 2009
@@ -20,11 +20,10 @@
          'SERVER_NAME': 'test',
          'SERVER_PORT': '8000',
      })
-
      # Apply request middleware
      for middleware_method in bh._request_middleware:
          # LocaleMiddleware should never be applied a second time because
-        # it would broke the current real request
+        # it would broke the current real request language
          if 'LocaleMiddleware' not in str(middleware_method.im_class):
              response = middleware_method(request)
      return request
@@ -39,8 +38,7 @@
          return []

      request = get_request_mock()
-
-
+
      try:
          # to avoid circular import
          from pages.views import details

Modified: trunk/pages/views.py
==============================================================================
--- trunk/pages/views.py        (original)
+++ trunk/pages/views.py        Sun May 10 07:51:32 2009
@@ -9,7 +9,7 @@

  def details(request, slug=None, lang=None, ajax=False):
      """
-    This example view get the root pages for navigation
+    This view get the root pages for navigation
      and the current page to display if there is any.

      All is rendered with the current page's template.
@@ -20,12 +20,10 @@
      the template.

      >>> from pages.views import details
-    >>> from pages.utils import get_request_mock
-    >>> request = get_request_mock()
      >>> context = details(request, only_context=True)

      This can be usefull if you want to write your own
-    view and reuse the following code without having to
+    view. You can reuse the following code without having to
      copy and paste it.
      """
      pages = Page.objects.navigation().order_by("tree_id")
@@ -57,6 +55,11 @@
          new_template_name = "body_%s" % template_name
          return new_template_name, locals()

-    return template_name, locals()
+    return template_name, {
+        'pages': pages,
+        'current_page': current_page,
+        'lang': lang,
+        'request': request,
+    }

  details = auto_render(details)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to