Author: batiste.bieler
Date: Sat Jun 20 07:50:50 2009
New Revision: 577
Modified:
trunk/ (props changed)
trunk/pages/__init__.py
trunk/pages/admin/__init__.py
trunk/pages/admin/forms.py
trunk/pages/admin/utils.py
trunk/pages/admin/views.py
trunk/pages/admin/widgets.py
trunk/pages/context_processors.py
trunk/pages/http.py
trunk/pages/managers.py
trunk/pages/models.py
trunk/pages/settings.py
trunk/pages/templatetags/__init__.py
trunk/pages/templatetags/pages_tags.py
trunk/pages/tests.py
trunk/pages/utils.py
trunk/pages/views.py
trunk/requirements/external_apps.txt
Log:
Reformat and add docstring. Comment out edit_area external.
Modified: trunk/pages/__init__.py
==============================================================================
--- trunk/pages/__init__.py (original)
+++ trunk/pages/__init__.py Sat Jun 20 07:50:50 2009
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
+"""Django page CMS module."""
VERSION = (1, 0, 4)
__version__ = '.'.join(map(str, VERSION))
Modified: trunk/pages/admin/__init__.py
==============================================================================
--- trunk/pages/admin/__init__.py (original)
+++ trunk/pages/admin/__init__.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"""Page Admin module."""
from os.path import join
from inspect import isclass, getmembers
@@ -23,6 +24,7 @@
from pages.admin.views import traduction, get_content, sub_menu,
change_status, modify_content
class PageAdmin(admin.ModelAdmin):
+ """Page Admin class."""
form = PageForm
exclude = ['author', 'parent']
@@ -75,8 +77,7 @@
)]
def __call__(self, request, url):
-
- # Delegate to the appropriate method, based on the URL.
+ """Delegate to the appropriate method, based on the URL."""
if url is None:
return self.list_pages(request)
elif url == 'jsi18n':
@@ -102,13 +103,19 @@
elif url.endswith('/change-status-hidden'):
return change_status(request, unquote(url[:-21]), Page.HIDDEN)
ret = super(PageAdmin, self).__call__(request, url)
-
-
- """
- Persist the language and template GET arguments, both on "save and
keep
- editing" and when switching language and template (which also
submits)
+
+ """Persist the language and template GET arguments, both on "save
and
+ keep editing" and when switching language and template (which
+ also submits)
"""
- if HttpResponseRedirect == type(ret) and
(request.GET.get('new_language', False) or request.GET.get('new_template',
False) or request.GET.get('language', False) or request.GET.get('template',
False)):
+
+ # TODO: clean that code
+ new_lang = request.GET.get('new_language', False)
+ lang = request.GET.get('language', False)
+ template = request.GET.get('template', False)
+
+ if HttpResponseRedirect == type(ret) and (new_lang or lang or
+ template):
for item in ret.items():
if 'Location' == item[0]:
new_uri = item[1] + \
@@ -119,8 +126,8 @@
return ret
def i18n_javascript(self, request):
- """
- Displays the i18n JavaScript that the Django admin requires.
+ """Displays the i18n JavaScript that the Django admin
+ requires.
This takes into account the USE_I18N setting. If it's set to
False, the
generated JavaScript will be leaner and faster.
@@ -132,9 +139,8 @@
return javascript_catalog(request, packages='pages')
def save_model(self, request, obj, form, change):
- """
- Move the page in the tree if necessary and save every placeholder
- Content object.
+ """Move the page in the tree if necessary and save every
+ placeholder Content object.
"""
language = form.cleaned_data['language']
@@ -174,9 +180,8 @@
obj.invalidate()
def get_fieldsets(self, request, obj=None):
- """
- Add fieldsets of placeholders to the list of already existing
- fieldsets.
+ """Add fieldsets of placeholders to the list of already
+ existing fieldsets.
"""
additional_fieldsets = []
@@ -206,10 +211,8 @@
return given_fieldsets + additional_fieldsets
def save_form(self, request, form, change):
- """
- Given a ModelForm return an unsaved instance. ``change`` is True if
- the object is being changed, and False if it's being added.
- """
+ """Given a ModelForm return an unsaved instance. ``change`` is
True if
+ the object is being changed, and False if it's being added."""
instance = super(PageAdmin, self).save_form(request, form, change)
instance.template = form.cleaned_data['template']
if not change:
@@ -217,10 +220,8 @@
return instance
def get_widget(self, name, fallback=Textarea):
- """
- Given the name of a placeholder return a Widget subclass
- like Textarea or TextInput.
- """
+ """Given the name of a placeholder return a Widget subclass
+ like Textarea or TextInput."""
if name and '.' in name:
name = str(name)
module_name, class_name = name.rsplit('.', 1)
@@ -233,10 +234,8 @@
return widget
def get_form(self, request, obj=None, **kwargs):
- """
- Get PageForm for the Page model and modify its fields depending on
- the request.
- """
+ """Get PageForm for the Page model and modify its fields depending
on
+ the request."""
form = super(PageAdmin, self).get_form(request, obj, **kwargs)
language = get_language_from_request(request, obj)
@@ -251,12 +250,12 @@
template = get_template_from_request(request, obj)
if settings.PAGE_TEMPLATES:
template_choices = list(settings.PAGE_TEMPLATES)
- template_choices.insert(0, (settings.DEFAULT_PAGE_TEMPLATE,
_('Default template')))
+ template_choices.insert(0, (settings.DEFAULT_PAGE_TEMPLATE,
+ _('Default template')))
form.base_fields['template'].choices = template_choices
form.base_fields['template'].initial = force_unicode(template)
# handle most of the logic of connected models
-
if obj:
for mod in get_connected_models():
model = mod['model']
@@ -301,9 +300,7 @@
return form
def change_view(self, request, object_id, extra_context=None):
- """
- The 'change' admin view for the Page model.
- """
+ """The 'change' admin view for the Page model."""
extra_context = {
'language': get_language_from_request(request),
'page_languages': settings.PAGE_LANGUAGES,
@@ -326,26 +323,22 @@
extra_context)
def has_add_permission(self, request):
- """
- Return true if the current user has permission to add a new page.
- """
+ """Return true if the current user has permission to add a new
+ page."""
if not settings.PAGE_PERMISSION:
return super(PageAdmin, self).has_add_permission(request)
else:
return has_page_add_permission(request)
def has_change_permission(self, request, obj=None):
- """
- Return true if the current user has permission on the page.
- Return the string 'All' if the user has all rights.
- """
+ """Return true if the current user has permission on the page.
+ Return the string 'All' if the user has all rights."""
if settings.PAGE_PERMISSION and obj is not None:
return obj.has_page_permission(request)
return super(PageAdmin, self).has_change_permission(request, obj)
def has_delete_permission(self, request, obj=None):
- """
- Return true if the current user has permission on the page.
+ """Return true if the current user has permission on the page.
Return the string 'All' if the user has all rights.
"""
if settings.PAGE_PERMISSION and obj is not None:
@@ -353,9 +346,7 @@
return super(PageAdmin, self).has_delete_permission(request, obj)
def list_pages(self, request, template_name=None, extra_context=None):
- """
- List root pages
- """
+ """List root pages"""
# HACK: overrides the changelist template and later resets it to
None
if template_name:
self.change_list_template = template_name
@@ -370,9 +361,8 @@
return change_list
def move_page(self, request, page_id, extra_context=None):
- """
- Move the page to the requested target, at the given position
- """
+ """Move the page to the requested target, at the given
+ position"""
page = Page.objects.get(pk=page_id)
target = request.POST.get('target', None)
Modified: trunk/pages/admin/forms.py
==============================================================================
--- trunk/pages/admin/forms.py (original)
+++ trunk/pages/admin/forms.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"""Page CMS forms"""
from django import forms
from django.template.defaultfilters import slugify
from django.utils.translation import ugettext_lazy as _
@@ -7,6 +8,7 @@
from pages.models import Page, Content
class PageForm(forms.ModelForm):
+ """Form for page creation"""
title = forms.CharField(
label=_('Title'),
widget=forms.TextInput(),
@@ -38,6 +40,7 @@
model = Page
def clean_slug(self):
+ """Handle move action on the pages"""
slug = slugify(self.cleaned_data['slug'])
target = self.data.get('target', None)
Modified: trunk/pages/admin/utils.py
==============================================================================
--- trunk/pages/admin/utils.py (original)
+++ trunk/pages/admin/utils.py Sat Jun 20 07:50:50 2009
@@ -3,7 +3,7 @@
from pages import settings
def get_connected_models():
-
+ """Return all the connected models with this CMS"""
if not settings.PAGE_CONNECTED_MODELS:
return []
Modified: trunk/pages/admin/views.py
==============================================================================
--- trunk/pages/admin/views.py (original)
+++ trunk/pages/admin/views.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"""Admin views"""
from django.shortcuts import get_object_or_404
from django.http import HttpResponse, Http404
from django.contrib.admin.views.decorators import staff_member_required
@@ -10,9 +11,7 @@
from pages.http import auto_render
def change_status(request, page_id, status):
- """
- Switch the status of a page
- """
+ """Switch the status of a page."""
if request.method == 'POST':
try:
page = Page.objects.get(pk=page_id)
@@ -25,6 +24,7 @@
change_status = staff_member_required(change_status)
def modify_content(request, page_id, content_id, language_id):
+ """Modify the content of a page."""
if request.method == 'POST':
content = request.POST.get('content', False)
if not content:
@@ -42,6 +42,7 @@
modify_content = staff_member_required(modify_content)
def traduction(request, page_id, language_id):
+ """Traduction helper."""
page = Page.objects.get(pk=page_id)
context = {}
lang = language_id
@@ -53,6 +54,7 @@
traduction = auto_render(traduction)
def get_content(request, page_id, content_id):
+ """Get the content for a particular page"""
content_instance = get_object_or_404(Content, pk=content_id)
return HttpResponse(content_instance.body)
get_content = staff_member_required(get_content)
Modified: trunk/pages/admin/widgets.py
==============================================================================
--- trunk/pages/admin/widgets.py (original)
+++ trunk/pages/admin/widgets.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"""Default Page CMS widgets."""
from os.path import join
from django.conf import settings
from django.forms import TextInput, Textarea
@@ -13,6 +14,7 @@
from django.utils import simplejson
class AutoCompleteTagInput(TextInput):
+ """An autocompete widget"""
class Media:
js = [join(PAGES_MEDIA_URL, path) for path in (
'javascript/jquery.js',
@@ -32,6 +34,7 @@
'admin/pages/page/widgets/autocompletetaginput.html',
context))
class RichTextarea(Textarea):
+ """A RichTextarea widget."""
class Media:
js = [join(PAGES_MEDIA_URL, path) for path in (
'javascript/jquery.js',
@@ -59,6 +62,7 @@
from tinymce import widgets as tinymce_widgets
class TinyMCE(tinymce_widgets.TinyMCE):
+ """TinyMCE widget."""
def __init__(self, content_language=None, attrs=None,
mce_attrs={}):
self.mce_attrs = mce_attrs
self.mce_attrs.update({
@@ -72,6 +76,7 @@
super(TinyMCE, self).__init__(content_language, attrs,
mce_attrs)
class WYMEditor(Textarea):
+ """WYMEditor widget."""
class Media:
js = [join(PAGES_MEDIA_URL, path) for path in (
@@ -108,6 +113,8 @@
'admin/pages/page/widgets/wymeditor.html', context))
class markItUpMarkdown(Textarea):
+ """markItUpMarkdown widget."""
+
class Media:
js = [join(PAGES_MEDIA_URL, path) for path in (
'javascript/jquery.js',
@@ -130,6 +137,8 @@
'admin/pages/page/widgets/markitupmarkdown.html', context))
class markItUpHTML(Textarea):
+ """markItUpHTML widget."""
+
class Media:
js = [join(PAGES_MEDIA_URL, path) for path in (
'javascript/jquery.js',
Modified: trunk/pages/context_processors.py
==============================================================================
--- trunk/pages/context_processors.py (original)
+++ trunk/pages/context_processors.py Sat Jun 20 07:50:50 2009
@@ -1,9 +1,8 @@
+"""Context processors for Page CMS."""
from pages import settings
def media(request):
- """
- Adds media-related context variables to the context.
- """
+ """Adds media-related context variables to the context."""
return {
'PAGES_MEDIA_URL': settings.PAGES_MEDIA_URL,
'PAGE_USE_SITE_ID': settings.PAGE_USE_SITE_ID
Modified: trunk/pages/http.py
==============================================================================
--- trunk/pages/http.py (original)
+++ trunk/pages/http.py Sat Jun 20 07:50:50 2009
@@ -1,3 +1,4 @@
+"""Page CMS functions related to the request object"""
from django.core.handlers.base import BaseHandler
from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse, HttpResponseRedirect
@@ -6,6 +7,7 @@
from pages import settings
def get_request_mock():
+ """Build a request mock that can be used for testing."""
bh = BaseHandler()
bh.load_middleware()
request = WSGIRequest({
@@ -27,9 +29,8 @@
pass
def auto_render(func):
- """
- A decorator which automatically inserts the template path into the
context
- and calls the render_to_response shortcut
+ """A decorator which automatically inserts the template path into the
+ context and calls the render_to_response shortcut
"""
def _dec(request, *args, **kwargs):
template_override = kwargs.pop('template_name', None)
@@ -52,9 +53,8 @@
def get_template_from_request(request, obj=None):
- """
- Gets a valid template from different sources or falls back to the
default
- template.
+ """Gets a valid template from different sources or falls back to the
+ default template.
"""
if settings.PAGE_TEMPLATES is None:
return settings.DEFAULT_PAGE_TEMPLATE
@@ -68,9 +68,7 @@
return settings.DEFAULT_PAGE_TEMPLATE
def get_language_from_request(request, current_page=None):
- """
- Return the most obvious language according the request
- """
+ """Return the most obvious language according the request."""
# first try the GET parameter
language = request.GET.get('language', None)
if language:
Modified: trunk/pages/managers.py
==============================================================================
--- trunk/pages/managers.py (original)
+++ trunk/pages/managers.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*-
+"""Django page CMS managers
+
+Manager Classes
+-------------
+
+ .. class:: PageManager
+ Page manager methods
+
+ .. class:: ContentManager
+ Content manager methods
+
+"""
import itertools
from datetime import datetime
from django.db import models, connection
@@ -9,6 +21,7 @@
from pages import settings
class PageManager(models.Manager):
+ """Page manager methods"""
def on_site(self, site_id=None):
if settings.PAGE_USE_SITE_ID:
@@ -18,15 +31,11 @@
return self
def root(self):
- """
- Return a queryset with pages that don't have parents, a.k.a. root.
- """
+ """Return a queryset with pages that don't have parents."""
return self.filter(parent__isnull=True)
def valid_targets(self, page_id, request, perms, page=None):
- """
- Give valid targets to move a page into the tree
- """
+ """QuerySet of valid targets for moving a page into the tree"""
if page is None:
page = self.get(pk=page_id)
exclude_list = []
@@ -40,13 +49,15 @@
return self.exclude(id__in=exclude_list)
def navigation(self):
+ """Fisrt level navigation filter"""
return
self.on_site().filter(status=self.model.PUBLISHED).filter(parent__isnull=True)
def hidden(self):
+ """Hidden page filter"""
return self.on_site().filter(status=self.model.HIDDEN)
def filter_published(self, queryset):
- """Resuable filter for published page"""
+ """Published page filter"""
if settings.PAGE_USE_SITE_ID:
queryset = queryset.filter(sites=settings.SITE_ID)
@@ -76,11 +87,10 @@
publication_end_date__lte=datetime.now())
class ContentManager(models.Manager):
+ """Content manager methods"""
def sanitize(self, content):
- """
- Sanitize the content to avoid XSS and so
- """
+ """Sanitize the content to avoid XSS"""
import html5lib
from html5lib import sanitizer
p = html5lib.HTMLParser(tokenizer=sanitizer.HTMLSanitizer)
@@ -88,9 +98,7 @@
return p.parse(content).toxml()[19:-14]
def set_or_create_content(self, page, language, cnttype, body):
- """
- set or create a content for a particular page and language
- """
+ """Set or create a content for a particular page and language."""
if settings.PAGE_SANITIZE_USER_INPUT:
body = self.sanitize(body)
try:
@@ -104,9 +112,7 @@
return content
def create_content_if_changed(self, page, language, cnttype, body):
- """
- set or create a content for a particular page and language
- """
+ """Set or create a content for a particular page and language"""
if settings.PAGE_SANITIZE_USER_INPUT:
body = self.sanitize(body)
try:
@@ -119,10 +125,8 @@
content = self.create(page=page, language=language, body=body,
type=cnttype)
def get_content(self, page, language, ctype, language_fallback=False):
- """
- Gets the latest content for a particular page and language. Falls
back
- to another language if wanted.
- """
+ """Gets the latest content for a particular page and language.
+ Falls back to another language if wanted."""
PAGE_CONTENT_DICT_KEY = "page_content_dict_%d_%s"
if not language:
language = settings.PAGE_DEFAULT_LANGUAGE
@@ -150,10 +154,8 @@
return ''
def get_content_slug_by_slug(self, slug):
- """
- Returns the latest Content slug object that match the given slug
for
- the current site domain.
- """
+ """Returns the latest Content slug object that match the given
+ slug for the current site domain."""
content = self.filter(type='slug', body=slug)
if settings.PAGE_USE_SITE_ID:
content = content.filter(page__sites__id=settings.SITE_ID)
@@ -165,11 +167,11 @@
return content
def get_page_ids_by_slug(self, slug):
- """
- Return all the page id according to a slug
- """
- sql = '''SELECT pages_content.page_id,
MAX(pages_content.creation_date)
- FROM pages_content WHERE (pages_content.type = %s AND
pages_content.body =%s)
+ """Return all the page id according to a slug"""
+ sql = '''SELECT pages_content.page_id,
+ MAX(pages_content.creation_date)
+ FROM pages_content WHERE (pages_content.type = %s
+ AND pages_content.body =%s)
GROUP BY pages_content.page_id'''
cursor = connection.cursor()
@@ -177,12 +179,11 @@
return [c[0] for c in cursor.fetchall()]
class PagePermissionManager(models.Manager):
-
+ """Hierachic page permission"""
+
def get_page_id_list(self, user):
- """
- Give a list of page where the user has rights or the string "All"
if
- the user has all rights.
- """
+ """Give a list of page where the user has rights or the
string "All"
+ if the user has all rights."""
if user.is_superuser:
return 'All'
id_list = []
Modified: trunk/pages/models.py
==============================================================================
--- trunk/pages/models.py (original)
+++ trunk/pages/models.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*-
+"""Django page CMS models
+
+Model Classes
+-------------
+
+ .. class:: Page
+ A simple hierarchical page model
+
+ .. class:: Content
+ A block of content, tied to a page, for a particular language
+
+"""
from datetime import datetime
from django.db import models
@@ -17,9 +29,8 @@
class Page(models.Model):
- """
- A simple hierarchical page model
- """
+ """A simple hierarchical page model"""
+
# some class constants to refer to, e.g. Page.DRAFT
DRAFT = 0
PUBLISHED = 1
@@ -76,6 +87,7 @@
verbose_name_plural = _('pages')
def save(self, *args, **kwargs):
+ """Override save method"""
if not self.status:
self.status = self.DRAFT
# Published pages should always have a publication date
@@ -92,10 +104,8 @@
super(Page, self).save(*args, **kwargs)
def get_calculated_status(self):
- """
- get the calculated status of the page based on published_date,
- published_end_date, and status
- """
+ """get the calculated status of the page based on
+ published_date, published_end_date, and status"""
if settings.PAGE_SHOW_START_DATE and self.publication_date:
if self.publication_date > datetime.now():
return self.DRAFT
Modified: trunk/pages/settings.py
==============================================================================
--- trunk/pages/settings.py (original)
+++ trunk/pages/settings.py Sat Jun 20 07:50:50 2009
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
-"""
-Convenience module that provides access to custom settings for the
``pages``
+"""Convenience module that provides access to custom settings for the
+``pages``
application. Provides default settings for the ``pages`` application when
the
-project ``settings`` module does not contain the appropriate settings.
-
-"""
+project ``settings`` module does not contain the appropriate settings."""
from os.path import join
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
Modified: trunk/pages/templatetags/__init__.py
==============================================================================
--- trunk/pages/templatetags/__init__.py (original)
+++ trunk/pages/templatetags/__init__.py Sat Jun 20 07:50:50 2009
@@ -0,0 +1 @@
+"""Page CMS template tag module"""
\ No newline at end of file
Modified: trunk/pages/templatetags/pages_tags.py
==============================================================================
--- trunk/pages/templatetags/pages_tags.py (original)
+++ trunk/pages/templatetags/pages_tags.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"""Page CMS page_tags template tags"""
from django import template
from django.utils.safestring import SafeUnicode, mark_safe
from django.utils.translation import ugettext_lazy as _
@@ -166,6 +167,7 @@
"""Tags"""
class GetContentNode(template.Node):
+ """Get content node"""
def __init__(self, page, content_type, varname, lang):
self.page = page
self.content_type = content_type
@@ -215,6 +217,7 @@
class LoadPagesNode(template.Node):
+ """Load page+ node"""
def render(self, context):
if (not context.has_key('pages')):
context['pages'] = Page.objects.navigation()
Modified: trunk/pages/tests.py
==============================================================================
--- trunk/pages/tests.py (original)
+++ trunk/pages/tests.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"""Django page CMS test suite module"""
import django
from django.test import TestCase
import settings
@@ -9,10 +10,12 @@
from django.http import HttpResponse, HttpResponseRedirect
class PagesTestCase(TestCase):
+ """Django page CMS test suite class"""
fixtures = ['tests.json']
counter = 1
def get_new_page_data(self):
+ """Helper method for creating page datas"""
page_data = {'title':'test page %d' % self.counter,
'slug':'test-page-%d' % self.counter, 'language':'en-us',
'sites':[2], 'status':Page.PUBLISHED}
@@ -20,9 +23,8 @@
return page_data
def test_01_add_page(self):
- """
- Test that the add admin page could be displayed via the admin
- """
+ """Test that the add admin page could be displayed via the
+ admin"""
c = Client()
c.login(username= 'batiste', password='b')
response = c.get('/admin/pages/page/add/')
@@ -30,9 +32,7 @@
def test_02_create_page(self):
- """
- Test that a page can be created via the admin
- """
+ """Test that a page can be created via the admin."""
setattr(settings, "SITE_ID", 2)
c = Client()
c.login(username= 'batiste', password='b')
@@ -47,9 +47,7 @@
self.assertNotEqual(page.last_modification_date, None)
def test_03_slug_collision(self):
- """
- Test a slug collision
- """
+ """Test a slug collision."""
setattr(settings, "PAGE_UNIQUE_SLUG_REQUIRED", True)
c = Client()
@@ -72,9 +70,7 @@
self.assertNotEqual(page1.id, page2.id)
def test_04_details_view(self):
- """
- Test the details view
- """
+ """Test the details view"""
c = Client()
c.login(username= 'batiste', password='b')
@@ -103,9 +99,7 @@
self.assertEqual(response.status_code, 200)
def test_05_edit_page(self):
- """
- Test that a page can edited via the admin
- """
+ """Test that a page can edited via the admin"""
c = Client()
c.login(username= 'batiste', password='b')
page_data = self.get_new_page_data()
@@ -124,9 +118,8 @@
self.assertEqual(body, 'changed body')
def test_06_site_framework(self):
- """
- Test the site framework, and test if it's possible to disable it
- """
+ """Test the site framework, and test if it's possible to
+ disable it"""
setattr(settings, "SITE_ID", 2)
setattr(settings, "PAGE_USE_SITE_ID", True)
@@ -182,10 +175,8 @@
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
- """
+ """Test post a page with different languages
+ and test that the default view works correctly."""
c = Client()
user = c.login(username= 'batiste', password='b')
@@ -211,7 +202,7 @@
major, middle, minor = [int(v) for v in django_version]
else:
major, middle = [int(v) for v in django_version]
- if major >=1 and middle > 0:
+ if major >= 1 and middle > 0:
response = c.get('/admin/pages/page/%d/?language=de' % page.id)
self.assertContains(response, 'value="de" selected="selected"')
@@ -250,9 +241,7 @@
def test_08_revision(self):
- """
- Test that a page can edited several times
- """
+ """Test that a page can edited several times."""
c = Client()
c.login(username= 'batiste', password='b')
page_data = self.get_new_page_data()
Modified: trunk/pages/utils.py
==============================================================================
--- trunk/pages/utils.py (original)
+++ trunk/pages/utils.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"""A collection of functions for Page CMS"""
from django.conf import settings as django_settings
from django.template import TemplateDoesNotExist
from django.template.loader_tags import ExtendsNode, ConstantIncludeNode
@@ -10,9 +11,7 @@
from pages.http import get_request_mock, get_language_from_request
def get_placeholders(template_name):
- """
- Return a list of PlaceholderNode found in the given template
- """
+ """Return a list of PlaceholderNode found in the given template"""
try:
temp = loader.get_template(template_name)
except TemplateDoesNotExist:
@@ -32,9 +31,8 @@
return plist
def placeholders_recursif(nodelist, plist, blist):
- """
- Recursively search into a template node list for PlaceholderNode node
- """
+ """Recursively search into a template node list for PlaceholderNode
+ node."""
for node in nodelist:
@@ -77,11 +75,8 @@
if isinstance(node, BlockNode):
blist.pop()
-
def has_page_add_permission(request, page=None):
- """
- Return true if the current user has permission to add a new page.
- """
+ """Return true if the current user has permission to add a new page."""
if not settings.PAGE_PERMISSION:
return True
else:
@@ -93,6 +88,7 @@
# TODO: move this in the manager
def get_page_from_slug(slug, request, lang=None):
+ """Get the page according to a slug."""
from pages.models import Content, Page
from django.core.urlresolvers import reverse
lang = get_language_from_request(request)
Modified: trunk/pages/views.py
==============================================================================
--- trunk/pages/views.py (original)
+++ trunk/pages/views.py Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+"""Default example views"""
from django.http import Http404, HttpResponsePermanentRedirect
from django.shortcuts import get_object_or_404
from django.contrib.sites.models import SITE_CACHE
@@ -9,8 +10,7 @@
def details(request, slug=None, lang=None, ajax=False):
- """
- This 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.
@@ -25,8 +25,7 @@
This can be usefull if you want to write your own
view. You can reuse the following code without having to
- copy and paste it.
- """
+ copy and paste it."""
pages = Page.objects.navigation().order_by("tree_id")
current_page = False
Modified: trunk/requirements/external_apps.txt
==============================================================================
--- trunk/requirements/external_apps.txt (original)
+++ trunk/requirements/external_apps.txt Sat Jun 20 07:50:50 2009
@@ -1,4 +1,5 @@
-e svn+http://django-mptt.googlecode.com/svn/tr...@119#egg=django-mptt
-e
svn+http://django-tagging.googlecode.com/svn/tr...@154#egg=django-tagging
html5lib>=0.10
+django>=1.0.2
django-page-cms
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---