Skip to content

Commit

Permalink
Added initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
Udi Bauman authored and Udi Bauman committed Aug 1, 2010
1 parent 4118a38 commit b4fe8ad
Show file tree
Hide file tree
Showing 1,175 changed files with 130,707 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
17 changes: 17 additions & 0 deletions AUTHORS
@@ -0,0 +1,17 @@
Django CMS
==========
* Patrick Lauber
* Jason Zylks
* Simon Meers
* Peter Cicman
* limpbrains :P

Django Page CMS
===============
* Batiste Bieler
* Jannis Leidel
* Antoni Aloy López
* Benjamin Wohlwend
* poweredbypenguins
* homebrew79

37 changes: 37 additions & 0 deletions CHANGELOG.txt
@@ -0,0 +1,37 @@
==== 2.0.0 (2009-11-12) ====

==== 2.0.1 (2009-12-13) ====

- mostly bugfixes (18 tickets closed)
- docs updated
- permissions now working in multisite environment
- home is now graphically designated in tree-view

==== 2.0.2 (2009-12-14) ====

- testsuite working again
- changelog file added

==== 2.1.0 (2010-XX-XX) ====

- language namespaces for apphooks (reverse("de:myview"), reverse("en:myview"))
- video plugin switch to http://github.com/FlashJunior/OSFlashVideoPlayer
- frontediting added (cms.middlware.toolbar.ToolbarMiddleware)
- testsuite works now under sqlite and postgres
- orphaned text embed plugins get now deleted if not referenced in the text anymore
- placeholder templatetag: "theme" attribute removed in favor of "width" (backward incompatible change if theme was used)
- menu is its own app now
- menu modifiers (you can register menu modifiers that can change menu nodes or rearrange them)
- menus are now class based.
- apphooks are now class based and can bring multiple menus and urls.py with them.
- menus and apphooks are auto-discovered now
- example templates look a lot better now.
- languages are not a dropdown anymore but fancy tabs
- placeholderend templatetag added: {% placeholder "content" %}There is no content here{% endplaceholder %}
- plugins can now be used in other apps :) see cms/docs/placeholders.txt
- plugins can now be grouped
- a lot of bugfixes
- the cms now depends on the cms.middleware.media.PlaceholderMediaMiddleware middleware
- templatetags refactored: see cms/docs/templatetags.txt for new signatures.
- placeholder has new option: or and a endbpalceholder templatetag

28 changes: 28 additions & 0 deletions LICENSE
@@ -0,0 +1,28 @@
Copyright (c) 2008, Batiste Bieler
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the author nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 changes: 11 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,11 @@
include AUTHORS
include LICENSE
include README.md
include CHANGELOG.txt
recursive-include cms/locale *
recursive-include cms/templates *
recursive-include cms/media *
recursive-include cms/docs *.txt *.png
recursive-include cms/plugins *
recursive-include menus/templates *
recursive-include mptt/tests/fixtures *.json
66 changes: 66 additions & 0 deletions README.md
@@ -0,0 +1,66 @@
Django CMS 2.0
==============

A Django app for managing hierarchical pages of content in multiple languages, on different sites.

Django CMS handles the navigation rendering for you in multiple languages with internationalization (i18n) slugs,
and the navigation can be extended by your own models.

Pages are rendered with a template that has placeholders which get filled via plugins.
Plugins included at the moment include the following:

* File
* Flash
* Google Map
* Link
* Picture
* HTML Snippet
* Teaser
* Text
* Video
* Twitter


Many more are in the works. Plugins are very easy to write and integrate with your own models.
For a list of 3rd party plugins have a look [here](http://www.django-cms.org/en/extensions/).

Tour & Screenshots
------------------

Can be found [here](http://www.django-cms.org/en/tour/).
Some Sites done with django-cms can be found [here](http://www.django-cms.org/en/sites/)



Documentation
-------------

Can be found [here](http://www.django-cms.org/en/documentation/).

Installation instructions can be found [here](http://www.django-cms.org/en/documentation/2.0/installation/).


Sourcecode
----------

Can be found [here](http://github.com/digi604/django-cms-2.0/) on github.

Help
----

There is a [google group mailinglist](http://groups.google.com/group/django-cms)
You can also visit the project website at [django-cms.org](http://www.django-cms.org/)
or #django-cms on freenet IRC for more info.

For a feature comparison of all the CMS apps available for django see
[CMSComparison](http://code.djangoproject.com/wiki/CMSAppsComparison).

Kudos
-----

- This is a fork of django-page-cms.
- Some icons are from [http://www.famfamfam.com](http://www.famfamfam.com/)
- Video plugin uses [OSFlashVideoPlayer](http://github.com/FlashJunior/OSFlashVideoPlayer)
- Includes [Wymeditor](http://www.wymeditor.org/)
- Tree Component from [jstree.com](http://www.jstree.com/)

21 changes: 21 additions & 0 deletions cms/__init__.py
@@ -0,0 +1,21 @@
VERSION = (2, 1, 0, 'beta3')
if VERSION[-1] != "final": # pragma: no cover
__version__ = '.'.join(map(str, VERSION))
else: # pragma: no cover
__version__ = '.'.join(map(str, VERSION[:-1]))


# patch settings
try:
from django.conf import settings
if 'cms' in settings.INSTALLED_APPS:
from conf import patch_settings
patch_settings()
except ImportError: # pragma: no cover
"""
This exception means that either the application is being built, or is
otherwise installed improperly. Both make running patch_settings
irrelevant.
"""
pass

Binary file added cms/__init__.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions cms/admin/__init__.py
@@ -0,0 +1,10 @@
import pageadmin
import useradmin
import permissionadmin

# Piggyback off admin.autodiscover() to discover cms plugins
from cms import plugin_pool
from cms.apphook_pool import apphook_pool
plugin_pool.plugin_pool.discover_plugins()

apphook_pool.discover_apps()
Binary file added cms/admin/__init__.pyc
Binary file not shown.
190 changes: 190 additions & 0 deletions cms/admin/change_list.py
@@ -0,0 +1,190 @@
from django.conf import settings
from django.contrib.sites.models import Site
from django.contrib.admin.views.main import ChangeList, ALL_VAR, IS_POPUP_VAR,\
ORDER_TYPE_VAR, ORDER_VAR, SEARCH_VAR
from cms.models import Title, PagePermission, Page, PageModerator
from cms.utils import get_language_from_request
from cms.utils.permissions import get_user_sites_queryset
from cms.exceptions import NoHomeFound
from cms.models.moderatormodels import MASK_PAGE, MASK_CHILDREN,\
MASK_DESCENDANTS, PageModeratorState
from menus.utils import find_children



COPY_VAR = "copy"

class CMSChangeList(ChangeList):
real_queryset = False

def __init__(self, request, *args, **kwargs):
super(CMSChangeList, self).__init__(request, *args, **kwargs)
from cms.utils.plugins import current_site
self._current_site = current_site(request)
try:
self.query_set = self.get_query_set(request)
except:
raise
self.get_results(request)

if self._current_site:
request.session['cms_admin_site'] = self._current_site.pk
self.set_sites(request)

def get_query_set(self, request=None):
if COPY_VAR in self.params:
del self.params[COPY_VAR]
qs = super(CMSChangeList, self).get_query_set().drafts()
if request:
site = self._current_site
permissions = Page.permissions.get_change_id_list(request.user, site)

if permissions != Page.permissions.GRANT_ALL:
qs = qs.filter(pk__in=permissions)
self.root_query_set = self.root_query_set.filter(pk__in=permissions)
self.real_queryset = True
qs = qs.filter(site=self._current_site)
qs = qs.order_by('tree_id', 'parent', 'lft')
return qs

def is_filtered(self):
from cms.utils.plugins import SITE_VAR
lookup_params = self.params.copy() # a dictionary of the query string
for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR, SITE_VAR):
if i in lookup_params:
del lookup_params[i]
if not lookup_params.items() and not self.query:
return False
return True

def get_results(self, request):
if self.real_queryset:
super(CMSChangeList, self).get_results(request)
if not self.is_filtered():
self.full_result_count = self.result_count = self.root_query_set.count()
else:
self.full_result_count = self.root_query_set.count()

def set_items(self, request):
lang = get_language_from_request(request)
site = self._current_site
pages = self.get_query_set(request).drafts().order_by('tree_id', 'parent', 'lft').select_related()

perm_edit_ids = Page.permissions.get_change_id_list(request.user, site)
perm_publish_ids = Page.permissions.get_publish_id_list(request.user, site)
perm_advanced_settings_ids = Page.permissions.get_advanced_settings_id_list(request.user, site)
perm_change_list_ids = Page.permissions.get_change_id_list(request.user, site)

if perm_edit_ids and perm_edit_ids != Page.permissions.GRANT_ALL:
pages = pages.filter(pk__in=perm_edit_ids)
#pages = pages.filter(pk__in=perm_change_list_ids)

if settings.CMS_MODERATOR:
# get all ids of public instances, so we can cache them
# TODO: add some filtering here, so the set is the same like page set...
published_public_page_id_set = Page.objects.public().filter(published=True).values_list('id', flat=True)

# get all moderations for current user and all pages
pages_moderator_set = PageModerator.objects \
.filter(user=request.user, page__site=self._current_site) \
.values_list('page', 'moderate_page', 'moderate_children', 'moderate_descendants')
# put page / moderations into singe dictionary, where key is page.id
# and value is sum of moderations, so if he can moderate page and descendants
# value will be MASK_PAGE + MASK_DESCENDANTS
page_moderator = map(lambda item: (item[0], item[1] * MASK_PAGE + item[2] * MASK_CHILDREN + item[3] * MASK_DESCENDANTS), pages_moderator_set)
page_moderator = dict(page_moderator)

# page moderator states
pm_qs = PageModeratorState.objects.filter(page__site=self._current_site)
pm_qs.query.group_by = ['page_id']
pagemoderator_states_id_set = pm_qs.values_list('page', flat=True)

ids = []
root_pages = []
pages = list(pages)
all_pages = pages[:]
try:
home_pk = Page.objects.drafts().get_home(self.current_site()).pk
except NoHomeFound:
home_pk = 0
for page in pages:
children = []

# note: We are using change_list permission here, because we must
# display also pages which user must not edit, but he haves a
# permission for adding a child under this page. Otherwise he would
# not be able to add anything under page which he can't change.
if not page.parent_id or (perm_change_list_ids != Page.permissions.GRANT_ALL and not int(page.parent_id) in perm_change_list_ids):
page.root_node = True
else:
page.root_node = False
ids.append(page.pk)

if settings.CMS_PERMISSION:
# caching the permissions
page.permission_edit_cache = perm_edit_ids == Page.permissions.GRANT_ALL or page.pk in perm_edit_ids
page.permission_publish_cache = perm_publish_ids == Page.permissions.GRANT_ALL or page.pk in perm_publish_ids
page.permission_advanced_settings_cache = perm_publish_ids == Page.permissions.GRANT_ALL or page.pk in perm_advanced_settings_ids
page.permission_user_cache = request.user

if settings.CMS_MODERATOR:
# set public instance existence state
page.public_published_cache = page.publisher_public_id in published_public_page_id_set

# moderation for current user
moderation_value = 0
try:
moderation_value = page_moderator[page.pk]
except:
pass
page._moderation_value_cahce = moderation_value
page._moderation_value_cache_for_user_id = request.user.pk

#moderation states
page._has_moderator_state_chache = page.pk in pagemoderator_states_id_set

if page.root_node or self.is_filtered():
page.last = True
if len(children):
children[-1].last = False
page.menu_level = 0
root_pages.append(page)
if page.parent_id:
page.get_cached_ancestors(ascending=True)
else:
page.ancestors_ascending = []
page.home_pk_cache = home_pk
if not self.is_filtered():
find_children(page, pages, 1000, 1000, [], -1, soft_roots=False, request=request, no_extended=True, to_levels=1000)
else:
page.childrens = []

# TODO: OPTIMIZE!!
titles = Title.objects.filter(page__in=ids)
for page in all_pages:# add the title and slugs and some meta data
page.title_cache = {}
page.all_languages = []
for title in titles:
if title.page_id == page.pk:
page.title_cache[title.language] = title
if not title.language in page.all_languages:
page.all_languages.append(title.language)
page.all_languages.sort()
self.root_pages = root_pages

def get_items(self):
return self.root_pages

def set_sites(self, request):
"""Sets sites property to current instance - used in tree view for
sites combo.
"""
if settings.CMS_PERMISSION:
self.sites = get_user_sites_queryset(request.user)
else:
self.sites = Site.objects.all()
self.has_access_to_multiple_sites = len(self.sites) > 1

def current_site(self):
return self._current_site

Binary file added cms/admin/change_list.pyc
Binary file not shown.
Empty file added cms/admin/dialog/__init__.py
Empty file.
Binary file added cms/admin/dialog/__init__.pyc
Binary file not shown.

0 comments on commit b4fe8ad

Please sign in to comment.