Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0aac245
Python-3 pythonic
jrief Apr 11, 2020
cf365d6
in editor: fix styling of map center button
jrief Apr 8, 2020
e99d4a7
In leafpligin markers, fix pasting from clipboard
jrief Mar 10, 2020
62a4680
Merge pull request #385 from jrief/releases/1.3
jrief May 8, 2020
924e478
fix external requirements
jrief May 10, 2020
c1d6ce6
Bump to version 1.3.1
jrief May 10, 2020
3581e87
Merge branch 'releases/1.3'
jrief May 10, 2020
42424df
Merge branch 'master' of github.com:jrief/djangocms-cascade
jrief May 10, 2020
8c85754
adopt interface to django-CMS>3.4
jrief May 14, 2020
6aac93b
upgrade build instructions to Sphinx > 3
jrief May 14, 2020
8841c0e
remove script files
jrief May 14, 2020
1d8db15
unwrap container from sidebar
jrief May 14, 2020
d77f600
remove djangocms-helper from testing dependencies
jrief May 23, 2020
8de3b8a
fix #386: migration to version 1
jrief Jun 28, 2020
63d134a
adjust empty lines
jrief Jun 28, 2020
80c3649
upgrade dependencies
jrief Jun 28, 2020
9dfacf1
Bump to version 1.3.2
jrief Jun 28, 2020
9b7b067
Merge branch 'master' of github.com:jrief/djangocms-cascade
jrief Jun 28, 2020
4a52a33
allow Django-3 to fail, because helpers not updated yet
jrief Jun 28, 2020
74ca318
fix deletion of marker in map
jrief Aug 4, 2020
362d5ba
Bump to 1.3.3
jrief Aug 4, 2020
1783804
code styling fixes
Sep 21, 2020
70909fd
use alternative request headers
Sep 22, 2020
9023b40
make the response a valid one
jrief Oct 15, 2020
c80ff39
Bump to version 1.3.4
jrief Oct 15, 2020
1a0b8b8
Add Python-3.8 to testing matrix
jrief Oct 15, 2020
f301db5
fix testing matrix
jrief Oct 15, 2020
164d916
Replace deprecated Jquery .bind() call with .on()
haricot Oct 28, 2020
e1d8479
fix rare past from clipboard exception, when clipboard is filled with…
jrief Oct 29, 2020
9714f7e
use mapbox new api
Nov 13, 2020
0919c6b
Merge pull request #395 from markusmo/feature/mapbox-new-api
jrief Nov 14, 2020
da9713d
remove whitespace in links caused by empty newlines
jrief Nov 19, 2020
4935309
fix invalid syntax
jrief Nov 19, 2020
9e990f1
Merge branch 'master' of github.com:jrief/djangocms-cascade
jrief Nov 19, 2020
78cb7f4
Replace deprecated jQuery .bind() call with .on()
jrief Nov 19, 2020
a569891
Merge pull request #393 from haricot/patch-4
jrief Nov 19, 2020
b473070
Bump to version 1.3.5
jrief Nov 19, 2020
a972823
refactor link validation from method clean() to _post_clean()
jrief Nov 19, 2020
6e28299
update changelog
jrief Nov 19, 2020
b361ab8
remove Python2 legacy syntax
jrief Nov 19, 2020
fafe6fa
changes for 1.3.5
jrief Nov 19, 2020
7955b9e
Fix regression on link validation introduced in 1.3.5
jrief Nov 20, 2020
fe95405
Bump to version 1.3.6
jrief Nov 20, 2020
c9e8f4f
remove unused import
jrief Nov 23, 2020
65d91e1
Perform validation of ext URL during form editing
jrief Jan 14, 2021
bada1f8
migrate towards django-entangled>=0.4
jrief Jan 14, 2021
07983c8
Bump to version 1.3.7
jrief Jan 14, 2021
73915b2
#397 added idea to gitignore
execut Feb 6, 2021
cfcb1c6
#397 fixed bug with bad tags of TextImagePlugin
execut Feb 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.{py}]
[*.py]
line_length=119
indent_style = space
indent_size = 4
Expand All @@ -22,7 +22,7 @@ indent_size = 4
indent_style = tab
indent_size = 4

[*.{rst}]
[*.rst]
line_length=100

[*.{json,yml,css}]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
*.log
*.pot
*.pyc
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: python

python:
- 3.5
- 3.6
Expand All @@ -13,13 +13,13 @@ env:
- DJANGOVER=django30 CMSVER=cms37

matrix:
exclude:
allow_failures:
- python: 3.8
env: DJANGOVER=django21 CMSVER=cms36
- python: 3.8
env: DJANGOVER=django22 CMSVER=cms36
- python: 3.8
env: DJANGOVER=django22 CMSVER=cms37
env: DJANGOVER=django30 CMSVER=cms37

install:
- pip install tox
Expand Down
2 changes: 1 addition & 1 deletion cmsplugin_cascade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
15. git commit -m 'Start with <version>'
16. git push
"""
__version__ = "1.3"
__version__ = "1.3.7"

default_app_config = 'cmsplugin_cascade.apps.CascadeConfig'
20 changes: 19 additions & 1 deletion cmsplugin_cascade/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from urllib.parse import urlparse
import requests

from django.conf.urls import url
from django.contrib import admin
from django.contrib.sites.shortcuts import get_current_site
Expand All @@ -7,6 +9,7 @@
from django.http import JsonResponse, HttpResponseForbidden, HttpResponseNotFound
from django.urls import reverse
from django.utils.translation import get_language_from_request

from cms.models.pagemodel import Page
from cms.extensions import PageExtensionAdmin
from cms.utils.page import get_page_from_path
Expand All @@ -33,12 +36,14 @@ def get_form(self, request, obj=None, **kwargs):

def get_urls(self):
urls = [
url(r'^get_page_sections/$', lambda: None, name='get_page_sections'), # just to reverse
url(r'^get_page_sections/$', lambda _: JsonResponse({'element_ids': []}),
name='get_page_sections'), # just to reverse
url(r'^get_page_sections/(?P<page_pk>\d+)$',
self.admin_site.admin_view(self.get_page_sections)),
url(r'^published_pages/$', self.get_published_pagelist, name='get_published_pagelist'),
url(r'^fetch_fonticons/(?P<iconfont_id>[0-9]+)$', self.fetch_fonticons),
url(r'^fetch_fonticons/$', self.fetch_fonticons, name='fetch_fonticons'),
url(r'^validate_exturl/$', self.validate_exturl, name='validate_exturl'),
]
urls.extend(super().get_urls())
return urls
Expand Down Expand Up @@ -108,6 +113,19 @@ def fetch_fonticons(self, request, iconfont_id=None):
data['families'] = icon_font.get_icon_families()
return JsonResponse(data)

def validate_exturl(self, request):
"""
Perform a GET request onto the given external URL and return its status.
"""
exturl = request.GET.get('exturl')
request_headers = {'User-Agent': 'Django-CMS-Cascade'}
try:
response = requests.get(exturl, allow_redirects=True, headers=request_headers)
except Exception:
return JsonResponse({'status_code': 500})
else:
return JsonResponse({'status_code': response.status_code})

def changeform_view(self, request, object_id=None, form_url='', extra_context=None):
extra_context = dict(extra_context or {}, icon_fonts=IconFont.objects.all())
return super().changeform_view(
Expand Down
2 changes: 1 addition & 1 deletion cmsplugin_cascade/app_settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

class AppSettings(object):
class AppSettings:

def _setting(self, name, default=None):
from django.conf import settings
Expand Down
9 changes: 5 additions & 4 deletions cmsplugin_cascade/bootstrap4/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.utils.safestring import mark_safe
from django.utils.text import format_lazy
from django.utils.translation import ngettext_lazy, gettext_lazy as _

from cms.plugin_pool import plugin_pool
from entangled.forms import EntangledModelFormMixin
from cmsplugin_cascade import app_settings
Expand Down Expand Up @@ -57,7 +58,7 @@ def clean_breapoints(self):
return self.cleaned_data['glossary']


class ContainerGridMixin(object):
class ContainerGridMixin:
def get_grid_instance(self):
fluid = self.glossary.get('fluid', False)
try:
Expand Down Expand Up @@ -124,7 +125,7 @@ class Meta:
untangled_fields = ['num_children']


class RowGridMixin(object):
class RowGridMixin:
def get_grid_instance(self):
row = grid.Bootstrap4Row()
query = Q(plugin_type='BootstrapContainerPlugin') | Q(plugin_type='BootstrapColumnPlugin') \
Expand Down Expand Up @@ -156,7 +157,7 @@ def save_model(self, request, obj, form, change):
plugin_pool.register_plugin(BootstrapRowPlugin)


class ColumnGridMixin(object):
class ColumnGridMixin:
valid_keys = ['xs-column-width', 'sm-column-width', 'md-column-width', 'lg-column-width', 'xs-column-width',
'xs-column-offset', 'sm-column-offset', 'md-column-offset', 'lg-column-offset', 'xs-column-offset']
def get_grid_instance(self):
Expand Down Expand Up @@ -195,7 +196,7 @@ def choose_help_text(*phrases):
return phrases[1].format(bs4_breakpoints[first].min)
else:
return phrases[2]

if 'parent' in self._cms_initial_attributes:
container=self._cms_initial_attributes['parent'].get_ancestors().order_by('depth').last().get_bound_plugin()
else:
Expand Down
5 changes: 3 additions & 2 deletions cmsplugin_cascade/bootstrap4/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import itertools
from operator import add
import re

from django.utils.translation import gettext_lazy as _


Expand Down Expand Up @@ -74,7 +75,7 @@ def media_query(self):
][self.value]


class Bound(object):
class Bound:
def __init__(self, min, max):
self.min = float(min)
self.max = float(max)
Expand Down Expand Up @@ -122,7 +123,7 @@ def extend(self, other):
}


class Break(object):
class Break:
def __init__(self, breakpoint, classes, narrower=None):
self.breakpoint = breakpoint
self.fixed_units = 0
Expand Down
5 changes: 3 additions & 2 deletions cmsplugin_cascade/bootstrap4/jumbotron.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
from entangled.forms import EntangledModelFormMixin

from cms.plugin_pool import plugin_pool
from cmsplugin_cascade import app_settings
from cmsplugin_cascade.fields import ColorField, MultiSizeField, CascadeImageField
Expand All @@ -16,7 +17,7 @@
logger = logging.getLogger('cascade')


class ImageBackgroundMixin(object):
class ImageBackgroundMixin:
@property
def element_heights(self):
element_heights = self.glossary.get('element_heights', {})
Expand Down Expand Up @@ -220,7 +221,7 @@ def render(self, context, instance, placeholder):
'CSS_PREFIXES': app_settings.CSS_PREFIXES,
})
except Exception as exc:
logger.warning("Unable generate picture elements. Reason: {}".format(exc))
logger.warning("Unable generate picture elements. Reason: {}".format(exc))
return self.super(BootstrapJumbotronPlugin, self).render(context, instance, placeholder)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion cmsplugin_cascade/clipboard/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def paste_from_clipboard(self, request, form):
cascade_clipboard.save(update_fields=['last_accessed_at'])

# detach plugins from clipboard and reattach them to current placeholder
cb_placeholder_plugin = request.toolbar.clipboard.cmsplugin_set.first()
cb_placeholder_plugin = request.toolbar.clipboard.cmsplugin_set.filter(plugin_type='PlaceholderPlugin').first()
cb_placeholder_instance, _ = cb_placeholder_plugin.get_plugin_instance()
new_plugins = cb_placeholder_instance.placeholder_ref.get_plugins()
new_plugins.update(placeholder=placeholder)
Expand Down
2 changes: 1 addition & 1 deletion cmsplugin_cascade/extra_fields/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

class PluginExtraFieldsConfig(object):
class PluginExtraFieldsConfig:
"""
Each Cascade Plugin can be configured to accept extra fields, such as an ID tag, one or more
CSS classes or inlines styles. It is possible to configure these fields globally using an
Expand Down
3 changes: 2 additions & 1 deletion cmsplugin_cascade/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
from django.core.validators import ProhibitNullCharactersValidator
from django.utils.deconstruct import deconstructible
from django.utils.translation import gettext_lazy as _, pgettext

from cmsplugin_cascade import app_settings
from cmsplugin_cascade.widgets import ColorPickerWidget, BorderChoiceWidget, MultipleTextInputWidget
from filer.fields.image import FilerImageField, AdminImageFormField
from filer.settings import settings as filer_settings


class GlossaryField(object):
class GlossaryField:
"""
Deprecated.
Behave similar to django.forms.Field, encapsulating a partial dictionary, stored as
Expand Down
25 changes: 24 additions & 1 deletion cmsplugin_cascade/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from django.forms.formsets import DELETION_FIELD_NAME
from django.forms.models import ModelForm

class ManageChildrenFormMixin(object):
from entangled.forms import EntangledModelFormMixin, EntangledModelForm


class ManageChildrenFormMixin:
"""
Classes derived from ``CascadePluginBase`` can optionally add this mixin class to their form,
offering the input field ``num_children`` in their plugin editor. The content of this field is
Expand All @@ -15,3 +20,21 @@ def __init__(self, *args, **kwargs):
initial = {'num_children': instance.get_num_children()}
kwargs.update(initial=initial)
super().__init__(*args, **kwargs)


class CascadeModelFormMixin(EntangledModelFormMixin):
"""
Classes inheriting from InlineAdmin and defining their own `form` shall use this special
variant of an `EntangledModelForm`, otherwise deletion of inlined elements does not work.
"""
def _clean_form(self):
internal_fields = ['cascade_element', 'id', DELETION_FIELD_NAME]
internal_cleaned_data = {key: val for key, val in self.cleaned_data.items() if key in internal_fields}
super()._clean_form()
self.cleaned_data.update(internal_cleaned_data)


class CascadeModelForm(CascadeModelFormMixin, ModelForm):
"""
A convenience class to create a ModelForms to be used with djangocms-cascade
"""
5 changes: 3 additions & 2 deletions cmsplugin_cascade/generic/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.forms.fields import CharField
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _

from entangled.forms import EntangledModelFormMixin
from cmsplugin_cascade import app_settings
from cmsplugin_cascade.models import CascadePage
Expand Down Expand Up @@ -41,7 +42,7 @@ def check_unique_element_id(cls, instance, element_id):
raise ValidationError(msg.format(element_id))


class SectionModelMixin(object):
class SectionModelMixin:
def element_id(self):
id_attr = self.glossary.get('element_id')
if id_attr:
Expand All @@ -57,7 +58,7 @@ def delete(self, *args, **kwargs):
super().delete(*args, **kwargs)


class SectionMixin(object):
class SectionMixin:
def get_form(self, request, obj=None, **kwargs):
form = kwargs.get('form', self.form)
assert issubclass(form, EntangledModelFormMixin), "Form must inherit from EntangledModelFormMixin"
Expand Down
4 changes: 2 additions & 2 deletions cmsplugin_cascade/generic/text_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class TextImagePlugin(LinkPluginBase):
allow_children = False
require_parent = False
form = type('TextImageForm', (LinkFormMixin, TextImageFormMixin), {'require_link': False})
html_tag_attributes = {'image_title': 'title', 'alt_tag': 'tag'}
html_tag_attributes.update(LinkPluginBase.html_tag_attributes)
html_tag_attributes = LinkPluginBase.html_tag_attributes
html_tag_attributes.update({'image_title': 'title', 'alt_tag': 'alt'})

class Media:
js = ['admin/js/jquery.init.js', 'cascade/js/admin/textimageplugin.js']
Expand Down
3 changes: 2 additions & 1 deletion cmsplugin_cascade/hide_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.forms.fields import BooleanField
from django.utils.translation import gettext_lazy as _
from django.template import engines

from entangled.forms import EntangledModelFormMixin


Expand All @@ -16,7 +17,7 @@ class Meta:
entangled_fields = {'glossary': ['hide_plugin']}


class HidePluginMixin(object):
class HidePluginMixin:
"""
This mixin class adds a checkbox to each named plugin, which if checked hides that
plugin during the rendering phase.
Expand Down
2 changes: 1 addition & 1 deletion cmsplugin_cascade/icon/plugin_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.utils.safestring import mark_safe
from cmsplugin_cascade.models import IconFont
from cmsplugin_cascade.plugin_base import CascadePluginMixinBase
from entangled.forms import get_related_object
from entangled.utils import get_related_object


class IconPluginMixin(CascadePluginMixinBase):
Expand Down
3 changes: 2 additions & 1 deletion cmsplugin_cascade/image.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.forms.fields import CharField
from django.utils.translation import gettext_lazy as _

from entangled.forms import EntangledModelFormMixin, EntangledField, get_related_object
from entangled.forms import EntangledModelFormMixin, EntangledField
from entangled.utils import get_related_object
from cmsplugin_cascade.fields import CascadeImageField


Expand Down
8 changes: 4 additions & 4 deletions cmsplugin_cascade/leaflet/map.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import json

from django.forms.fields import CharField, BooleanField
from django.forms import widgets
from django.forms.fields import CharField, BooleanField
from django.db.models.fields.related import ManyToOneRel
from django.contrib.admin import StackedInline
from django.core.exceptions import ValidationError
from django.utils.html import strip_tags, strip_spaces_between_tags
from django.utils.safestring import mark_safe
from django.utils.translation import ngettext_lazy, gettext_lazy as _
from entangled.forms import EntangledModelFormMixin, EntangledModelForm
from filer.fields.image import FilerImageField, AdminImageFormField
from filer.settings import settings as filer_settings
from filer.utils.loader import load_model
Expand All @@ -17,6 +16,7 @@

from cmsplugin_cascade import app_settings
from cmsplugin_cascade.fields import HiddenDictField, SizeField, MultiSizeField
from cmsplugin_cascade.forms import CascadeModelForm, CascadeModelFormMixin
from cmsplugin_cascade.image import ImagePropertyMixin
from cmsplugin_cascade.mixins import WithInlineElementsMixin
from cmsplugin_cascade.models import InlineCascadeElement
Expand All @@ -32,7 +32,7 @@ def data(self):
return mark_safe(json.dumps(self.glossary))


class MarkerForm(EntangledModelForm):
class MarkerForm(CascadeModelForm):
title = CharField(
label=_("Marker Title"),
widget=widgets.TextInput(attrs={'size': 60}),
Expand Down Expand Up @@ -111,7 +111,7 @@ class MarkerInline(StackedInline):
extra = 0


class LeafletFormMixin(EntangledModelFormMixin):
class LeafletFormMixin(CascadeModelFormMixin):
map_width = SizeField(
label=_("Map Width"),
allowed_units=['px', '%'],
Expand Down
4 changes: 3 additions & 1 deletion cmsplugin_cascade/leaflet/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ def set_defaults(config):
config.setdefault('leaflet', {})
config['leaflet'].setdefault('tilesURL', 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'),
config['leaflet'].setdefault('default_position', {'lat': 30.0, 'lng': -40.0, 'zoom': 3})
config['leaflet'].setdefault('id', 'mapbox.streets'),
config['leaflet'].setdefault('id', 'mapbox/streets-v11'),
config['leaflet'].setdefault('maxZoom', 18),
config['leaflet'].setdefault('tileSize', 512)
config['leaflet'].setdefault('zoomOffset', -1)
config['leaflet'].setdefault('detectRetina', True)
config['leaflet'].setdefault('attribution', mark_safe('Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a>')),
Loading