Permalink
Browse files

cms settings changed, added merging with django settings

video plugin upgrade
some tests fixed
yaml test fixtures changed to json

copy is broken, permission framework is broken, currently: 9 Failures, 1 Error
  • Loading branch information...
1 parent 2963ae2 commit 7353b46ba14dd30bf8db8d0981f35df5bde67fad @pcicman pcicman committed Oct 16, 2009
Showing with 741 additions and 1,072 deletions.
  1. +3 −1 cms/__init__.py
  2. +2 −2 cms/admin/change_list.py
  3. +3 −3 cms/admin/dialog/forms.py
  4. +2 −2 cms/admin/dialog/views.py
  5. +8 −7 cms/admin/forms.py
  6. +21 −20 cms/admin/pageadmin.py
  7. +1 −1 cms/admin/permissionadmin.py
  8. +1 −1 cms/admin/useradmin.py
  9. +8 −7 cms/admin/views.py
  10. +2 −3 cms/admin/widgets.py
  11. +3 −4 cms/appresolver.py
  12. +2 −1 cms/cache/signals.py
  13. +44 −0 cms/conf/__init__.py
  14. +98 −0 cms/conf/global_settings.py
  15. +41 −0 cms/conf/patch.py
  16. +1 −1 cms/context_processors.py
  17. +2 −2 cms/management/commands/publisher_publish.py
  18. +5 −6 cms/middleware/multilingual.py
  19. +1 −1 cms/models/managers.py
  20. +1 −1 cms/models/pagemodel.py
  21. +0 −1 cms/models/permissionmodels.py
  22. +1 −1 cms/models/pluginmodel.py
  23. +1 −2 cms/models/query.py
  24. +1 −1 cms/models/titlemodels.py
  25. +4 −4 cms/plugin_base.py
  26. +4 −5 cms/plugin_pool.py
  27. +1 −2 cms/plugins/file/cms_plugins.py
  28. +2 −2 cms/plugins/file/models.py
  29. +2 −2 cms/plugins/link/cms_plugins.py
  30. +2 −2 cms/plugins/picture/cms_plugins.py
  31. +2 −2 cms/plugins/snippet/cms_plugins.py
  32. +1 −1 cms/plugins/teaser/cms_plugins.py
  33. +1 −1 cms/plugins/text/managers.py
  34. +4 −4 cms/plugins/text/widgets/tinymce_widget.py
  35. +3 −4 cms/plugins/text/widgets/wymeditor_widget.py
  36. +114 −0 cms/plugins/video/migrations/0002_color_mute_controller.py
  37. +15 −1 cms/plugins/video/models.py
  38. +7 −3 cms/plugins/video/templates/cms/plugins/video.html
  39. +0 −131 cms/settings.py
  40. +6 −5 cms/signals.py
  41. +1 −1 cms/templatetags/cms_tags.py
  42. +9 −2 cms/tests/__init__.py
  43. +115 −3 cms/tests/base.py
  44. +1 −0 cms/tests/fixtures/permission.json
  45. +0 −525 cms/tests/fixtures/permission.yaml
  46. +54 −130 cms/tests/page.py
  47. +70 −151 cms/tests/permmod.py
  48. +49 −0 cms/tests/site.py
  49. +1 −1 cms/urls.py
  50. +1 −1 cms/utils/__init__.py
  51. +4 −4 cms/utils/admin.py
  52. +3 −4 cms/utils/i18n.py
  53. +6 −6 cms/utils/moderator.py
  54. +1 −1 cms/utils/navigation.py
  55. +3 −3 cms/utils/page.py
  56. +2 −2 cms/utils/permissions.py
  57. +1 −1 cms/views.py
View
@@ -1,5 +1,7 @@
-
VERSION = (2, 0, 0, 'RC1')
__version__ = '.'.join(map(str, VERSION))
+# patch settings
+from conf import patch_settings
+patch_settings()
View
@@ -1,9 +1,9 @@
+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 import settings
from cms.utils import get_language_from_request, find_children
-from django.contrib.sites.models import Site
from cms.utils.permissions import get_user_sites_queryset
from cms.exceptions import NoHomeFound
from cms.models.moderatormodels import MASK_PAGE, MASK_CHILDREN,\
@@ -1,13 +1,13 @@
from django import forms
from django.utils.translation import ugettext_lazy as _
-from cms import settings as cms_settings
+from django.conf import settings
def get_copy_dialog_form(request):
fields = {}
- if cms_settings.CMS_PERMISSION:
+ if settings.CMS_PERMISSION:
fields['copy_permissions'] = forms.BooleanField(label=_('Copy permissions'), required=False, initial=True)
- if cms_settings.CMS_MODERATOR:
+ if settings.CMS_MODERATOR:
fields['copy_moderation'] = forms.BooleanField(label=_('Copy moderation'), required=False, initial=True)
Form = type('CopyDialogForm', (forms.BaseForm,), { 'base_fields': fields })
return Form
@@ -2,12 +2,12 @@
from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.admin.views.decorators import staff_member_required
from django.http import Http404, HttpResponse
+from django.conf import settings
from cms.models import Page
-from cms import settings as cms_settings
@staff_member_required
def get_copy_dialog(request, page_id):
- if not cms_settings.CMS_PERMISSION or not cms_settings.CMS_MODERATOR:
+ if not settings.CMS_PERMISSION or not settings.CMS_MODERATOR:
return HttpResponse('')
page = get_object_or_404(Page, pk=page_id)
View
@@ -1,3 +1,4 @@
+from django.conf import settings
from django import forms
from django.template.defaultfilters import slugify
from django.utils.translation import ugettext as _, ugettext_lazy
@@ -7,7 +8,7 @@
from django.contrib.contenttypes.models import ContentType
from django.db.models.fields import BooleanField
-from cms import settings as cms_settings
+
from cms.models import Page, Title, PagePermission, PageUser, ACCESS_PAGE,\
PageUserGroup
from cms.utils.urlutils import any_path_re
@@ -25,7 +26,7 @@ class PageAddForm(forms.ModelForm):
help_text=_('The default title'))
slug = forms.CharField(label=_("Slug"), widget=forms.TextInput(),
help_text=_('The part of the title that is used in the URL'))
- language = forms.ChoiceField(label=_("Language"), choices=cms_settings.CMS_LANGUAGES,
+ language = forms.ChoiceField(label=_("Language"), choices=settings.CMS_LANGUAGES,
help_text=_('The current language of the content fields.'))
class Meta:
@@ -39,10 +40,10 @@ def __init__(self, *args, **kwargs):
if not self.fields['site'].initial:
self.fields['site'].initial = Site.objects.get_current().pk
if self.fields['parent'].initial and \
- cms_settings.CMS_TEMPLATE_INHERITANCE_MAGIC in \
- [name for name, value in cms_settings.CMS_TEMPLATES]:
+ settings.CMS_TEMPLATE_INHERITANCE_MAGIC in \
+ [name for name, value in settings.CMS_TEMPLATES]:
# non-root pages default to inheriting their template
- self.fields['template'].initial = cms_settings.CMS_TEMPLATE_INHERITANCE_MAGIC
+ self.fields['template'].initial = settings.CMS_TEMPLATE_INHERITANCE_MAGIC
def clean(self):
cleaned_data = self.cleaned_data
@@ -69,13 +70,13 @@ def clean_slug(self):
def clean_language(self):
language = self.cleaned_data['language']
- if not language in dict(cms_settings.CMS_LANGUAGES).keys():
+ if not language in dict(settings.CMS_LANGUAGES).keys():
raise ValidationError("Given language does not match language settings.")
return language
class PageForm(PageAddForm):
- APPLICATION_URLS = (('', '----------'), ) + cms_settings.CMS_APPLICATIONS_URLS
+ APPLICATION_URLS = (('', '----------'), ) + settings.CMS_APPLICATIONS_URLS
menu_title = forms.CharField(label=_("Menu Title"), widget=forms.TextInput(),
help_text=_('Overwrite what is displayed in the menu'), required=False)
View
@@ -1,4 +1,22 @@
-from cms import settings
+import os
+from copy import deepcopy
+from django.conf import settings
+from django.contrib import admin
+from django.contrib.admin.options import IncorrectLookupParameters
+from django.contrib.admin.util import unquote
+from django.contrib.sites.models import Site
+from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
+from django.core.urlresolvers import reverse
+from django.forms import Widget, Textarea, CharField
+from django.http import HttpResponseRedirect, HttpResponse, Http404,\
+ HttpResponseBadRequest, HttpResponseForbidden
+from django.shortcuts import render_to_response, get_object_or_404
+from django.template.context import RequestContext
+from django.template.defaultfilters import title
+from django.utils.encoding import force_unicode
+from django.utils.functional import curry
+from django.utils.translation import ugettext as _
+
from cms.admin.change_list import CMSChangeList
from cms.admin.dialog.views import get_copy_dialog
from cms.admin.forms import PageForm, PageAddForm
@@ -20,23 +38,6 @@
will_require_moderation
from cms.utils.permissions import has_page_add_permission, \
get_user_permission_level, has_global_change_permissions_permission
-from copy import deepcopy
-from django.contrib import admin
-from django.contrib.admin.options import IncorrectLookupParameters
-from django.contrib.admin.util import unquote
-from django.contrib.sites.models import Site
-from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
-from django.core.urlresolvers import reverse
-from django.forms import Widget, Textarea, CharField
-from django.http import HttpResponseRedirect, HttpResponse, Http404,\
- HttpResponseBadRequest, HttpResponseForbidden
-from django.shortcuts import render_to_response, get_object_or_404
-from django.template.context import RequestContext
-from django.template.defaultfilters import title
-from django.utils.encoding import force_unicode
-from django.utils.functional import curry
-from django.utils.translation import ugettext as _
-from os.path import join
class PageAdmin(admin.ModelAdmin):
form = PageForm
@@ -122,14 +123,14 @@ class PageAdmin(admin.ModelAdmin):
class Media:
css = {
- 'all': [join(settings.CMS_MEDIA_URL, path) for path in (
+ 'all': [os.path.join(settings.CMS_MEDIA_URL, path) for path in (
'css/rte.css',
'css/pages.css',
'css/change_form.css',
'css/jquery.dialog.css',
)]
}
- js = [join(settings.CMS_MEDIA_URL, path) for path in (
+ js = [os.path.join(settings.CMS_MEDIA_URL, path) for path in (
'js/lib/jquery.js',
'js/lib/jquery.query.js',
'js/lib/ui.core.js',
@@ -1,4 +1,4 @@
-from cms import settings
+from django.conf import settings
from cms.admin.forms import GlobalPagePermissionAdminForm, \
PagePermissionInlineAdminForm
from cms.admin.models import BaseInlineFormSetWithQuerySet
View
@@ -1,4 +1,4 @@
-from cms import settings
+from django.conf import settings
from cms.admin.forms import PageUserForm, PageUserGroupForm
from cms.admin.permissionadmin import GenericCmsPermissionAdmin
from cms.exceptions import NoPermissionsException
View
@@ -1,17 +1,18 @@
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponse, Http404, HttpResponseForbidden, HttpResponseBadRequest
from django.contrib.admin.views.decorators import staff_member_required
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ugettext, ugettext_lazy as _
from django.template.context import RequestContext
+from django.conf import settings
+from django.template.defaultfilters import escapejs, force_escape
+from django.views.decorators.http import require_POST
+from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
-from cms import settings
from cms.models import Page, Title, CMSPlugin, MASK_CHILDREN, MASK_DESCENDANTS,\
MASK_PAGE
from cms.plugin_pool import plugin_pool
-from django.template.defaultfilters import escapejs, force_escape
-from django.views.decorators.http import require_POST
from cms.utils.admin import render_admin_menu_item
-from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
+
@require_POST
def change_status(request, page_id):
@@ -69,11 +70,11 @@ def add_plugin(request):
position = None
if not page.has_change_permission(request):
- return HttpResponseForbidden(_("You do not have permission to change this page"))
+ return HttpResponseForbidden(ugettext("You do not have permission to change this page"))
# Sanity check to make sure we're not getting bogus values from JavaScript:
if not language or not language in [ l[0] for l in settings.LANGUAGES ]:
- return HttpResponseBadRequest(_("Language must be set to a supported language!"))
+ return HttpResponseBadRequest(ugettext("Language must be set to a supported language!"))
plugin = CMSPlugin(page=page, language=language, plugin_type=plugin_type, position=position, placeholder=placeholder)
View
@@ -3,7 +3,6 @@
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string
-from cms.settings import CMS_MEDIA_URL
from django.forms.widgets import Widget, Select
from cms.models import PageUser
@@ -16,14 +15,14 @@ def __init__(self, attrs=None, installed=None, list=None):
self.attrs = {}
class Media:
- js = [join(CMS_MEDIA_URL, path) for path in (
+ js = [join(settings.CMS_MEDIA_URL, path) for path in (
'js/lib/jquery.js',
'js/lib/ui.core.js',
'js/lib/ui.sortable.js',
'js/plugin_editor.js',
)]
css = {
- 'all': [join(CMS_MEDIA_URL, path) for path in (
+ 'all': [join(settings.CMS_MEDIA_URL, path) for path in (
'css/plugin_editor.css',
)]
}
View
@@ -1,5 +1,4 @@
-from django.conf import settings
-from cms import settings as cms_settings
+from django.conf import settings
from django.core.urlresolvers import RegexURLResolver, Resolver404, reverse
from cms.utils.moderator import get_page_queryset
from cms.models import Title
@@ -140,7 +139,7 @@ def urlpatterns(self):
# use draft(). This can be done, because url patterns are used just
# in frontend
- is_draft = not cms_settings.CMS_MODERATOR
+ is_draft = not settings.CMS_MODERATOR
try:
home = Page.objects.get_home()
home_titles = home.title_set.all()
@@ -153,7 +152,7 @@ def urlpatterns(self):
urls = []
for title in title_qs.filter(application_urls__gt="").select_related():
- if cms_settings.CMS_FLAT_URLS:
+ if settings.CMS_FLAT_URLS:
if title.language in home_slugs:
path = title.slug.split(home_slugs[title.language] + "/", 1)[-1]
else:
View
@@ -1,6 +1,7 @@
+from django.conf import settings
from django.db.models import signals
from django.contrib.auth.models import User, Group
-from cms import settings
+
from cms.models import PagePermission, GlobalPagePermission, Page
from cms.cache.permissions import clear_user_permission_cache,\
clear_permission_cache
View
@@ -0,0 +1,44 @@
+from django.conf import settings
+from patch import pre_patch, post_patch, post_patch_check
+
+ALREADY_PATCHED = False
+
+def patch_settings():
+ """Merge settings with global cms settings, so all required attributes
+ will exist. Never override, just append non existing settings.
+
+ Also check for setting inconstistence if settings.DEBUG
+ """
+ global ALREADY_PATCHED
+
+ # do this just once
+ if ALREADY_PATCHED:
+ return
+
+ ALREADY_PATCHED = True
+
+ from cms.conf import global_settings
+ # patch settings
+
+ pre_patch()
+
+ # merge with global cms settings
+ for attr in dir(global_settings):
+ if attr == attr.upper() and not hasattr(settings, attr):
+ setattr(settings._wrapped, attr, getattr(global_settings, attr))
+
+
+ post_patch()
+
+ if settings.DEBUG:
+ # check if settings are correct, call this only if debugging is enabled
+ post_patch_check()
+
+
+
+
+
+"""
+ removed CMS_UNIQUE_SLUGS setting
+
+"""
Oops, something went wrong.

0 comments on commit 7353b46

Please sign in to comment.