Skip to content

Commit

Permalink
Merge pull request #121 from remik/django-1.9
Browse files Browse the repository at this point in the history
Django 1.9 and few others
  • Loading branch information
batiste committed Dec 22, 2015
2 parents eb8eef9 + 90e7a90 commit fe33156
Show file tree
Hide file tree
Showing 34 changed files with 316 additions and 351 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ local_settings.py
pages/testproj/media/
screenshot_*
*~
.tox
ghostdriver.log
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@ language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
env:
- DJANGO="Django<1.9"
- DJANGO="Django<1.10"
matrix:
exclude:
# Django 1.9+ no longer supports python 3.2/3.3
- python: "3.2"
env: DJANGO="Django<1.10"
- python: "3.3"
env: DJANGO="Django<1.10"
# command to install dependencies
install:
- "pip install -r requirements/external_apps.txt"
- "pip install -r requirements/test_apps.txt"
- "pip install coveralls"
- "pip install $DJANGO"
# command to run tests
script: "coverage run --source=pages pages/test_runner.py"
after_success:
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Evgeniy Gulitsyn
Cans https://github.com/cans
Francesco Facconi
Markus "mjtorn" Törnqvist
Remigiusz Dymecki
15 changes: 12 additions & 3 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@

This file describe new features and incompatibilites between released version of the CMS.

Release TODO
=============

Released the TODO.

* Support Django 1.9
* Support Python 3.4, 3.5
* Cleanup

Release 1.8.2
=============

Released the 20 of December 2015.

* Migrations files were not included in 1.8.1
* Add a pages_push and pages_pull command that permit to pull and push content between
* Add a pages_push and pages_pull command that permit to pull and push content between
different hosts in rather smart and non breaking way.

Release 1.8.1
Expand Down Expand Up @@ -76,8 +85,8 @@ Backward Incompatible Changes
------------------------------

* HTML sanitization and the dependecy to the html5lib have been removed.
* Remove support for WYMEditor, markItUp and CKEditor editors. Rational:
Those Widget are untested, not updated and were created when packages for those widgets didn't exists as python packages (django-ckeditor, django-wymeditor, django-markitup).
* Remove support for WYMEditor, markItUp and CKEditor editors. Rational:
Those Widget are untested, not updated and were created when packages for those widgets didn't exists as python packages (django-ckeditor, django-wymeditor, django-markitup).
If you need those editors please install the package and register the widget to use them directly in your templates.
* The pages_navigation context processor has been removed. This is not useful as {% load_pages %} already load the pages_navigation variable in the context.
* Removal of the video placeholder. Rational: Used as an example but add no real value to the CMS.
Expand Down
4 changes: 2 additions & 2 deletions doc/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Features
Dependencies & Compatibility
============================

* Django 1.8
* Python 2.7, 3.3
* Django 1.8, 1.9
* Python 2.7, 3.3, 3.4, 3.5
* `django-mptt <https://github.com/django-mptt/django-mptt>`_ is needed
* `django-taggit if needed <https://github.com/alex/django-taggit>`_ (if PAGE_TAGGING = True)
* `django-haystack if needed <http://haystacksearch.org/>`_
Expand Down
36 changes: 16 additions & 20 deletions example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
PROJECT_DIR = os.path.dirname(__file__)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@domain.com'),
Expand Down Expand Up @@ -40,22 +39,20 @@
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
STATIC_URL = '/static/'

STATICFILES_DIRS = [
os.path.join(PROJECT_DIR, "bootstrap"),
]

FIXTURE_DIRS = [os.path.join(PROJECT_DIR, 'fixtures')]

# Make this unique, and don't share it with anybody.
SECRET_KEY = '*xq7m@)*f2awoj!spa0(jibsrz9%c0d=e(g)v*!17y(vx0ue_3'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)

TEMPLATE_CONTEXT_PROCESSORS = (
_TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.i18n",
"django.core.context_processors.debug",
Expand All @@ -64,6 +61,17 @@
"pages.context_processors.media",
)

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'DIRS': [os.path.join(PROJECT_DIR, 'templates')],
'OPTIONS': {
'context_processors': _TEMPLATE_CONTEXT_PROCESSORS
},
},
]

INTERNAL_IPS = ('127.0.0.1',)

MIDDLEWARE_CLASSES = (
Expand All @@ -77,13 +85,6 @@

ROOT_URLCONF = 'example.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_DIR, 'templates'),
)

#CACHE_BACKEND = "locmem:///?timeout=300&max_entries=6000"

CACHES = {
Expand Down Expand Up @@ -111,7 +112,6 @@
#'ckeditor', # if commented a fallback widget will be used
)

PAGE_TINYMCE = False
PAGE_TAGGING = False

# Default language code for this installation. All choices can be found here:
Expand Down Expand Up @@ -140,13 +140,10 @@

PAGE_DEFAULT_TEMPLATE = 'index.html'


PAGE_TEMPLATES = (
('index.html', 'Bootstrap index'),
)

PAGE_SANITIZE_USER_INPUT = True

SITE_ID = 1
PAGE_USE_SITE_ID = True

Expand Down Expand Up @@ -207,4 +204,3 @@
from local_settings import *
except ImportError:
pass

32 changes: 16 additions & 16 deletions example/urls.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@

from django.conf import settings
from django.conf.urls import url, include, patterns
from django.conf.urls import url, include
from django.conf.urls import handler404, handler500
from django.conf.urls.static import static
from django.contrib import admin
from pages.views import details

admin.autodiscover()

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls.static import static


urlpatterns = patterns('',
(r'^i18n/', include('django.conf.urls.i18n')),
(r'^admin/', include(admin.site.urls)),
urlpatterns = [
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^admin/', include(admin.site.urls)),
#url(r'^search/', include('haystack.urls'), name='haystack_search'),
)
]

if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT, show_indexes=True)
#urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT, show_indexes=True)

#if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT, show_indexes=True)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT, show_indexes=True)

if 'ckeditor' in settings.INSTALLED_APPS:
urlpatterns += patterns('',
(r'^ckeditor/', include('ckeditor.urls')),
)
urlpatterns += [
url(r'^ckeditor/', include('ckeditor.urls')),
]

urlpatterns += patterns('',
urlpatterns += [
# this gonna match /admin if someone forget the traling slash
(r'^', include('pages.urls')),
)
url(r'^', include('pages.urls')),
]
12 changes: 4 additions & 8 deletions pages/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@
from pages.templatetags.pages_tags import PlaceholderNode
from pages.admin.forms import make_form
from pages.admin.views import traduction, get_content, sub_menu
from pages.admin.views import list_pages_ajax
from pages.admin.views import change_status, modify_content, delete_content
from pages.admin.views import move_page
import pages.widgets

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
from django.conf import settings as global_settings
from django.http import HttpResponseRedirect, Http404
from django.contrib.admin.utils import unquote
from django.contrib.admin.sites import AlreadyRegistered
if global_settings.USE_I18N:
from django.views.i18n import javascript_catalog
Expand Down Expand Up @@ -89,11 +86,11 @@ def add_action(cls, method):
cls.actions.append(method)

def urls(self):
from django.conf.urls import patterns, url, include
from django.conf.urls import url

# Admin-site-wide views.
urlpatterns = patterns('',
url(r'^$', self.list_pages, name='admin:pages_page_changelist'),
urlpatterns = [
url(r'^$', self.list_pages, name='page-changelist'),
url(r'^(?P<page_id>[0-9]+)/traduction/(?P<language_id>[-\w]+)/$',
traduction, name='page-traduction'),
url(r'^(?P<page_id>[0-9]+)/get-content/(?P<content_id>[0-9]+)/$',
Expand All @@ -108,7 +105,7 @@ def urls(self):
move_page, name='page-move-page'),
url(r'^(?P<page_id>[0-9]+)/change-status/$',
change_status, name='page-change-status'),
)
]

urlpatterns += super(PageAdmin, self).urls

Expand Down Expand Up @@ -367,4 +364,3 @@ class AliasAdmin(admin.ModelAdmin):
admin.site.register(PageAlias, AliasAdmin)
except AlreadyRegistered:
pass

27 changes: 17 additions & 10 deletions pages/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
from pages.utils import get_placeholders
from pages.phttp import get_language_from_request

from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponse, Http404, HttpResponseRedirect
from django.contrib.admin.views.decorators import staff_member_required
from django.views.decorators.csrf import csrf_exempt
from django.core.urlresolvers import reverse


@csrf_exempt
def change_status(request, page_id):
Expand All @@ -26,6 +27,7 @@ def change_status(request, page_id):
raise Http404
change_status = staff_member_required(change_status)


def list_pages_ajax(request, invalid_move=False):
"""Render pages table for ajax function."""
language = get_language_from_request(request)
Expand All @@ -36,11 +38,11 @@ def list_pages_ajax(request, invalid_move=False):
'language': language,
'pages': pages,
}
return render_to_response("admin/pages/page/change_list_table.html",
context,
context_instance=RequestContext(request))
return render(request, "admin/pages/page/change_list_table.html",
context)
list_pages_ajax = staff_member_required(list_pages_ajax)


@csrf_exempt
def modify_content(request, page_id, content_type, language_id):
"""Modify the content of a page."""
Expand All @@ -65,6 +67,7 @@ def modify_content(request, page_id, content_type, language_id):
raise Http404
modify_content = staff_member_required(modify_content)


@csrf_exempt
def delete_content(request, page_id, language_id):
page = get_object_or_404(Page, pk=page_id)
Expand All @@ -76,10 +79,11 @@ def delete_content(request, page_id, language_id):
c.delete()

destination = request.POST.get('next', request.META.get('HTTP_REFERER',
'/admin/pages/page/%s/' % page_id))
reverse("admin:pages_page_change", args=[page_id])))
return HttpResponseRedirect(destination)
delete_content = staff_member_required(delete_content)


def traduction(request, page_id, language_id):
"""Traduction helper."""
page = Page.objects.get(pk=page_id)
Expand All @@ -89,20 +93,22 @@ def traduction(request, page_id, language_id):
Content.objects.get_content(page, language_id, "title")
is None
)
return render_to_response('pages/traduction_helper.html', {
return render(request, 'pages/traduction_helper.html', {
'page':page,
'lang':lang,
'language_error':language_error,
'placeholders':placeholders,
}, context_instance=RequestContext(request))
})
traduction = staff_member_required(traduction)


def get_content(request, page_id, content_id):
"""Get the content for a particular page"""
content = Content.objects.get(pk=content_id)
return HttpResponse(content.body)
get_content = staff_member_required(get_content)


@csrf_exempt
def move_page(request, page_id, extra_context=None):
"""Move the page to the requested target, at the given
Expand Down Expand Up @@ -130,16 +136,17 @@ def move_page(request, page_id, extra_context=None):
return list_pages_ajax(request, invalid_move)
return HttpResponseRedirect('../../')


def sub_menu(request, page_id):
"""Render the children of the requested page with the sub_menu
template."""
page = Page.objects.get(id=page_id)
pages = page.children.all()
page_languages = settings.PAGE_LANGUAGES
return render_to_response("admin/pages/page/sub_menu.html", {
return render(request, "admin/pages/page/sub_menu.html", {
'can_publish': request.user.has_perm('pages.can_publish'),
'page':page,
'pages':pages,
'page_languages':page_languages,
}, context_instance=RequestContext(request))
})
sub_menu = staff_member_required(sub_menu)
1 change: 0 additions & 1 deletion pages/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Context processors for Page CMS."""
from pages import settings
from pages.models import Page


def media(request):
Expand Down

0 comments on commit fe33156

Please sign in to comment.