From 16358b72e70a109652609551c0ad89aec28fc58b Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 24 Jul 2019 12:18:03 +0200 Subject: [PATCH] Machina preview. --- requirements/requirements.txt | 1 + src/wolnelektury/settings/apps.py | 12 ++++-- src/wolnelektury/settings/basic.py | 9 ++++ src/wolnelektury/settings/cache.py | 5 ++- src/wolnelektury/settings/contrib.py | 7 ++++ src/wolnelektury/settings/static.py | 6 +++ src/wolnelektury/templates/board_base.html | 48 ++++++++++++++++++++++ src/wolnelektury/urls.py | 3 +- 8 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 src/wolnelektury/templates/board_base.html diff --git a/requirements/requirements.txt b/requirements/requirements.txt index d91672550..a75156a2b 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -15,6 +15,7 @@ django-extensions==1.7.8 djangorestframework==3.9.1 djangorestframework-xml django-admin-ordering==0.10.0 +django-machina==0.7.1 oauthlib>=3.0.1,<3.1 diff --git a/src/wolnelektury/settings/apps.py b/src/wolnelektury/settings/apps.py index 213f2e7ce..76a921898 100644 --- a/src/wolnelektury/settings/apps.py +++ b/src/wolnelektury/settings/apps.py @@ -1,7 +1,8 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -# These are the ones we should test. + +from machina import get_apps as get_machina_apps + INSTALLED_APPS_OUR = [ 'wolnelektury', # our @@ -72,6 +73,11 @@ INSTALLED_APPS_CONTRIB = [ 'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.google', # 'allauth.socialaccount.providers.twitter', -] + + # Machina related apps: + 'mptt', + 'haystack', + 'widget_tweaks', +] + get_machina_apps() INSTALLED_APPS = INSTALLED_APPS_OUR + INSTALLED_APPS_CONTRIB diff --git a/src/wolnelektury/settings/basic.py b/src/wolnelektury/settings/basic.py index 2684cc4cf..e6511abd3 100644 --- a/src/wolnelektury/settings/basic.py +++ b/src/wolnelektury/settings/basic.py @@ -2,6 +2,7 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from os import path +from machina import MACHINA_MAIN_TEMPLATE_DIR from .paths import PROJECT_DIR DEBUG = False @@ -13,6 +14,8 @@ ADMINS = [ MANAGERS = ADMINS +CONTACT_EMAIL = 'fundacja@nowoczesnapolska.org.pl' + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # 'postgresql_psycopg2' @@ -39,6 +42,10 @@ SITE_ID = 1 TEMPLATES = [{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ( + path.join(PROJECT_DIR, 'templates'), # Duplicate, because of Machina<1 weird configuration. + MACHINA_MAIN_TEMPLATE_DIR, + ), 'OPTIONS': { 'loaders': ( ('django.template.loaders.cached.Loader', ( @@ -54,6 +61,7 @@ TEMPLATES = [{ 'django.template.context_processors.request', 'wolnelektury.context_processors.extra_settings', 'search.context_processors.search_form', + 'machina.core.context_processors.metadata', ), }, }] @@ -75,6 +83,7 @@ MIDDLEWARE_CLASSES = [ 'django.contrib.messages.middleware.MessageMiddleware', 'fnpdjango.middleware.SetRemoteAddrFromXRealIP', 'django.middleware.cache.FetchFromCacheMiddleware', + 'machina.apps.forum_permission.middleware.ForumPermissionMiddleware', ] ROOT_URLCONF = 'wolnelektury.urls' diff --git a/src/wolnelektury/settings/cache.py b/src/wolnelektury/settings/cache.py index 107ac0db7..fab83259f 100644 --- a/src/wolnelektury/settings/cache.py +++ b/src/wolnelektury/settings/cache.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -24,6 +23,10 @@ CACHES = { '127.0.0.1:11211', ], }, + 'machina_attachments': { + 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', + 'LOCATION': '/tmp', + }, } CACHE_MIDDLEWARE_SECONDS = 24 * 60 * 60 diff --git a/src/wolnelektury/settings/contrib.py b/src/wolnelektury/settings/contrib.py index 308353afc..5e89a6f90 100644 --- a/src/wolnelektury/settings/contrib.py +++ b/src/wolnelektury/settings/contrib.py @@ -46,3 +46,10 @@ REST_FRAMEWORK = { DEBUG_TOOLBAR_CONFIG = { 'RESULTS_CACHE_SIZE': 100, } + + +HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine', + }, +} diff --git a/src/wolnelektury/settings/static.py b/src/wolnelektury/settings/static.py index cccb6807f..b8b782839 100644 --- a/src/wolnelektury/settings/static.py +++ b/src/wolnelektury/settings/static.py @@ -202,3 +202,9 @@ STATICFILES_FINDERS = [ 'pipeline.finders.CachedFileFinder', 'pipeline.finders.PipelineFinder', ] + + +from machina import MACHINA_MAIN_STATIC_DIR +STATICFILES_DIRS = ( + MACHINA_MAIN_STATIC_DIR, +) diff --git a/src/wolnelektury/templates/board_base.html b/src/wolnelektury/templates/board_base.html new file mode 100644 index 000000000..cadb6bbe8 --- /dev/null +++ b/src/wolnelektury/templates/board_base.html @@ -0,0 +1,48 @@ +{% extends "board_base.html" %} +{% load i18n %} + +{% block header %} + + + + + + +{% endblock header %} diff --git a/src/wolnelektury/urls.py b/src/wolnelektury/urls.py index f284857c4..bd437a6be 100644 --- a/src/wolnelektury/urls.py +++ b/src/wolnelektury/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -7,6 +6,7 @@ from django.conf import settings from django.contrib import admin from django.views.generic import RedirectView import django.views.static +from machina.app import board import catalogue.views import picture.views from . import views @@ -75,6 +75,7 @@ urlpatterns += [ url(r'^szukaj/', include('search.urls')), url(r'^i18n/', include('django.conf.urls.i18n')), + url(r'^forum/', include(board.urls)), ] urlpatterns += [ -- 2.20.1