--- /dev/null
+"""
+Django settings for core project.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/1.6/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/1.6/ref/settings/
+"""
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+import os
+BASE_DIR = os.path.dirname(os.path.dirname(__file__))
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = ')1^j9pxlee5bz+$-g1_tphmnip=u^78r+xskny()61)ulk7n4w'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+TEMPLATE_DEBUG = True
+
+ALLOWED_HOSTS = []
+
+
+# Application definition
+
+INSTALLED_APPS = (
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+
+ 'django.contrib.sites', # Used by django_comments.
+ 'django_comments', # Used by migdal.
+ 'django_comments_xtd', # Used by migdal.
+ 'migdal',
+ 'fnpdjango', # Has template tags used in default migdal templates.
+ 'sorl.thumbnail', # Has template tags used in default migdal templates.
+ 'fnp_django_pagination', # Has template tags used in default migdal templates.
+ 'django_gravatar', # Has template tags used in default migdal templates.
+ 'core',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'fnpdjango.middleware.URLLocaleMiddleware', # Needed to set language.
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+ 'fnp_django_pagination.middleware.PaginationMiddleware', # Used in default migdal templates.
+)
+
+ROOT_URLCONF = 'core.urls'
+
+WSGI_APPLICATION = 'core.wsgi.application'
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+ }
+}
+
+# We have to provide a base template.
+TEMPLATE_DIRS = [
+ os.path.join(BASE_DIR, 'core/templates'),
+]
+TEMPLATE_CONTEXT_PROCESSORS = (
+ "django.core.context_processors.request", # Used in template tags.
+ "django.contrib.auth.context_processors.auth",
+ "django.core.context_processors.debug",
+ "django.core.context_processors.i18n",
+ "django.core.context_processors.media",
+ "django.core.context_processors.static",
+ "django.core.context_processors.tz",
+ "django.contrib.messages.context_processors.messages"
+)
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'APP_DIRS': True,
+ 'DIRS': TEMPLATE_DIRS,
+ 'OPTIONS': {
+ 'context_processors': [
+ "django.template.context_processors.request", # Used in template tags.
+ "django.contrib.auth.context_processors.auth",
+ "django.template.context_processors.debug",
+ "django.template.context_processors.i18n",
+ "django.template.context_processors.media",
+ "django.template.context_processors.static",
+ "django.template.context_processors.tz",
+ "django.contrib.messages.context_processors.messages"
+ ],
+ }
+ }
+]
+
+
+# These match languages in migrations.
+LANGUAGE_CODE = 'pl'
+LANGUAGES = [
+ ('pl', 'Polish'),
+ ('en', 'English'),
+ ]
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+STATIC_URL = '/static/'
+
+
+# Match default migdal markup type.
+from fnpdjango.utils.text.textilepl import textile_pl
+MARKUP_FIELD_TYPES = (
+ ('textile_pl', textile_pl),
+)
+
+
+# Create an Entry type.
+from fnpdjango.utils.settings import LazyUGettextLazy as gettext
+from migdal.helpers import EntryType
+
+MIGDAL_TYPES = (
+ EntryType('blog', gettext('blog'), commentable=True, on_main=True),
+ EntryType('info', gettext('info'), commentable=False, on_main=False),
+)
+
+
+# Needed for Haystack to work.
+HAYSTACK_CONNECTIONS = {
+ 'default': {
+ 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
+ 'URL': 'http://127.0.0.1:8983/solr/prawokultury'
+ },
+}
+
+# django_comments need SITE_ID.
+SITE_ID = 1
--- /dev/null
+from django.test import TestCase
+from migdal.models import Entry
+
+
+class MigdalTests(TestCase):
+ def test_x(self):
+ Entry.objects.create(
+ type='info', author='An author',
+ published_pl=True, title_pl='An info entry', slug_pl='test1',
+ body_pl='**Test text**',
+ )
+ Entry.objects.create(
+ type='blog', author='An author',
+ published_pl=True, title_pl='A blog entry', slug_pl='test2',
+ body_pl='**Test blog text**',
+ )
+
+
+ response = self.client.get('/')
+ self.assertContains(response, 'A blog entry')
+ self.assertNotContains(response, 'An info entry')
+
+
+
+ response = self.client.get('/info/')
+ self.assertContains(response, 'An info entry')
+
+ response = self.client.get('/info/test1/')
+ self.assertContains(response, '<b>Test text</b>')
from django.shortcuts import get_object_or_404
from django_comments_xtd.models import XtdComment
import django_comments as comments
+import django
from django import template
from migdal import app_settings
from migdal.models import Category, Entry
register = template.Library()
+if django.VERSION < (1, 8):
+ # See https://docs.djangoproject.com/en/2.2/releases/1.8/#rendering-templates-loaded-by-get-template-with-a-context
+ context_for_get_template = template.Context
+else:
+ context_for_get_template = lambda x: x
+
+
+
@register.simple_tag(takes_context=True)
def entry_begin(context, entry, detail=False):
t = template.loader.select_template((
'object': entry,
'detail': detail,
}
- return t.render(template.Context(context))
+ return t.render(context_for_get_template(context))
@register.simple_tag(takes_context=True)
'request': context['request'],
'object': entry,
}
- return t.render(template.Context(context))
+ return t.render(context_for_get_template(context))
@register.simple_tag(takes_context=True)
'object': entry,
'counter': counter,
}
- return t.render(template.Context(context))
+ return t.render(context_for_get_template(context))
@register.inclusion_tag('migdal/categories.html', takes_context=True)