Use XMM (Legacy CMS)¶
Use XMM as content management system and migrate later to the new CMS.
Dependencies¶
Install necessary dependencies first.
pipenv install
yarn install
Update database by executing the two following commands:
./manage.py migrate
./manage.py sync_translation_fields --noinput
Settings¶
The following changes has to be done in the settings.py First off all you have to activate CMS_LEGACY_MODE.
CMS_LEGACY_MODE = True
VIEWS¶
CMS views has been moved into legacy package. The inheritance must be checked if the views have been overwritten.
VIEWS = {
'cms-page-index': 'eshop.modules.cms.legacy_views.cms_page',
'cms-page': 'eshop.modules.cms.legacy_views.cms_page',
}
CMS object classes¶
Object classes has been moved into legacy package. The inheritance must be checked if the objects have been overwritten.
CMS_OBJECT = 'eshop.modules.cms.models.legacy.base.BaseCMSObject'
CMS_PAGE_CLASS = 'eshop.modules.cms.models.legacy.page.Page'
CMS_PAGE_CLASSES = {
'landing': 'eshop.modules.cms.models.legacy.page.LandingPage',
'link': 'eshop.modules.cms.models.legacy.page.LinkPage',
'folder': 'eshop.modules.cms.models.legacy.page.FolderPage',
'notification': 'eshop.modules.cms.models.legacy.page.NotificationPage',
}
CMS_BLOCK_CLASSES = {
'button': 'eshop.modules.cms.models.legacy.block.ButtonBlock',
'newsletter_button': 'eshop.modules.cms.models.legacy.block.ButtonBlock',
'card': 'eshop.modules.cms.models.legacy.block.CardBlock',
'text': 'eshop.modules.cms.models.legacy.block.TextBlock',
'offset': 'eshop.modules.cms.models.legacy.block.OffsetBlock',
'map': 'eshop.modules.cms.models.legacy.block.MapBlock',
'slider': 'eshop.modules.cms.models.legacy.block.SliderBlock',
'video': 'eshop.modules.cms.models.legacy.block.VideoBlock',
'news': 'eshop.modules.cms.models.legacy.block.NewsBlock',
'gallery': 'eshop.modules.cms.models.legacy.block.GalleryBlock',
'itemlist': 'eshop.modules.cms.models.legacy.block.ItemlistBlock',
}
TEMPLATES - context_processors¶
Add legacy_mode context processor.
...
'eshop.modules.cms.context_processors.notifications',
'eshop.modules.cms.context_processors.legacy_mode',
'eshop.modules.catalog.context_processors.navigation',
...
SEARCH¶
CMS search has been moved into legacy package. The inheritance msut be checked if search objects have been overwritten.
...
('pages', {
'document_class': 'eshop.modules.cms.legacy_search.PageDocument',
'search_class': 'eshop.modules.cms.legacy_search.CMSSearch',
'form_class': 'eshop.modules.cms.forms.CMSSearchForm',
'model_class': 'eshop.modules.cms.models.legacy.page.Page',
'permission': None,
}),
...
BACKEND¶
URL¶
Change cms_error_handler imports in project urls.py.
if getattr(settings, 'CMS_LEGACY_MODE', False):
from eshop.modules.cms.legacy_views import cms_error_handler
else:
from eshop.modules.cms.views import cms_error_handler
Celery¶
Add elastic_celery task to project tasks.py. Replace [PROJECT] with your project package name.
@task
def elastic_celery(ctx):
print('Running Elastic Celery worker...')
try:
log = '-l INFO'
run(f'PYTHONPATH=. celery worker -A [PROJECT].celery -Q elastic {log}', pty=True)
except UnexpectedExit as e:
if e.result.exited != 1:
print('Elastic Celery task queue worker crashed!')
raise
except KeyboardInterrupt:
pass
print('Stopped Elastic Celery beat and worker')
@task(default=True)
def runall(ctx, with_flower=False, with_chrome=False, with_exports_celery=False):
tasks = [runserver, celery, elastic_celery]
if with_flower:
tasks.append(flower)
if with_chrome:
tasks.append(chrome)
if with_exports_celery:
tasks.append(exports_celery)
processes = [Process(target=func, args=(ctx,)) for func in tasks]
[proc.start() for proc in processes]
[proc.join() for proc in processes]
print('All background processes cleaned up.')
Add new celery task to settings.py
# Celery task queue
CELERY_BROKER_URL = env('CELERY_BROKER_URL', default='redis://localhost:6379/1')
CELERY_RESULT_BACKEND = env('CELERY_RESULT_BACKEND', default='redis://localhost:6379/1')
CELERY_DEFAULT_QUEUE = 'celery'
CELERY_DEFAULT_EXCHANGE_TYPE = 'topic'
CELERY_DEFAULT_ROUTING_KEY = 'celery'
CELERY_TASK_QUEUES = (
Queue('celery', Exchange('celery'), routing_key='celery'),
Queue('elastic', Exchange('elastic'), routing_key='elastic'),
)
CELERY_TASK_ROUTES = {
'api_core_update_index': {
'queue': 'elastic',
'routing_key': 'elastic',
}
}
if 'eshop.modules.exporter' in INSTALLED_APPS:
CELERY_TASK_QUEUES += (Queue('exporter', Exchange('exporter'), routing_key='exporter'),)
CELERY_TASK_ROUTES['eshop.modules.Export.tasks.Export'] = {
'queue': 'exporter',
'routing_key': 'exporter',
}
FRONTEND¶
JavaScript¶
Import used javascript files in ui/js/app.js
import 'poly-eshop4/eshop/ui/js/news'; import 'poly-eshop4/eshop/ui/js/cms';
Create the file ui/js/admin.js
import 'poly-eshop4/eshop/ui/js/admin';
Add “vue” alias, “admin” entrypoint, “css” and font rules to your webpack.config.js (or adopt the changes from poly-eshop4/eshop/conf/project_template/ui/webpack.config.js)
... resolve: { ... alias: { vue: 'vue/dist/vue.js', }, }, entry: { app: [...], admin: [ path.resolve(rootPath, 'ui/js/admin.js'), ], }, module: { rules: [ ... { test: /\.css/, use: ['style-loader', 'css-loader'], }, { test: /\.(eot|svg|ttf|woff|woff2)(\??#?v=[.0-9]+)?$/, loader: 'file-loader', options: { name: '[name].[ext]', outputPath: '../fonts/', publicPath: '/static/fonts/', esModule: false, }, }, ... ], }, ...
Templates¶
Check project specific cms templates and change extends to legacy package.
{% extends "cms/legacy/bocks/article.html" %}
{% extends "cms/legacy/pages/default.html" %}
{% extends "cms/legacy/forms/form.html" %}