~developer-ubuntu-com-dev/developer-ubuntu-com/django-1.8-cms-2.3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# -*- coding: utf-8 -*-
"""
Django settings for developer_portal 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/
"""

from django.utils.translation import ugettext_lazy as _

ADMIN_GROUP = 'ubuntudeveloperportal'
EDITOR_GROUP = 'ubuntudeveloperportal-editors'

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_PATH = os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]

SITE_ID = 1

# 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 = 'we3w67a1=2e384asi&f_fcp8meje#)n@lyoys21izkwo)%eknh'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['127.0.0.1', 'developer.ubuntu.com']


# 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',

    # Allow login from Ubuntu SSO
    'django_openid_auth',

    'menus', #helper for model independent hierarchical website navigation
    'sekizai', #for javascript and css management
    'reversion', #content versioning
    'django_pygments',
    'django_comments',
    'tagging',
    'template_debug',

    'ckeditor',
    'djangocms_text_ckeditor',

    'cms', #django CMS itself
    'djangocms_link',
    'djangocms_picture',
    'djangocms_video',
    'djangocms_snippet',
    'treebeard', #required by django CMS

    'cmsplugin_zinnia',
    'zinnia',
    'zinnia_ckeditor',

    'developer_portal',

    'webapp_creator',

    'store_data',

    'api_docs',
]

MIDDLEWARE_CLASSES = (
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',

    # Replace standard session middleware with one that will strip
    # sessionid from the Cookie on anonymous sessions
    #
    #'django.contrib.sessions.middleware.SessionMiddleware',
    'developer_portal.middleware.CacheFriendlySessionMiddleware',

    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',

    'django.middleware.cache.FetchFromCacheMiddleware',
    
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',

)
#CACHE_MIDDLEWARE_SECONDS = 3600
#CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(PROJECT_PATH, "templates"),
            ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.core.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.core.context_processors.i18n',
                'django.core.context_processors.media',
                'django.core.context_processors.static',

                'sekizai.context_processors.sekizai',
                'cms.context_processors.cms_settings',
                'django.contrib.messages.context_processors.messages',
            ]
        }
    }
]

ROOT_URLCONF = 'developer_portal.urls'

WSGI_APPLICATION = 'developer_portal.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'en'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

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

MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
MEDIA_URL = '/media/'

ASSETS_URL = '//assets.ubuntu.com/'

# Django CMS specific settings
#
CMS_PERMISSION = True

CMS_CACHE_DURATIONS = {
    'menus': 0,
}

CMS_TEMPLATES = (
    ('default.html', 'Default'),
    ('landing_page.html', 'Landing Page'),
    ('no_subnav.html', 'Without Subnav'),
    ('with_hero.html', 'With Hero'),
)

LOCALE_PATHS = (
    os.path.join(PROJECT_PATH, 'locale'),
)

LANGUAGES = [
    ('en', _('English')),
    ('zh-cn', _('Simplified Chinese')),
]

CMS_LANGUAGES = {
    1: [
        {
            'code': 'en',
            'name': _('English'),
            'public': True,
            'hide_untranslated': True,
            'redirect_on_fallback': False,
        },
        {
            'code': 'zh-cn',
            'name': _('Simplified Chinese'),
            'fallbacks': ['en'],
            'hide_untranslated': True,
            'redirect_on_fallback': False,
            'public': True,
        },
        {
            'code': 'es',
            'name': _('Spanish'),
            'fallbacks': ['en'],
            'hide_untranslated': False,
            'redirect_on_fallback': False,
            'public': True,
        },
    ],
    'default': {
        'fallbacks': ['en'],
        'redirect_on_fallback':False,
        'public': False,
        'hide_untranslated': False,
    }
}

AUTHENTICATION_BACKENDS = (
    'django_openid_auth.auth.OpenIDBackend',
    'django.contrib.auth.backends.ModelBackend',
)

# OPENID Related settings
OPENID_STRICT_USERNAMES = False
OPENID_FOLLOW_RENAMES = True
OPENID_SREG_REQUIRED_FIELDS = ['email']
OPENID_CREATE_USERS = True
OPENID_REUSE_USERS = False
OPENID_UPDATE_DETAILS_FROM_SREG = True
OPENID_SSO_SERVER_URL = 'https://login.ubuntu.com/'
OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO = True

# Tell django.contrib.auth to use the OpenID signin URLs.
LOGIN_URL = '/openid/login'
LOGIN_REDIRECT_URL = '/'

# Django 1.6 uses a JSON serializer by default, which breaks
# django_openid_auth, so force it to use the old default
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'

CMS_PLACEHOLDER_CONF = {
    'page_content': {
        'name': _("Page content"),
        'default_plugins': [
            {
                'plugin_type': 'TextPlugin',
                'values': {
                    # Translators: this is the default text that will be shown
                    # to editors when editing a page. You can use some HTML,
                    # but don't go wild :)
                    'body': _('<p>Add content here...</p>'),
                },
            },
        ],
    },
}

CKEDITOR_UPLOAD_PATH = "media/"
CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
CKEDITOR_IMAGE_BACKEND = 'dummy'
CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Full',
    },
    'zinnia-content': {
        'toolbar_Zinnia': [
            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
            ['Undo', 'Redo'],
            ['Scayt'],
            ['Link', 'Unlink', 'Anchor'],
            ['Image', 'Table', 'HorizontalRule', 'SpecialChar'],
            ['Source'],
            ['Maximize'],
            '/',
            ['Bold', 'Italic', 'Underline', 'Strike',
             'Subscript', 'Superscript', '-', 'RemoveFormat'],
            ['NumberedList', 'BulletedList', '-',
             'Outdent', 'Indent', '-', 'Blockquote'],
            ['Styles', 'Format'],
        ],
        'toolbar': 'Zinnia',
    },
}
TEXT_ADDITIONAL_TAGS = ('iframe',)
TEXT_ADDITIONAL_ATTRIBUTES = ('scrolling', 'allowfullscreen', 'frameborder')

CMSPLUGIN_ZINNIA_APP_URLS = ['developer_portal.blog.urls']

REST_FRAMEWORK = {
    # Use hyperlinked styles by default.
    # Only used if the `serializer_class` attribute is not set on a view.
    'DEFAULT_MODEL_SERIALIZER_CLASS':
        'rest_framework.serializers.HyperlinkedModelSerializer',

    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
    ],
    
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication',
    ),
    
    #'PAGINATE_BY': 10,
}

MIGRATION_MODULES = {
    'cms': 'cms.migrations',
    'cmsplugin_zinnia': 'cmsplugin_zinnia.migrations',
    'djangocms_link': 'djangocms_link.migrations',
    'djangocms_picture': 'djangocms_picture.migrations',
    'djangocms_snippet': 'djangocms_snippet.migrations',
    'djangocms_text_ckeditor': 'djangocms_text_ckeditor.migrations',
    'djangocms_video': 'djangocms_video.migrations',
    'django_comments': 'django_comments.migrations',
    'menus': 'menus.migrations',
    'rest_framework.authtoken': 'rest_framework.authtoken.migrations',
    'reversion': 'reversion.migrations',
    'tagging': 'tagging.migrations',
    'taggit': 'taggit.migrations',
    'zinnia': 'zinnia.migrations',
}

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'errors': {
            'level': 'ERROR',
            'class': 'logging.FileHandler',
            'filename': './error.log',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['errors'],
            'level': 'ERROR',
            'propagate': True,
        },
    },
}