Author: batiste.bieler
Date: Sat Jul 11 06:22:03 2009
New Revision: 603

Modified:
    trunk/example/settings.py
    trunk/pages/admin/__init__.py
    trunk/pages/templatetags/pages_tags.py
    trunk/pages/tests/pages_tests.py

Log:
Fix a broken test

Modified: trunk/example/settings.py
==============================================================================
--- trunk/example/settings.py   (original)
+++ trunk/example/settings.py   Sat Jul 11 06:22:03 2009
@@ -108,14 +108,16 @@
  # django.utils.translation -- that module depends on the settings.
  gettext_noop = lambda s: s

-# language you want to into the CMS
+# languages you want to translate into the CMS.
  PAGE_LANGUAGES = (
      ('de', gettext_noop('German')),
      ('fr-ch', gettext_noop('Swiss french')),
      ('en-us', gettext_noop('US English')),
  )

-# You should add here all language you want to accept as valid client  
language
+# You should add here all language you want to accept as valid client
+# language. By default we copy the PAGE_LANGUAGES constant and add some  
other
+# similar languages.
  languages = list(PAGE_LANGUAGES)
  languages.append(('fr-fr', gettext_noop('French')))
  languages.append(('fr-be', gettext_noop('Belgium french')))
@@ -139,7 +141,7 @@
      ('pages/editor.html', 'raw editor'),
  )

-# A test runner that use the coverage module
+# A test runner that use the test coverage module
  TEST_RUNNER = "test_runner.run_tests"

  try:

Modified: trunk/pages/admin/__init__.py
==============================================================================
--- trunk/pages/admin/__init__.py       (original)
+++ trunk/pages/admin/__init__.py       Sat Jul 11 06:22:03 2009
@@ -322,6 +322,17 @@
          return super(PageAdmin, self).change_view(request, object_id,
                                                          extra_context)

+    def add_view(self, request, form_url='', extra_context=None):
+        """The 'add' admin view for the Page model."""
+        extra_context = {
+            'language': get_language_from_request(request),
+            'page_languages': settings.PAGE_LANGUAGES,
+        }
+        template = get_template_from_request(request)
+        #extra_context['placeholders'] = get_placeholders(template)
+        return super(PageAdmin, self).add_view(request, form_url,
+                                                            extra_context)
+
      def has_add_permission(self, request):
          """Return true if the current user has permission to add a new
          page."""

Modified: trunk/pages/templatetags/pages_tags.py
==============================================================================
--- trunk/pages/templatetags/pages_tags.py      (original)
+++ trunk/pages/templatetags/pages_tags.py      Sat Jul 11 06:22:03 2009
@@ -135,7 +135,6 @@
      lang -- the wanted language (defaults to None, uses request object  
else)
      """
      lang = context.get('lang', None)
-    path = context.get('path', None)
      # if the page is a SafeUnicode, try to use it like a slug
      if isinstance(page, SafeUnicode) or isinstance(page, unicode):
          page = Page.objects.from_path(page, lang)

Modified: trunk/pages/tests/pages_tests.py
==============================================================================
--- trunk/pages/tests/pages_tests.py    (original)
+++ trunk/pages/tests/pages_tests.py    Sat Jul 11 06:22:03 2009
@@ -2,7 +2,7 @@
  """Django page CMS test suite module"""
  import django
  from django.test import TestCase
-import settings
+from pages import settings
  from pages.models import Page, Content, PagePermission
  from django.test.client import Client
  from django.template import Template, RequestContext, TemplateDoesNotExist
@@ -120,7 +120,7 @@
          """Test the site framework, and test if it's possible to
          disable it"""

-        """
+
          # this kind of hacks doesn't work anymore
          setattr(settings, "SITE_ID", 2)
          setattr(settings, "PAGE_USE_SITE_ID", True)
@@ -175,22 +175,21 @@
          setattr(settings, "PAGE_USE_SITE_ID", False)

          # we should get everything
-        self.assertEqual(Page.objects.on_site().count(), 3)"""
+        self.assertEqual(Page.objects.on_site().count(), 3)

      def test_07_languages(self):
          """Test post a page with different languages
-        and test that the default view works correctly."""
+        and test that the admin views works correctly."""
          c = Client()
          user = c.login(username= 'batiste', password='b')

-        # test that the default language setting is used add page admin
-        # and not accept-language in HTTP requests.
-        """setattr(settings, "PAGE_DEFAULT_LANGUAGE", 'de')
+        # test that the client language setting is used in add page admin
+        c.cookies["django_language"] = 'de'
          response = c.get('/admin/pages/page/add/')
          self.assertContains(response, 'value="de" selected="selected"')
-        setattr(settings, "PAGE_DEFAULT_LANGUAGE", 'fr-ch')
+        c.cookies["django_language"] = 'fr-ch'
          response = c.get('/admin/pages/page/add/')
-        self.assertContains(response, 'value="fr-ch"  
selected="selected"')"""
+        self.assertContains(response, 'value="fr-ch" selected="selected"')

          page_data = self.get_new_page_data()
          page_data["title"] = 'english title'

--~--~---------~--~----~------------~-------~--~----~
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