Skip to content

Instantly share code, notes, and snippets.

@wfehr
wfehr / README
Last active Jun 27, 2019
Overview of changed pages for django-cms
View README
This gist provides an overview for page-changes in django-cms.
It prints out the changed plugins etc. for pages.
Note: This is not a 'diff-tool', so you won't see the exact changes, e.g. text-content.
@wfehr
wfehr / __init__.py
Created Oct 17, 2018
Test-app for django-cms apphooks.
@wfehr
wfehr / redirect.py
Last active Oct 30, 2018
Django middleware to remove trailing slashes
View redirect.py
from django import http
from django.conf import settings
from django.core import urlresolvers
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import MiddlewareMixin
class AppendOrRemoveSlashMiddleware(MiddlewareMixin):
"""
This middleware removes a given trailing slash if the resulting path is
@wfehr
wfehr / djangocms_migration_helper.py
Last active Oct 16, 2018
Helper for migrations in django-cms for plugins which get a model and previously had none.
View djangocms_migration_helper.py
# anywhere_you_want.py
def create_plugins_from_cmsplugin(new_model_app, new_plugin_model_name,
new_plugin_name, apps=None):
"""
Create plugins for `new_plugin_name` from CMSPlugin-Plugins. This is
necessary if you add a model to a plugin which previously had none.
"""
if apps is None:
from django.apps.registry import apps as dj_apps
apps = dj_apps
@wfehr
wfehr / migration_filer_deprecation_move.py
Created Apr 30, 2018
Migration to move deprecated cmsplugin-*-plugins to the newer djangocms-*-plugins
View migration_filer_deprecation_move.py
from django.apps import apps as global_apps
from django.db import migrations
from djangocms_file.models import get_templates as get_file_templates
from djangocms_picture.models import get_templates as get_picture_templates
def forwards_filer_file(apps, schema_editor):
try:
CMSPluginFilerFile = apps.get_model('cmsplugin_filer_file',
'FilerFile')