Skip to content
Browse files

almost done with venv stuff (=tons of failing tests :D)

  • Loading branch information...
1 parent c81e780 commit 595d9092d95ceb45ae666b78a86a4c71ed395396 @ojii ojii committed Jun 7, 2012
Showing with 1,389 additions and 9 deletions.
  1. +1 −0 .gitignore
  2. +192 −0 cms/test_utils/cli.py
  3. +1 −1 cms/test_utils/fixtures/fakemlng.py
  4. 0 cms/test_utils/project/__init__.py
  5. +25 −0 cms/test_utils/project/cms_urls_for_apphook_tests.py
  6. 0 cms/test_utils/project/fakemlng/__init__.py
  7. +1 −0 cms/test_utils/project/fakemlng/fixtures/fakemlng.json
  8. +14 −0 cms/test_utils/project/fakemlng/models.py
  9. 0 cms/test_utils/project/fileapp/__init__.py
  10. +7 −0 cms/test_utils/project/fileapp/models.py
  11. 0 cms/test_utils/project/models.py
  12. +13 −0 cms/test_utils/project/noadmin_urls.py
  13. +14 −0 cms/test_utils/project/nonroot_urls.py
  14. 0 cms/test_utils/project/placeholderapp/__init__.py
  15. +87 −0 cms/test_utils/project/placeholderapp/admin.py
  16. +38 −0 cms/test_utils/project/placeholderapp/models.py
  17. +9 −0 cms/test_utils/project/placeholderapp/views.py
  18. 0 cms/test_utils/project/pluginapp/__init__.py
  19. +15 −0 cms/test_utils/project/pluginapp/models.py
  20. 0 cms/test_utils/project/pluginapp/plugins/__init__.py
  21. 0 cms/test_utils/project/pluginapp/plugins/manytomany_rel/__init__.py
  22. +24 −0 cms/test_utils/project/pluginapp/plugins/manytomany_rel/cms_plugins.py
  23. +16 −0 cms/test_utils/project/pluginapp/plugins/manytomany_rel/models.py
  24. 0 cms/test_utils/project/sampleapp/__init__.py
  25. +11 −0 cms/test_utils/project/sampleapp/admin.py
  26. +11 −0 cms/test_utils/project/sampleapp/cms_app.py
  27. BIN cms/test_utils/project/sampleapp/media/sampleapp/img/gift.jpg
  28. +62 −0 cms/test_utils/project/sampleapp/menu.py
  29. +27 −0 cms/test_utils/project/sampleapp/models.py
  30. +5 −0 cms/test_utils/project/sampleapp/templates/sampleapp/category_view.html
  31. +21 −0 cms/test_utils/project/sampleapp/templates/sampleapp/home.html
  32. +14 −0 cms/test_utils/project/sampleapp/urls.py
  33. +17 −0 cms/test_utils/project/sampleapp/views.py
  34. +25 −0 cms/test_utils/project/second_cms_urls_for_apphook_tests.py
  35. +16 −0 cms/test_utils/project/second_urls_for_apphook_tests.py
  36. +11 −0 cms/test_utils/project/templates/404.html
  37. +3 −0 cms/test_utils/project/templates/add_placeholder.html
  38. +43 −0 cms/test_utils/project/templates/base.html
  39. +32 −0 cms/test_utils/project/templates/col_three.html
  40. +24 −0 cms/test_utils/project/templates/col_two.html
  41. +1 −0 cms/test_utils/project/templates/extra_context.html
  42. +41 −0 cms/test_utils/project/templates/fail.html
  43. +3 −0 cms/test_utils/project/templates/menu/breadcrumb.html
  44. +4 −0 cms/test_utils/project/templates/menu/language_chooser.html
  45. +22 −0 cms/test_utils/project/templates/menu/menu.html
  46. +1 −0 cms/test_utils/project/templates/menu/sub_menu.html
  47. +1 −0 cms/test_utils/project/templates/menu/test_language_chooser.html
  48. +165 −0 cms/test_utils/project/templates/nav_playground.html
  49. +13 −0 cms/test_utils/project/templates/placeholder_tests/base.html
  50. +3 −0 cms/test_utils/project/templates/placeholder_tests/child.html
  51. +7 −0 cms/test_utils/project/templates/placeholder_tests/nested_super_level1.html
  52. +7 −0 cms/test_utils/project/templates/placeholder_tests/nested_super_level2.html
  53. +7 −0 cms/test_utils/project/templates/placeholder_tests/nested_super_level3.html
  54. +5 −0 cms/test_utils/project/templates/placeholder_tests/nested_super_level4.html
  55. +14 −0 cms/test_utils/project/templates/placeholder_tests/outside.html
  56. +11 −0 cms/test_utils/project/templates/placeholder_tests/outside_base.html
  57. +1 −0 cms/test_utils/project/templates/placeholder_tests/outside_nested.html
  58. +5 −0 cms/test_utils/project/templates/placeholder_tests/test_eleven.html
  59. +21 −0 cms/test_utils/project/templates/placeholder_tests/test_five.html
  60. +22 −0 cms/test_utils/project/templates/placeholder_tests/test_four.html
  61. +16 −0 cms/test_utils/project/templates/placeholder_tests/test_one.html
  62. +17 −0 cms/test_utils/project/templates/placeholder_tests/test_seven.html
  63. +25 −0 cms/test_utils/project/templates/placeholder_tests/test_six.html
  64. +17 −0 cms/test_utils/project/templates/placeholder_tests/test_three.html
  65. +17 −0 cms/test_utils/project/templates/placeholder_tests/test_two.html
  66. +9 −0 cms/test_utils/project/templates/placeholderapp.html
  67. +3 −0 cms/test_utils/project/templates/sidebar_submenu.html
  68. +9 −0 cms/test_utils/project/templates/sidebar_submenu_root.html
  69. +1 −0 cms/test_utils/project/templates/subdir/template.html
  70. +3 −0 cms/test_utils/project/templates/unicode_placeholder.html
  71. +18 −0 cms/test_utils/project/urls.py
  72. +16 −0 cms/test_utils/project/urls_for_apphook_tests.py
  73. +51 −0 cms/test_utils/runners.py
  74. +7 −0 cms/test_utils/util/urls.py
  75. +4 −5 cms/tests/placeholder.py
  76. +3 −2 cms/tests/plugins.py
  77. +1 −1 cms/tests/reversion_tests.py
  78. +39 −0 runtests.py
View
1 .gitignore
@@ -7,6 +7,7 @@ cms/django
*.svn
.*
*.xml
+/*env*/
cms.sqlite
cms/media/cms_page_media/
cms/docs/build
View
192 cms/test_utils/cli.py
@@ -0,0 +1,192 @@
+# -*- coding: utf-8 -*-
+import os
+
+gettext = lambda s: s
+
+
+urlpatterns = []
+
+
+def configure(**extra):
+ from django.conf import settings
+ os.environ['DJANGO_SETTINGS_MODULE'] = 'cms.test_utils.cli'
+ defaults = dict(
+ CACHE_BACKEND = 'locmem:///',
+ DEBUG = True,
+ TEMPLATE_DEBUG = True,
+ DATABASE_SUPPORTS_TRANSACTIONS = True,
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': 'cmstest',
+ 'USER': 'cmstest',
+ 'PASSWORD': 'cmstest',
+ 'PORT': 5433,
+ }
+ },
+ SITE_ID = 1,
+ USE_I18N = True,
+ MEDIA_ROOT = '/media/',
+ STATIC_ROOT = '/static/',
+ CMS_MEDIA_ROOT = '/cms-media/',
+ CMS_MEDIA_URL = '/cms-media/',
+ MEDIA_URL = '/media/',
+ STATIC_URL = '/static/',
+ ADMIN_MEDIA_PREFIX = '/static/admin/',
+ EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend',
+ SECRET_KEY = 'key',
+ TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+ 'django.template.loaders.eggs.Loader',
+ ),
+ TEMPLATE_CONTEXT_PROCESSORS = [
+ "django.contrib.auth.context_processors.auth",
+ "django.core.context_processors.i18n",
+ "django.core.context_processors.debug",
+ "django.core.context_processors.request",
+ "django.core.context_processors.media",
+ 'django.core.context_processors.csrf',
+ "cms.context_processors.media",
+ "sekizai.context_processors.sekizai",
+ "django.core.context_processors.static",
+ ],
+ TEMPLATE_DIRS = [
+ os.path.abspath(os.path.join(os.path.dirname(__file__), 'project', 'templates'))
+ ],
+ MIDDLEWARE_CLASSES = [
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'cms.middleware.multilingual.MultilingualURLMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.doc.XViewMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'cms.middleware.user.CurrentUserMiddleware',
+ 'cms.middleware.page.CurrentPageMiddleware',
+ 'cms.middleware.toolbar.ToolbarMiddleware',
+ ],
+ INSTALLED_APPS = [
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.admin',
+ 'django.contrib.sites',
+ 'django.contrib.staticfiles',
+ 'cms',
+ 'menus',
+ 'mptt',
+ 'cms.plugins.text',
+ 'cms.plugins.picture',
+ 'cms.plugins.file',
+ 'cms.plugins.flash',
+ 'cms.plugins.link',
+ 'cms.plugins.snippet',
+ 'cms.plugins.googlemap',
+ 'cms.plugins.teaser',
+ 'cms.plugins.video',
+ 'cms.plugins.twitter',
+ 'cms.plugins.inherit',
+ 'cms.test_utils.project.sampleapp',
+ 'cms.test_utils.project.placeholderapp',
+ 'cms.test_utils.project.pluginapp',
+ 'cms.test_utils.project.pluginapp.plugins.manytomany_rel',
+ 'cms.test_utils.project.fakemlng',
+ 'cms.test_utils.project.fileapp',
+ 'south',
+ 'reversion',
+ 'sekizai',
+ ],
+ LANGUAGE_CODE = "en",
+ LANGUAGES = (
+ ('en', gettext('English')),
+ ('fr', gettext('French')),
+ ('de', gettext('German')),
+ ('pt-BR', gettext("Brazil")),
+ ('nl', gettext("Dutch")),
+ ),
+ CMS_LANGUAGES = (
+ ('en', gettext('English')),
+ ('fr', gettext('French')),
+ ('de', gettext('German')),
+ ('pt-BR', gettext("Brazil")),
+ ('nl', gettext("Dutch")),
+ ),
+ CMS_LANGUAGE_CONF = {
+ 'de':['fr', 'en'],
+ 'en':['fr', 'de'],
+ },
+ CMS_TEMPLATES = (
+ ('col_two.html', gettext('two columns')),
+ ('col_three.html', gettext('three columns')),
+ ('nav_playground.html', gettext('navigation examples')),
+ ),
+ CMS_PLACEHOLDER_CONF = {
+ 'col_sidebar': {
+ 'plugins': ('FilePlugin', 'FlashPlugin', 'LinkPlugin', 'PicturePlugin',
+ 'TextPlugin', 'SnippetPlugin'),
+ 'name': gettext("sidebar column")
+ },
+
+ 'col_left': {
+ 'plugins': ('FilePlugin', 'FlashPlugin', 'LinkPlugin', 'PicturePlugin',
+ 'TextPlugin', 'SnippetPlugin','GoogleMapPlugin',),
+ 'name': gettext("left column")
+ },
+
+ 'col_right': {
+ 'plugins': ('FilePlugin', 'FlashPlugin', 'LinkPlugin', 'PicturePlugin',
+ 'TextPlugin', 'SnippetPlugin','GoogleMapPlugin',),
+ 'name': gettext("right column")
+ },
+ 'extra_context': {
+ "plugins": ('TextPlugin',),
+ "extra_context": {"width": 250},
+ "name": "extra context"
+ },
+ },
+ CMS_SOFTROOT = True,
+ CMS_MODERATOR = True,
+ CMS_PERMISSION = True,
+ CMS_PUBLIC_FOR = 'all',
+ CMS_CACHE_DURATIONS = {
+ 'menus': 0,
+ 'content': 0,
+ 'permissions': 0,
+ },
+ CMS_APPHOOKS=[],
+ CMS_REDIRECTS = True,
+ CMS_SEO_FIELDS = True,
+ CMS_FLAT_URLS = False,
+ CMS_MENU_TITLE_OVERWRITE = True,
+ CMS_HIDE_UNTRANSLATED = False,
+ CMS_URL_OVERWRITE = True,
+ CMS_SHOW_END_DATE = True,
+ CMS_SHOW_START_DATE = True,
+ CMS_PLUGIN_PROCESSORS = tuple(),
+ CMS_PLUGIN_CONTEXT_PROCESSORS = tuple(),
+ CMS_SITE_CHOICES_CACHE_KEY = 'CMS:site_choices',
+ CMS_PAGE_CHOICES_CACHE_KEY = 'CMS:page_choices',
+ SOUTH_TESTS_MIGRATE = False,
+ CMS_NAVIGATION_EXTENDERS = (
+ ('cms.test_utils.project.sampleapp.menu_extender.get_nodes', 'SampleApp Menu'),
+ ),
+ TEST_RUNNER = 'cms.test_utils.runners.NormalTestRUnner',
+ JUNIT_OUTPUT_DIR = '.',
+ TIME_TESTS = False,
+ ROOT_URLCONF = 'cms.test_utils.cli',
+ )
+ defaults.update(extra)
+ settings.configure(**defaults)
+ from cms.conf import patch_settings
+ patch_settings()
+ from south.management.commands import patch_for_test_db_setup
+ patch_for_test_db_setup()
+ from django.core.urlresolvers import set_urlconf
+ from django.utils.importlib import import_module
+ from django.contrib import admin
+ admin.autodiscover()
+ set_urlconf(settings.ROOT_URLCONF)
+ module = import_module(__name__)
+ for key, value in defaults.items():
+ setattr(module, key, value)
View
2 cms/test_utils/fixtures/fakemlng.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from cms.api import add_plugin
-from project.fakemlng.models import MainModel, Translations
+from cms.test_utils.project.fakemlng.models import MainModel, Translations
class FakemlngFixtures(object):
def create_fixtures(self):
View
0 cms/test_utils/project/__init__.py
No changes.
View
25 cms/test_utils/project/cms_urls_for_apphook_tests.py
@@ -0,0 +1,25 @@
+from cms.apphook_pool import apphook_pool
+from cms.views import details
+from django.conf import settings
+from django.conf.urls.defaults import url, patterns
+
+if settings.APPEND_SLASH:
+ reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)/$', details, name='pages-details-by-slug')
+else:
+ reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)$', details, name='pages-details-by-slug')
+
+urlpatterns = [
+ # Public pages
+ url(r'^$', details, {'slug':''}, name='pages-root'),
+ reg,
+]
+
+if apphook_pool.get_apphooks():
+ """If there are some application urls, add special resolver, so we will
+ have standard reverse support.
+ """
+ from cms.appresolver import get_app_patterns
+ urlpatterns = get_app_patterns() + urlpatterns
+ #urlpatterns = (dynamic_app_regex_url_resolver, ) + urlpatterns
+
+urlpatterns = patterns('', *urlpatterns)
View
0 cms/test_utils/project/fakemlng/__init__.py
No changes.
View
1 cms/test_utils/project/fakemlng/fixtures/fakemlng.json
@@ -0,0 +1 @@
+[{"pk": 1, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 2, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 3, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 4, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 5, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 6, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 7, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 1, "model": "cms.cmsplugin", "fields": {"rght": 2, "parent": null, "language": "en", "level": 0, "creation_date": "2011-01-04 08:52:59", "lft": 1, "tree_id": 1, "position": null, "placeholder": 6, "plugin_type": "TextPlugin"}}, {"pk": 2, "model": "cms.cmsplugin", "fields": {"rght": 2, "parent": null, "language": "en", "level": 0, "creation_date": "2011-01-04 08:53:28", "lft": 1, "tree_id": 2, "position": null, "placeholder": 5, "plugin_type": "TextPlugin"}}, {"pk": 1, "model": "text.text", "fields": {"body": "<p>FRENCH!</p>", "cmsplugin_ptr": 1}}, {"pk": 2, "model": "text.text", "fields": {"body": "<p>ENGLISH</p>", "cmsplugin_ptr": 2}}, {"pk": 1, "model": "fakemlng.mainmodel", "fields": {}}, {"pk": 1, "model": "fakemlng.translations", "fields": {"placeholder": 4, "master": 1, "language_code": "de"}}, {"pk": 2, "model": "fakemlng.translations", "fields": {"placeholder": 5, "master": 1, "language_code": "en"}}, {"pk": 3, "model": "fakemlng.translations", "fields": {"placeholder": 6, "master": 1, "language_code": "fr"}}, {"pk": 4, "model": "fakemlng.translations", "fields": {"placeholder": null, "master": 1, "language_code": "nl"}}]
View
14 cms/test_utils/project/fakemlng/models.py
@@ -0,0 +1,14 @@
+from cms.models.fields import PlaceholderField
+from django.db import models
+
+
+class MainModel(models.Model):
+ pass
+
+class Translations(models.Model):
+ master = models.ForeignKey(MainModel)
+ language_code = models.CharField(max_length=15, db_index=True)
+ placeholder = PlaceholderField('translated', null=True)
+
+ class Meta:
+ unique_together = [('master', 'language_code')]
View
0 cms/test_utils/project/fileapp/__init__.py
No changes.
View
7 cms/test_utils/project/fileapp/models.py
@@ -0,0 +1,7 @@
+from cms.utils.helpers import reversion_register
+from django.db import models
+
+class FileModel(models.Model):
+ test_file = models.FileField(upload_to='fileapp/', blank=True, null=True)
+
+reversion_register(FileModel)
View
0 cms/test_utils/project/models.py
No changes.
View
13 cms/test_utils/project/noadmin_urls.py
@@ -0,0 +1,13 @@
+from django.conf import settings
+from django.conf.urls.defaults import handler500, handler404, patterns, include, \
+ url
+
+
+urlpatterns = patterns('',
+ url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
+ url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.CMS_MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^', include('cms.urls')),
+)
View
14 cms/test_utils/project/nonroot_urls.py
@@ -0,0 +1,14 @@
+from django.conf import settings
+from django.conf.urls.defaults import handler500, handler404, patterns, include, \
+ url
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ (r'^admin/', include(admin.site.urls)),
+ (r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
+ url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.CMS_MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^content/', include('cms.urls')),
+)
View
0 cms/test_utils/project/placeholderapp/__init__.py
No changes.
View
87 cms/test_utils/project/placeholderapp/admin.py
@@ -0,0 +1,87 @@
+from cms.admin.placeholderadmin import PlaceholderAdmin
+from cms.test_utils.project.placeholderapp.models import (Example1, Example2,
+ Example3, Example4, Example5)
+from django.contrib import admin
+
+
+class MixinAdmin(admin.ModelAdmin):
+ def formfield_for_dbfield(self, db_field, **kwargs):
+ """
+ Hook for specifying the form Field instance for a given database Field
+ instance.
+
+ If kwargs are given, they're passed to the form Field's constructor.
+ """
+ # silly test that placeholderadmin doesn't fuck stuff up
+ request = kwargs.pop('request', None)
+ return super(MixinAdmin, self).formfield_for_dbfield(db_field, request=request, **kwargs)
+
+
+class Example1Admin(PlaceholderAdmin, MixinAdmin):
+ pass
+
+class Example2Admin(PlaceholderAdmin):
+ fieldsets = (
+ ('Placeholder + more fields', {
+ 'classes': ('wide',),
+ 'fields': ('char_1', 'placeholder', 'char_2',)
+ }),
+ ('Other fields', {
+ 'classes': ('wide',),
+ 'fields': ('char_3', 'char_4',)
+ }),
+ )
+
+class Example3Admin(PlaceholderAdmin):
+ fieldsets = (
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_1', 'char_2',)
+ }),
+ (u'Only Placeholder with rigth classes', {
+ 'classes': ('plugin-holder', 'plugin-holder-nopage',),
+ 'fields': ('placeholder',)
+ }),
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_3', 'char_4',)
+ }),
+ )
+
+class Example4Admin(PlaceholderAdmin):
+ fieldsets = (
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_1', 'char_2',)
+ }),
+ (u'Only Placeholder, with wrong classes', {
+ 'classes': ('wide', 'plugin-holder-nopage',),
+ 'fields': ('placeholder',)
+ }),
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_3', 'char_4',)
+ }),
+ )
+
+class Example5Admin(PlaceholderAdmin):
+ fieldsets = (
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_1', 'char_2',)
+ }),
+ (u'Two Placeholder, with right classes', {
+ 'classes': ('plugin', 'plugin-holder-nopage',),
+ 'fields': ('placeholder_1', 'placeholder_2',)
+ }),
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_3', 'char_4',)
+ }),
+ )
+
+admin.site.register(Example1, Example1Admin)
+admin.site.register(Example2, Example2Admin)
+admin.site.register(Example3, Example3Admin)
+admin.site.register(Example4, Example4Admin)
+admin.site.register(Example5, Example5Admin)
View
38 cms/test_utils/project/placeholderapp/models.py
@@ -0,0 +1,38 @@
+from django.db import models
+from cms.models.fields import PlaceholderField
+
+class Example1(models.Model):
+ char_1 = models.CharField(u'char_1', max_length=255)
+ char_2 = models.CharField(u'char_2', max_length=255)
+ char_3 = models.CharField(u'char_3', max_length=255)
+ char_4 = models.CharField(u'char_4', max_length=255)
+ placeholder = PlaceholderField('placeholder')
+
+class Example2(models.Model):
+ char_1 = models.CharField(u'char_1', max_length=255)
+ char_2 = models.CharField(u'char_2', max_length=255)
+ char_3 = models.CharField(u'char_3', max_length=255)
+ char_4 = models.CharField(u'char_4', max_length=255)
+ placeholder = PlaceholderField('placeholder')
+
+class Example3(models.Model):
+ char_1 = models.CharField(u'char_1', max_length=255)
+ char_2 = models.CharField(u'char_2', max_length=255)
+ char_3 = models.CharField(u'char_3', max_length=255)
+ char_4 = models.CharField(u'char_4', max_length=255)
+ placeholder = PlaceholderField('placeholder')
+
+class Example4(models.Model):
+ char_1 = models.CharField(u'char_1', max_length=255)
+ char_2 = models.CharField(u'char_2', max_length=255)
+ char_3 = models.CharField(u'char_3', max_length=255)
+ char_4 = models.CharField(u'char_4', max_length=255)
+ placeholder = PlaceholderField('placeholder')
+
+class Example5(models.Model):
+ char_1 = models.CharField(u'char_1', max_length=255)
+ char_2 = models.CharField(u'char_2', max_length=255)
+ char_3 = models.CharField(u'char_3', max_length=255)
+ char_4 = models.CharField(u'char_4', max_length=255)
+ placeholder_1 = PlaceholderField('placeholder_1', related_name='p1')
+ placeholder_2 = PlaceholderField('placeholder_2', related_name='p2')
View
9 cms/test_utils/project/placeholderapp/views.py
@@ -0,0 +1,9 @@
+from django.shortcuts import render_to_response
+from django.template.context import RequestContext
+from cms.test_utils.project.placeholderapp.models import Example1
+
+
+def example_view(request):
+ context = RequestContext(request)
+ context['examples'] = Example1.objects.all()
+ return render_to_response('placeholderapp.html', context)
View
0 cms/test_utils/project/pluginapp/__init__.py
No changes.
View
15 cms/test_utils/project/pluginapp/models.py
@@ -0,0 +1,15 @@
+from django.db import models
+
+
+class Section(models.Model):
+ name = models.CharField(max_length=50)
+
+ def __unicode__(self):
+ return self.name
+
+class Article(models.Model):
+ title = models.CharField(max_length=50)
+ section = models.ForeignKey(Section)
+
+ def __unicode__(self):
+ return u"%s -- %s" % (self.title, self.section)
View
0 cms/test_utils/project/pluginapp/plugins/__init__.py
No changes.
View
0 cms/test_utils/project/pluginapp/plugins/manytomany_rel/__init__.py
No changes.
View
24 cms/test_utils/project/pluginapp/plugins/manytomany_rel/cms_plugins.py
@@ -0,0 +1,24 @@
+from django.utils.translation import ugettext as _
+
+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+
+from cms.test_utils.project.pluginapp.plugins.manytomany_rel.models import ArticlePluginModel
+from cms.test_utils.project.pluginapp.models import Article
+
+
+
+class ArticlePlugin(CMSPluginBase):
+ model = ArticlePluginModel
+ name = _("Articles")
+ render_template = "newsroom/plugins/articles.html"
+ admin_preview = False
+
+ def render(self, context, instance, placeholder):
+ article_qs = Article.published_objects.all(section__name__in=instance.sections)
+ context.update({'instance':instance,
+ 'article_qs':article_qs,
+ 'placeholder':placeholder})
+ return context
+
+plugin_pool.register_plugin(ArticlePlugin)
View
16 cms/test_utils/project/pluginapp/plugins/manytomany_rel/models.py
@@ -0,0 +1,16 @@
+from django.db import models
+
+from cms.models import CMSPlugin
+
+from cms.test_utils.project.pluginapp.models import Section
+
+
+class ArticlePluginModel(CMSPlugin):
+ title = models.CharField(max_length=50)
+ sections = models.ManyToManyField(Section)
+
+ def __unicode__(self):
+ return self.title
+
+ def copy_relations(self, oldinstance):
+ self.sections = oldinstance.sections.all()
View
0 cms/test_utils/project/sampleapp/__init__.py
No changes.
View
11 cms/test_utils/project/sampleapp/admin.py
@@ -0,0 +1,11 @@
+from cms.admin.placeholderadmin import PlaceholderAdmin
+from django.contrib import admin
+from cms.test_utils.project.sampleapp.models import Picture, Category
+
+class PictureInline(admin.StackedInline):
+ model = Picture
+
+class CategoryAdmin(PlaceholderAdmin):
+ inlines = [PictureInline]
+
+admin.site.register(Category, CategoryAdmin)
View
11 cms/test_utils/project/sampleapp/cms_app.py
@@ -0,0 +1,11 @@
+from cms.app_base import CMSApp
+from cms.test_utils.project.sampleapp.menu import SampleAppMenu
+from cms.apphook_pool import apphook_pool
+from django.utils.translation import ugettext_lazy as _
+
+class SampleApp(CMSApp):
+ name = _("Sample App")
+ urls = ["cms.test_utils.project.sampleapp.urls"]
+ menus = [SampleAppMenu]
+
+apphook_pool.register(SampleApp)
View
BIN cms/test_utils/project/sampleapp/media/sampleapp/img/gift.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
62 cms/test_utils/project/sampleapp/menu.py
@@ -0,0 +1,62 @@
+from cms.app_base import CMSApp
+from cms.menu_bases import CMSAttachMenu
+from django.core.urlresolvers import reverse, NoReverseMatch
+from django.utils.translation import ugettext_lazy as _
+from menus.base import Menu, NavigationNode
+from menus.menu_pool import menu_pool
+from project.sampleapp.models import Category
+
+class SampleAppMenu(Menu):
+
+ def get_nodes(self, request):
+ nodes = []
+ for cat in Category.objects.all():
+ n = NavigationNode(cat.name, cat.get_absolute_url(), cat.pk, cat.parent_id, "sampleapp")
+ nodes.append(n)
+ try:
+ n = NavigationNode(_('sample root page'), reverse('sample-root'), 1)
+ n2 = NavigationNode(_('sample settings page'), reverse('sample-settings'), 2)
+ n3 = NavigationNode(_('sample account page'), reverse('sample-account'), 3)
+ n4 = NavigationNode(_('sample my profile page'), reverse('sample-profile'), 4, 3)
+ nodes.append(n)
+ nodes.append(n2)
+ nodes.append(n3)
+ nodes.append(n4)
+ except NoReverseMatch:
+ pass
+ return nodes
+
+menu_pool.register_menu(SampleAppMenu)
+
+class StaticMenu(CMSAttachMenu):
+ name = _("Static Menu")
+ def get_nodes(self, request):
+ nodes = []
+ n = NavigationNode('static root page', "/fresh/", 1)
+ n2 = NavigationNode('static settings page', "/bye/", 2)
+ n3 = NavigationNode('static account page', "/hello/", 3)
+ n4 = NavigationNode('static my profile page', "/hello/world/", 4, 3)
+ nodes.append(n)
+ nodes.append(n2)
+ nodes.append(n3)
+ nodes.append(n4)
+ return nodes
+
+menu_pool.register_menu(StaticMenu)
+
+class StaticMenu2(CMSAttachMenu):
+ name = _("Static Menu2")
+ def get_nodes(self, request):
+ nodes = []
+ n = NavigationNode('static2 root page', "/fresh/", 1)
+ n2 = NavigationNode('static2 settings page', "/bye/", 2)
+ n3 = NavigationNode('static2 account page', "/hello/", 3)
+ n4 = NavigationNode('static2 my profile page', "/hello/world/", 4, 3)
+ nodes.append(n)
+ nodes.append(n2)
+ nodes.append(n3)
+ nodes.append(n4)
+ return nodes
+
+menu_pool.register_menu(StaticMenu2)
+
View
27 cms/test_utils/project/sampleapp/models.py
@@ -0,0 +1,27 @@
+from cms.models.fields import PlaceholderField
+from django.core.urlresolvers import reverse
+from django.db import models
+import mptt
+
+class Category(models.Model):
+ parent = models.ForeignKey('self', blank=True, null=True)
+ name = models.CharField(max_length=20)
+ description = PlaceholderField('category_description', 600)
+
+ def __unicode__(self):
+ return self.name
+
+ def get_absolute_url(self):
+ return reverse('category_view', args=[self.pk])
+
+ class Meta:
+ verbose_name_plural = 'categories'
+
+try:
+ mptt.register(Category)
+except mptt.AlreadyRegistered:
+ pass
+
+class Picture(models.Model):
+ image = models.ImageField(upload_to="pictures")
+ category = models.ForeignKey(Category)
View
5 cms/test_utils/project/sampleapp/templates/sampleapp/category_view.html
@@ -0,0 +1,5 @@
+{% extends 'index.html' %}
+
+{% block content %}
+<h1>{{ category.get_title }}</h1>
+{% endblock %}
View
21 cms/test_utils/project/sampleapp/templates/sampleapp/home.html
@@ -0,0 +1,21 @@
+{% extends "base.html" %}
+{% load cms_tags %}
+
+{% block content %}
+ <h2>Sample application home page - on page {% page_attribute page_title %}</h2>
+ <h3>{{ message }}</h3>
+ {{ block.super }}
+ <ul>
+ <li>
+ <a href="{% url sample-root %}">Sample app root reverse test</a>
+ </li>
+ <li>
+ <a href="{% url de:sample-account %}">Sample app account reverse test german</a>
+ </li>
+ <li>
+ <a href="{% url en:sample-account %}">Sample app account reverse test english</a>
+ </li>
+ </ul>
+ <h4>Sample image - appmedia works?</h4>
+ <img src="{{ MEDIA_URL }}sampleapp/img/gift.jpg" alt="gift">
+{% endblock content %}
View
14 cms/test_utils/project/sampleapp/urls.py
@@ -0,0 +1,14 @@
+from django.conf.urls.defaults import *
+
+"""
+Also used in cms.tests.ApphooksTestCase
+"""
+
+urlpatterns = patterns('cms.test_utils.project.sampleapp.views',
+ url(r'^$', 'sample_view', {'message': 'sample root page',}, name='sample-root'),
+ url(r'^settings/$', 'sample_view', kwargs={'message': 'sample settings page'}, name='sample-settings'),
+ url(r'^account/$', 'sample_view', {'message': 'sample account page'}, name='sample-account'),
+ url(r'^account/my_profile/$', 'sample_view', {'message': 'sample my profile page'}, name='sample-profile'),
+ url(r'(?P<id>[0-9]+)/$', 'category_view', name='category_view'),
+ url(r'notfound/$', 'notfound', name='notfound'),
+)
View
17 cms/test_utils/project/sampleapp/views.py
@@ -0,0 +1,17 @@
+# Create your views here.
+from django.http import Http404
+from django.shortcuts import render_to_response
+from django.template.context import RequestContext
+from menus.utils import simple_language_changer
+from cms.test_utils.project.sampleapp.models import Category
+
+@simple_language_changer
+def sample_view(request, **kw):
+ context = RequestContext(request, kw)
+ return render_to_response("sampleapp/home.html", context)
+
+def category_view(request, id):
+ return render_to_response('sampleapp/category_view.html', RequestContext(request, {'category':Category.objects.get(pk=id)}))
+
+def notfound(request):
+ raise Http404
View
25 cms/test_utils/project/second_cms_urls_for_apphook_tests.py
@@ -0,0 +1,25 @@
+from cms.apphook_pool import apphook_pool
+from cms.views import details
+from django.conf import settings
+from django.conf.urls.defaults import url, patterns
+
+if settings.APPEND_SLASH:
+ reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)/$', details, name='pages-details-by-slug')
+else:
+ reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)$', details, name='pages-details-by-slug')
+
+urlpatterns = [
+ # Public pages
+ url(r'^$', details, {'slug':''}, name='pages-root'),
+ reg,
+]
+
+if apphook_pool.get_apphooks():
+ """If there are some application urls, add special resolver, so we will
+ have standard reverse support.
+ """
+ from cms.appresolver import get_app_patterns
+ urlpatterns = get_app_patterns() + urlpatterns
+ #urlpatterns = (dynamic_app_regex_url_resolver, ) + urlpatterns
+
+urlpatterns = patterns('', *urlpatterns)
View
16 cms/test_utils/project/second_urls_for_apphook_tests.py
@@ -0,0 +1,16 @@
+from django.conf import settings
+from django.conf.urls.defaults import handler500, handler404, patterns, include, \
+ url
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ url(r'^admin/', include(admin.site.urls)),
+ url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
+ url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.CMS_MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^', include('project.second_cms_urls_for_apphook_tests')),
+)
View
11 cms/test_utils/project/templates/404.html
@@ -0,0 +1,11 @@
+{% extends "col_two.html" %}
+{% load i18n cms_tags %}
+
+{% block tpl_id %}tpl_404{% endblock %}
+
+{% block content %}
+<div id="col1" class="grid_8">
+ <h1>404</h1>
+ <p>Page not found!</p>
+</div>
+{% endblock %}
View
3 cms/test_utils/project/templates/add_placeholder.html
@@ -0,0 +1,3 @@
+{% load cms_tags %}
+{% placeholder my_placeholder %}
+<!-- SECOND_PLACEHOLDER -->
View
43 cms/test_utils/project/templates/base.html
@@ -0,0 +1,43 @@
+{% load i18n cms_tags menu_tags sekizai_tags %}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{{ LANGUAGE_CODE }}" lang="{{ LANGUAGE_CODE }}">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>{% page_attribute page_title %}</title>
+ <meta name="description" content="{% page_attribute meta_description %}"/>
+ <meta name="keywords" content="{% page_attribute meta_keywords %}"/>
+ <link href="{{ STATIC_URL }}css/style.css" media="all" rel="stylesheet" type="text/css" />
+ <link href="{{ STATIC_URL }}css/print.css" media="print" rel="stylesheet" type="text/css" />
+ {% render_block "css" %}
+ {% render_block "js" %}
+</head>
+<body id="{% block tpl_id %}none{% endblock %}" class="{{ LANGUAGE_CODE }}">
+{% cms_toolbar %}
+ <div id="page" class="container_16 ">
+ <div id="header">
+ <div id="logo">
+ <a href="/">Company name</a>
+ </div>
+ <div id="nav_lang">
+ {% spaceless %}
+ <ul>
+ {% language_chooser %}
+ </ul>
+ {% endspaceless %}
+ </div>
+ <div id="nav_main" class="clearfix">
+ {% spaceless %}
+ <ul>
+ {% show_menu 0 0 100 100 %}
+ </ul>
+ {% endspaceless %}
+ </div>
+ </div>
+ <ul class="breadcrumb clearfix">
+ {% show_breadcrumb %}
+ </ul>
+ <div id="main">
+ {% block content %}{% endblock content %}
+ </div>
+ </div>
+</body>
+</html>
View
32 cms/test_utils/project/templates/col_three.html
@@ -0,0 +1,32 @@
+{% extends "base.html" %}
+{% load i18n cms_tags %}
+
+{% block tpl_id %}tpl_col_three{% endblock %}
+
+{% block content %}
+ <div id="col1" class="grid_4">
+ {% include "sidebar_submenu.html" %}
+ {% block col_sidebar %}
+ {% with "220" as width %}
+ {% placeholder col_sidebar %}
+ {% endwith %}
+ {% endblock %}
+ </div>
+
+ <div id="col2" class="grid_6 push_1">
+ {% block page_title %}<h1>{% page_attribute title %}</h1>{% endblock %}
+ {% block col_left %}
+ {% with "340" as width %}
+ {% placeholder col_left %}
+ {% endwith %}
+ {% endblock %}
+ </div>
+
+ <div id="col3" class="grid_4 push_2">
+ {% block col_right %}
+ {% with "220" as width %}
+ {% placeholder col_right %}
+ {% endwith %}
+ {% endblock %}
+ </div>
+{% endblock %}
View
24 cms/test_utils/project/templates/col_two.html
@@ -0,0 +1,24 @@
+{% extends "base.html" %}
+{% load i18n cms_tags %}
+
+{% block tpl_id %}tpl_col_two{% endblock %}
+
+{% block content %}
+ <div id="col1" class="grid_4">
+ {% include "sidebar_submenu.html" %}
+ {% block col_sidebar %}
+ {% with "220" as width %}
+ {% placeholder col_sidebar %}
+ {% endwith %}
+ {% endblock %}
+ </div>
+
+ <div id="col2" class="grid_11 push_1">
+ {% block page_title %}<h1>{% page_attribute title %}</h1>{% endblock %}
+ {% block col_left %}
+ {% with "640" as width %}
+ {% placeholder col_left %}
+ {% endwith %}
+ {% endblock %}
+ </div>
+{% endblock %}
View
1 cms/test_utils/project/templates/extra_context.html
@@ -0,0 +1 @@
+{% load cms_tags %}{% placeholder "extra_context" %}
View
41 cms/test_utils/project/templates/fail.html
@@ -0,0 +1,41 @@
+{% load i18n cms_tags menu_tags %}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{{ LANGUAGE_CODE }}" lang="{{ LANGUAGE_CODE }}">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>{% page_attribute page_title %}</title>
+ <meta name="description" content="{% page_attribute meta_description %}"/>
+ <meta name="keywords" content="{% page_attribute meta_keywords %}"/>
+ <link href="{{ STATIC_URL }}css/style.css" media="all" rel="stylesheet" type="text/css" />
+ <link href="{{ STATIC_URL }}css/print.css" media="print" rel="stylesheet" type="text/css" />
+</head>
+<body id="{% block tpl_id %}none{% endblock %}" class="{{ LANGUAGE_CODE }}">
+
+ <div id="page" class="container_16 ">
+ <div id="header">
+ <div id="logo">
+ <a href="/">Company name</a>
+ </div>
+ <div id="nav_lang">
+ {% spaceless %}
+ <ul>
+ {% language_chooser %}
+ </ul>
+ {% endspaceless %}
+ </div>
+ <div id="nav_main" class="clearfix">
+ {% spaceless %}
+ <ul>
+ {% show_menu 0 0 100 100 %}
+ </ul>
+ {% endspaceless %}
+ </div>
+ </div>
+ <ul class="breadcrumb clearfix">
+ {% show_breadcrumb %}
+ </ul>
+ <div id="main">
+ {% block content %}{% endblock content %}
+ </div>
+ </div>
+</body>
+</html>
View
3 cms/test_utils/project/templates/menu/breadcrumb.html
@@ -0,0 +1,3 @@
+{% for ance in ancestors %}
+<li>{% if not forloop.last %}<a href="{{ ance.get_absolute_url }}">{{ ance.get_menu_title }}</a>{% else %}<span>{{ ance.get_menu_title }}</span>{% endif %}</li>
+{% endfor %}
View
4 cms/test_utils/project/templates/menu/language_chooser.html
@@ -0,0 +1,4 @@
+{% load menu_tags %}
+{% for language in languages %}
+<li><a href="{% page_language_url language.0 %}"{% ifequal current_language language.0 %} class="selected"{% endifequal %}>{{ language.0 }}</a></li>
+{% endfor %}
View
22 cms/test_utils/project/templates/menu/menu.html
@@ -0,0 +1,22 @@
+{% load menu_tags cache %}
+{% for child in children %}
+
+<li>
+ <a href="{{ child.get_absolute_url }}" class="menu {% if child.selected %} selected{% endif %}{% if child.ancestor %} ancestor{% endif %}">{% if not child.is_leaf_node %}+{% endif %}{{ child.get_menu_title }}
+ <span>
+ {% if child.selected %}selected{% endif %}
+ {% if child.ancestor %}ancestor{% endif %}
+ {% if child.sibling %}sibling{% endif %}
+ {% if child.descendant %}descendant{% endif %}
+ {% if child.soft_root %}(softroot){% endif %}
+ (Level: {{ child.menu_level }} {{ child.level }})
+ </span>
+ </a>
+ {% if child.children %}
+ <ul>
+ {% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
+ </ul>
+ {% endif %}
+</li>
+
+{% endfor %}
View
1 cms/test_utils/project/templates/menu/sub_menu.html
@@ -0,0 +1 @@
+{% include "menu/menu.html" %}
View
1 cms/test_utils/project/templates/menu/test_language_chooser.html
@@ -0,0 +1 @@
+{% for language in languages %}{{ language.0 }}{% endfor %}
View
165 cms/test_utils/project/templates/nav_playground.html
@@ -0,0 +1,165 @@
+{% load cache cms_tags menu_tags sekizai_tags %}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ lang }}" xml:lang="{{ lang }}" >
+<head>
+<title>{% page_attribute page_title %}</title>
+<meta name="description" content="{% page_attribute meta_description %}"/>
+<meta name="keywords" content="{% page_attribute meta_keywords %}"/>
+<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
+{% render_block "css" %}
+<style>
+ .placeholder-editable {
+ border:1px #bbb solid;
+ background:#fff;
+ min-height:1em;
+ padding:5px;
+ cursor:text;
+ overflow:hidden;
+ height:1%;
+ }
+
+ .placeholder-editable input {
+ float:right;
+ padding:4px 10px;
+ margin-top:3px;
+ }
+
+ .placeholder-over, .edit {
+ border:1px #999 solid;
+ background:#5c705c;
+ color:#fff;
+ cursor: hand;
+ }
+
+ .edit {
+ padding:5px;
+ }
+
+ body {
+ font-family:sans-serif;
+ font-size:75%;
+ background:#b5b185;
+ color:#333;
+ }
+
+ #main {
+ width:600px;
+ padding:20px;
+ margin:0 auto;
+ border:1px #999 solid;
+ margin-bottom:40px;
+ height:1%;
+ background:#fffdca;
+ }
+
+ h1, h2 {
+ border-bottom:1px #ddd solid;
+ color:#a4b854;
+ }
+
+ a {
+ color:#ff7959
+ }
+
+ ul.breadcrumb {
+ clear:left;
+ padding-bottom:30px;
+ margin-left:-40px;
+ }
+ ul.breadcrumb li{
+ float:left;
+ margin-left:5px;
+ list-style:none;
+ }
+ p.chooser a{
+ text-decoration: none;
+ }
+ p.chooser a.current {
+ text-decoration: underline;
+ }
+</style>
+</head>
+<body>
+{% cms_toolbar %}
+<div id="main">
+<p style="float:right">
+ {% if user.is_authenticated %}
+ <a href="/admin/logout/">log out</a>
+ {% else %}
+ <a href="/admin/">log in</a>
+ {% endif %}
+</p>
+<p class="chooser">
+ See this page in: {% language_chooser %}
+</p>
+<h1>{% block title %}{% page_attribute title %}{% endblock %}</h1>
+
+<h3>site: {{ site.name }}</h3>
+
+<h2>Complete navigation</h2>
+
+<ul>
+ {% show_menu 0 100 100 100 %}
+</ul>
+
+<h2>Navigation with active tree</h2>
+<ul>
+ {% show_menu 0 100 0 100 %}
+</ul>
+
+<h2>Navigation with only 1 active extra level</h2>
+<ul>
+ {% show_menu 0 100 0 1 %}
+</ul>
+
+<h2>Level 0 navigation </h2>
+<ul>
+ {% show_menu 0 0 0 0 %}
+</ul>
+
+<h2>Level 1 navigation </h2>
+<ul>
+ {% show_menu 1 1 100 100 %}
+</ul>
+
+<h2>Level 1 navigation (only active tree)</h2>
+<ul>
+ {% show_menu 1 1 0 100 %}
+</ul>
+
+<h2>Level 0-1 navigation</h2>
+<ul>
+ {% show_menu 0 1 100 100 %}
+</ul>
+
+<h2>Display the sub menu (2 level deep) of the current page</h2>
+
+<ul>
+ {% show_sub_menu 2 %}
+</ul>
+
+
+<h2>Show the breadcrumb navigation of the current page</h2>
+<ul class="breadcrumb">
+ {% show_breadcrumb %}
+</ul>
+
+<h2>Content</h2>
+{% block content %}
+ <div>
+ <h3>Title placeholder {% page_attribute title %}</h3>
+ <div style="float:right;width:30%;">
+ <h3>Right column placeholder</h3>
+ {% placeholder right-column %}
+ </div>
+ <div style="float:left;width:65%;">
+ <h3>Body placeholder</h3>
+ {% placeholder "body" %}
+ </div>
+ </div>
+{% endblock %}
+
+</div>
+
+{% render_block "js" %}
+</body>
+</html>
View
13 cms/test_utils/project/templates/placeholder_tests/base.html
@@ -0,0 +1,13 @@
+{% load cms_tags %}
+
+{% block one %}
+ {% placeholder "one" %}
+{% endblock %}
+
+{% block two %}
+ {% placeholder "two" %}
+{% endblock %}
+
+{% block three %}
+ {% placeholder "three" %}
+{% endblock %}
View
3 cms/test_utils/project/templates/placeholder_tests/child.html
@@ -0,0 +1,3 @@
+{% load cms_tags %}
+
+{% placeholder "child" %}
View
7 cms/test_utils/project/templates/placeholder_tests/nested_super_level1.html
@@ -0,0 +1,7 @@
+{% extends "placeholder_tests/nested_super_level2.html" %}
+{% load cms_tags %}
+
+{% block one %}
+{% placeholder "level1" %}
+{{ block.super }}
+{% endblock %}
View
7 cms/test_utils/project/templates/placeholder_tests/nested_super_level2.html
@@ -0,0 +1,7 @@
+{% extends "placeholder_tests/nested_super_level3.html" %}
+{% load cms_tags %}
+
+{% block one %}
+{% placeholder "level2" %}
+{{ block.super }}
+{% endblock %}
View
7 cms/test_utils/project/templates/placeholder_tests/nested_super_level3.html
@@ -0,0 +1,7 @@
+{% extends "placeholder_tests/nested_super_level4.html" %}
+{% load cms_tags %}
+
+{% block one %}
+{% placeholder "level3" %}
+{{ block.super }}
+{% endblock %}
View
5 cms/test_utils/project/templates/placeholder_tests/nested_super_level4.html
@@ -0,0 +1,5 @@
+{% load cms_tags %}
+
+{% block one %}
+{% placeholder "level4" %}
+{% endblock %}
View
14 cms/test_utils/project/templates/placeholder_tests/outside.html
@@ -0,0 +1,14 @@
+{% extends "placeholder_tests/outside_base.html" %}
+{% load cms_tags %}
+
+{% comment %}
+This files hould result in following placeholders:
+
+ - new_one (from this)
+ - two (from base.html)
+ - base_end (from base.html)
+{% endcomment %}
+
+{% block one %}
+ {% placeholder "new_one" %}
+{% endblock %}
View
11 cms/test_utils/project/templates/placeholder_tests/outside_base.html
@@ -0,0 +1,11 @@
+{% load cms_tags %}
+
+{% block one %}
+ {% placeholder "one" %}
+{% endblock %}
+
+{% block two %}
+ {% placeholder "two" %}
+{% endblock %}
+
+{% placeholder "base_outside" %}
View
1 cms/test_utils/project/templates/placeholder_tests/outside_nested.html
@@ -0,0 +1 @@
+{% extends "placeholder_tests/outside.html" %}
View
5 cms/test_utils/project/templates/placeholder_tests/test_eleven.html
@@ -0,0 +1,5 @@
+{% load cms_tags %}
+{% block "myblock" %}
+{{ block.super }}
+{% placeholder "myplaceholder" %}
+{% endblock %}
View
21 cms/test_utils/project/templates/placeholder_tests/test_five.html
@@ -0,0 +1,21 @@
+{% extends "placeholder_tests/base.html" %}
+
+{% load cms_tags %}
+
+{% comment %}
+
+This file should result in following placeholders:
+
+ - one (from base.html)
+ - extra_one (from this)
+ - two (from base.html)
+ - three (from base.html)
+
+{% endcomment %}
+
+{% block one %}
+ {% if something %}
+ {{ block.super }}
+ {% endif %}
+ {% placeholder "extra_one" %}
+{% endblock %}
View
22 cms/test_utils/project/templates/placeholder_tests/test_four.html
@@ -0,0 +1,22 @@
+{% extends "placeholder_tests/test_three.html" %}
+
+{% load cms_tags %}
+
+{% comment %}
+
+This file should result in following placeholders:
+
+ - new_one (from test_one.html)
+ - child (from child.html)
+ - four (from this)
+
+{% endcomment %}
+
+{% block three %}
+ {% block subblockthree %}
+ {% placeholder "four" %}
+ {% endblock %}
+{% endblock %}
+{% block two %}
+ {% include "placeholder_tests/child.html" %}
+{% endblock %}
View
16 cms/test_utils/project/templates/placeholder_tests/test_one.html
@@ -0,0 +1,16 @@
+{% extends "placeholder_tests/base.html" %}
+
+{% load cms_tags %}
+
+{% comment %}
+This files hould result in following placeholders:
+
+ - new_one (from this)
+ - two (from base.html)
+ - three (from base.html)
+
+{% endcomment %}
+
+{% block one %}
+ {% placeholder "new_one" %}
+{% endblock %}
View
17 cms/test_utils/project/templates/placeholder_tests/test_seven.html
@@ -0,0 +1,17 @@
+{% load cms_tags %}
+
+{% comment %}
+
+This file should result in following placeholders:
+
+ - new_one (from this)
+ - new_two (from this)
+ - new_three (from this)
+
+{% endcomment %}
+
+{% if something %}
+ <div class="something">{% placeholder "one" %}</div>
+{% else %}
+ <div class="something_else">{% placeholder "one" %}</div>
+{% endif %}
View
25 cms/test_utils/project/templates/placeholder_tests/test_six.html
@@ -0,0 +1,25 @@
+{% extends "placeholder_tests/base.html" %}
+
+{% load cms_tags %}
+
+{% comment %}
+
+This file should result in following placeholders:
+
+ - new_one (from this)
+ - new_two (from this)
+ - new_three (from this)
+
+{% endcomment %}
+
+{% block one %}
+ {% placeholder "new_one" %}
+
+ {% block two %}
+ {% placeholder "new_two" %}
+
+ {% block three %}
+ {% placeholder "new_three" %}
+ {% endblock %}
+ {% endblock %}
+{% endblock %}
View
17 cms/test_utils/project/templates/placeholder_tests/test_three.html
@@ -0,0 +1,17 @@
+{% extends "placeholder_tests/test_one.html" %}
+
+{% load cms_tags %}
+
+{% comment %}
+
+This file should result in following placeholders:
+
+ - new_one (from test_one.html)
+ - two (from base.html)
+ - new_three (from this)
+
+{% endcomment %}
+
+{% block three %}
+ {% placeholder "new_three" %}
+{% endblock %}
View
17 cms/test_utils/project/templates/placeholder_tests/test_two.html
@@ -0,0 +1,17 @@
+{% extends "placeholder_tests/base.html" %}
+
+{% load cms_tags %}
+
+{% comment %}
+This files hould result in following placeholders:
+
+ - child (from child.html)
+ - three (from base.html)
+
+{% endcomment %}
+
+{% block one %}
+ {% include "placeholder_tests/child.html" %}
+{% endblock %}
+
+{% block two %}{% endblock %}
View
9 cms/test_utils/project/templates/placeholderapp.html
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+{% load placeholder_tags %}
+{% block content %}
+{% for example in examples %}
+ <div>{% render_placeholder example.placeholder %}</div>
+{% empty %}
+ <div>No examples found</div>
+{% endfor %}
+{% endblock content %}
View
3 cms/test_utils/project/templates/sidebar_submenu.html
@@ -0,0 +1,3 @@
+{% load i18n cms_tags menu_tags %}
+
+{% show_menu 1 100 0 1 "sidebar_submenu_root.html" %}
View
9 cms/test_utils/project/templates/sidebar_submenu_root.html
@@ -0,0 +1,9 @@
+{% if children %}
+<div id="nav_sub">
+ <ul>
+ {% with "menu/menu.html" as template %}
+ {% include "menu/menu.html" %}
+ {% endwith %}
+ </ul>
+</div>
+{% else %}{% endif %}
View
1 cms/test_utils/project/templates/subdir/template.html
@@ -0,0 +1 @@
+{% load sekizai_tags %}{% render_block "css" %}{% render_block "js" %}test
View
3 cms/test_utils/project/templates/unicode_placeholder.html
@@ -0,0 +1,3 @@
+{% load cms_tags %}
+
+{% placeholder "nöd gültig" %}
View
18 cms/test_utils/project/urls.py
@@ -0,0 +1,18 @@
+from django.conf import settings
+from django.conf.urls.defaults import handler500, handler404, patterns, include, \
+ url
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ url(r'^admin/', include(admin.site.urls)),
+ url(r'^example/$', 'cms.test_utils.project.placeholderapp.views.example_view'),
+ url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
+ url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.CMS_MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+ (r'', include('django.contrib.staticfiles.urls')),
+ url(r'^', include('cms.urls')),
+)
View
16 cms/test_utils/project/urls_for_apphook_tests.py
@@ -0,0 +1,16 @@
+from django.conf import settings
+from django.conf.urls.defaults import handler500, handler404, patterns, include, \
+ url
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ url(r'^admin/', include(admin.site.urls)),
+ url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
+ url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.CMS_MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^', include('project.cms_urls_for_apphook_tests')),
+)
View
51 cms/test_utils/runners.py
@@ -0,0 +1,51 @@
+from django.conf import settings
+from django.test.simple import DjangoTestSuiteRunner
+from django.utils.unittest.suite import TestSuite
+import operator
+import time
+
+
+TIMINGS = {}
+
+def time_it(func):
+ def _inner(*args, **kwargs):
+ start = time.time()
+ func(*args, **kwargs)
+ end = time.time()
+
+ TIMINGS[unicode(func)] = end - start
+ return _inner
+
+
+class TimingSuite(TestSuite):
+ def addTest(self, test):
+ test = time_it(test)
+ super(TimingSuite, self).addTest(test)
+
+
+class JenkinsTestRunner(DjangoTestSuiteRunner):
+ def run_suite(self, suite, **kwargs):
+ from xmlrunner import XMLTestRunner
+ return XMLTestRunner(output=settings.JUNIT_OUTPUT_DIR).run(suite)
+
+
+
+class NormalTestRunner(DjangoTestSuiteRunner):
+ def build_suite(self, test_labels, extra_tests=None, **kwargs):
+ suite = super(NormalTestRunner, self).build_suite(test_labels, extra_tests, **kwargs)
+ if settings.TIME_TESTS:
+ return TimingSuite(suite)
+ else:
+ return suite
+
+ def teardown_test_environment(self, **kwargs):
+ super(NormalTestRunner, self).teardown_test_environment(**kwargs)
+ if settings.TIME_TESTS:
+ by_time = sorted(
+ TIMINGS.iteritems(),
+ key=operator.itemgetter(1),
+ reverse=True)[:10]
+ print("Ten slowest tests:")
+ for func_name, timing in by_time:
+ print("{t:.2f}s {f}".format(f=func_name, t=timing))
+
View
7 cms/test_utils/util/urls.py
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+from django.core.urlresolvers import clear_url_caches, set_urlconf
+
+
+def set_urls(urlpatterns):
+ clear_url_caches()
+ set_urlconf(urlpatterns)
View
9 cms/tests/placeholder.py
@@ -10,12 +10,14 @@
from cms.plugins.text.cms_plugins import TextPlugin
from cms.plugins.text.models import Text
from cms.test_utils.fixtures.fakemlng import FakemlngFixtures
+from cms.test_utils.project.fakemlng.models import Translations
+from cms.test_utils.project.placeholderapp.models import (Example1, Example2,
+ Example3, Example4, Example5)
from cms.test_utils.testcases import CMSTestCase, TestCase
from cms.test_utils.util.context_managers import (SettingsOverride,
UserLoginContext)
from cms.test_utils.util.mock import AttributeObject
-from cms.utils.placeholder import (PlaceholderNoAction, MLNGPlaceholderActions,
- get_placeholder_conf)
+from cms.utils.placeholder import PlaceholderNoAction, MLNGPlaceholderActions
from cms.utils.plugins import get_placeholders
from django.conf import settings
from django.contrib import admin
@@ -24,9 +26,6 @@
from django.http import HttpResponseForbidden, HttpResponse
from django.template import TemplateSyntaxError, Template
from django.template.context import Context, RequestContext
-from project.fakemlng.models import Translations
-from project.placeholderapp.models import (Example1, Example2, Example3,
- Example4, Example5)
class PlaceholderTestCase(CMSTestCase):
View
5 cms/tests/plugins.py
@@ -15,6 +15,9 @@
from cms.plugins.text.utils import (plugin_tags_to_id_list,
plugin_tags_to_admin_html)
from cms.plugins.twitter.models import TwitterRecentEntries
+from cms.test_utils.project.pluginapp.models import Article, Section
+from cms.test_utils.project.pluginapp.plugins.manytomany_rel.models import (
+ ArticlePluginModel)
from cms.test_utils.testcases import (CMSTestCase, URL_CMS_PAGE,
URL_CMS_PAGE_ADD, URL_CMS_PLUGIN_ADD, URL_CMS_PLUGIN_EDIT, URL_CMS_PAGE_CHANGE,
URL_CMS_PLUGIN_REMOVE)
@@ -27,8 +30,6 @@
from django.core.management import call_command
from django.forms.widgets import Media
from django.test.testcases import TestCase
-from project.pluginapp.models import Article, Section
-from project.pluginapp.plugins.manytomany_rel.models import ArticlePluginModel
import os
View
2 cms/tests/reversion_tests.py
@@ -11,7 +11,7 @@
from django.contrib.contenttypes.models import ContentType
from django.core.files.uploadedfile import SimpleUploadedFile
from os.path import join
-from project.fileapp.models import FileModel
+from cms.test_utils.project.fileapp.models import FileModel
from reversion.models import Revision, Version
from reversion import revision as revision_manager
import shutil
View
39 runtests.py
@@ -0,0 +1,39 @@
+from cms.test_utils.cli import configure
+import argparse
+import sys
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--jenkins', action='store_true', default=False,
+ dest='jenkins')
+ parser.add_argument('--jenkins-data-dir', default='.', dest='jenkins_data_dir')
+ parser.add_argument('--coverage', action='store_true', default=False,
+ dest='coverage')
+ parser.add_argument('--failfast', action='store_true', default=False,
+ dest='failfast')
+ parser.add_argument('--verbosity', default=1)
+ parser.add_argument('--time-tests', action='store_true', default=False,
+ dest='time_tests')
+ args = parser.parse_args()
+ args.urlconf = 'cms.test_utils.project.urls'
+ if getattr(args, 'jenkins', False):
+ TEST_RUNNER = 'cms.test_utils.runners.JenkinsTestRunner'
+ else:
+ TEST_RUNNER = 'cms.test_utils.runners.NormalTestRunner'
+ JUNIT_OUTPUT_DIR = getattr(args, 'jenkins_data_dir', '.')
+ TIME_TESTS = getattr(args, 'time_tests', False)
+ configure(TEST_RUNNER=TEST_RUNNER, JUNIT_OUTPUT_DIR=JUNIT_OUTPUT_DIR,
+ TIME_TESTS=TIME_TESTS, ROOT_URLCONF='cms.test_utils.project.urls')
+ from django.conf import settings
+ from django.test.utils import get_runner
+ TestRunner = get_runner(settings)
+
+ test_runner = TestRunner(verbosity=args.verbosity, interactive=False, failfast=args.failfast)
+ failures = test_runner.run_tests(['cms', 'menus'])
+ if failures:
+ sys.exit(bool(failures))
+
+
+if __name__ == '__main__':
+ main()

0 comments on commit 595d909

Please sign in to comment.
Something went wrong with that request. Please try again.