Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
FinalAngel committed Jan 16, 2024
1 parent f4e3201 commit b654881
Show file tree
Hide file tree
Showing 19 changed files with 331 additions and 80 deletions.
18 changes: 18 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[run]
branch = True
source = aldryn_django_cms
omit =
migrations/*
tests/*

[report]
exclude_lines =
pragma: no cover
def __repr__
if self.debug:
if settings.DEBUG
raise AssertionError
raise NotImplementedError
if 0:
if __name__ == .__main__.:
ignore_errors = True
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80

[*.py]
max_line_length = 120
quote_type = single

[*.{scss,js,html}]
max_line_length = 120
indent_style = space
quote_type = double

[*.js]
max_line_length = 120
quote_type = single

[*.rst]
max_line_length = 80

[*.yml]
indent_size = 2
61 changes: 61 additions & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Checks

on: [push]

jobs:
flake8:
name: flake8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install flake8
run: pip install --upgrade flake8
- name: Run flake8
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: flake8
run: flake8

isort:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- run: python -m pip install isort
- name: isort
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: isort
run: isort -c --df aldryn_django_cms

unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9"]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install packaging
pip install -r tests/requirements.txt
python setup.py install
- name: Run coverage
run: coverage run setup.py test
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1
33 changes: 27 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
/settings.json
.DS_STORE
*.pyc
aldryn_django_cms.egg-info
build
dist
*.py[cod]
*$py.class
*.egg-info
*.log
*.pot
.DS_Store
.coverage/
.eggs/
.idea/
.project/
.pydevproject/
.vscode/
.settings/
.tox/
__pycache__/
build/
dist/
env/

/~
/node_modules
.sass-cache
*.css.map
npm-debug.log
package-lock.json

local.sqlite
6 changes: 4 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
CHANGELOG
=========
Changelog
=========


4.0.1.14.dev2 (2022-07-15)
---------------------------
--------------------------

* Use 4.0.1.dev2 release of django CMS.

Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include LICENSE
include README.rst
recursive-exclude * *.py[co]
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ Once satisfied:
#. Notify the team via Slack.


.. |build| image:: https://travis-ci.org/divio/aldryn-django-cms.svg?branch=support/3.9.x
:target: https://travis-ci.org/divio/aldryn-django-cms
.. |coverage| image:: https://codecov.io/gh/divio/aldryn-django-cms/branch/support/3.9.x/graph/badge.svg
.. |build| image:: https://github.com/divio/aldryn-django-cms/actions/workflows/default.yml/badge.svg?branch=support/4.0.x
:target: https://github.com/divio/aldryn-django-cms/actions
.. |coverage| image:: https://codecov.io/gh/divio/aldryn-django-cms/branch/support/4.0.x/graph/badge.svg
:target: https://codecov.io/gh/divio/aldryn-django-cms

.. |python| image:: https://img.shields.io/badge/python-3.6%20%7C%C2%A03.7%20%7C%C2%A03.8%20%7C%C2%A03.9-blue.svg
.. |python| image:: https://img.shields.io/badge/python-3.8%20%7C%C2%A03.9%20%7C%C2%A03.10%20%7C%C2%A03.11-blue.svg
:target: https://pypi.org/project/aldryn-django-cms/
.. |django| image:: https://img.shields.io/badge/django-2.2%20%7C%203.1%20%7C%C2%A03.2-blue.svg
.. |django| image:: https://img.shields.io/badge/django-3.2%20%7C%203.1%20%7C%C2%A04.2-blue.svg
:target: https://www.djangoproject.com/
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.9-blue.svg
:target: https://www.django-cms.org/
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-4.0-blue.svg
:target: https://www.django-cms.org/
30 changes: 22 additions & 8 deletions aldryn_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
import json
import os

from aldryn_client import forms


SYSTEM_FIELD_WARNING = 'WARNING: this field is auto-written. Please do not change it here.'


Expand All @@ -27,7 +27,7 @@ class Form(forms.BaseForm):
'overridden if the project supplies a <a href='
'\'http://docs.django-cms.org/en/stable/reference/configuration.html#cms-templates\''
'target=\'_blank\'>CMS_TEMPLATES setting</a>. See <a href='
'\'http://support.divio.com/project-types/django-cms/manage-templates-in-your-django-cms-project-on-the-divio-cloud\' '
'\'http://support.divio.com/project-types/django-cms/manage-templates-in-your-django-cms-project-on-the-divio-cloud\' ' # noqa
'target=\'_blank\'>Manage templates in your django CMS project</a> for more information.'
),
)
Expand All @@ -49,8 +49,10 @@ class Form(forms.BaseForm):

def to_settings(self, data, settings):
from functools import partial

from django.urls import reverse_lazy
from aldryn_addons.utils import boolean_ish, djsenv

from aldryn_addons.utils import djsenv

env = partial(djsenv, settings=settings)

Expand Down Expand Up @@ -83,13 +85,19 @@ def to_settings(self, data, settings):
'cms.context_processors.cms_settings',
])

settings['MIDDLEWARE'].extend([
middlewares = [
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
])
settings['MIDDLEWARE'].insert(0, 'cms.middleware.utils.ApphookReloadMiddleware',)
]

if settings.get('MIDDLEWARE_CLASSES', None):
settings['MIDDLEWARE_CLASSES'].extend(middlewares)
settings['MIDDLEWARE_CLASSES'].insert(0, 'cms.middleware.utils.ApphookReloadMiddleware', )
else:
settings['MIDDLEWARE'].extend(middlewares)
settings['MIDDLEWARE'].insert(0, 'cms.middleware.utils.ApphookReloadMiddleware', )

settings['ADDON_URLS_I18N_LAST'] = 'cms.urls'

Expand All @@ -114,7 +122,7 @@ def to_settings(self, data, settings):
with open(old_cms_templates_json) as fobj:
templates = json.load(fobj)
else:
templates= settings.get('CMS_TEMPLATES', json.loads(data['cms_templates']))
templates = settings.get('CMS_TEMPLATES', json.loads(data['cms_templates']))

settings['CMS_TEMPLATES'] = templates

Expand Down Expand Up @@ -157,7 +165,6 @@ def to_settings(self, data, settings):

settings['PARLER_LANGUAGES'].update({'default': parler_defaults})

# aldryn_snake
TEMPLATE_CONTEXT_PROCESSORS = settings['TEMPLATES'][0]['OPTIONS']['context_processors']
TEMPLATE_CONTEXT_PROCESSORS.extend([
'aldryn_snake.template_api.template_processor',
Expand Down Expand Up @@ -198,6 +205,10 @@ def to_settings(self, data, settings):
# django-robots
settings['INSTALLED_APPS'].append('robots')

settings['MIGRATION_COMMANDS'].append(
'python manage.py cms fix-tree'
)

# default plugins
settings['INSTALLED_APPS'].extend([
# required by aldryn-forms
Expand All @@ -216,6 +227,9 @@ def to_settings(self, data, settings):
# stage sso enabled
# add internal endpoints that do not require authentication
settings['ALDRYN_SSO_LOGIN_WHITE_LIST'].append(reverse_lazy('cms-check-uninstall'))
# this is an internal django-cms url
# which gets called when a user logs out from toolbar
settings['ALDRYN_SSO_LOGIN_WHITE_LIST'].append(reverse_lazy('admin:cms_page_resolve'))

# Prevent injecting random comments to counter BREACH/CRIME attacks
# into the page tree snippets, as the javascript parsing the result
Expand Down
1 change: 0 additions & 1 deletion aldryn_django_cms/models.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
10 changes: 4 additions & 6 deletions aldryn_django_cms/urls.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# -*- coding: utf-8 -*-

from django.conf.urls import url, include
from django.contrib.sitemaps.views import sitemap
from django.urls import include, re_path

from cms.sitemaps import CMSSitemap

from .views import check_uninstall_ok


urlpatterns = [
url(r'^admin/~cmscloud-api/check-uninstall/$', check_uninstall_ok, name='cms-check-uninstall'),
url(r'^sitemap.xml$', sitemap, {'sitemaps': {'cmspages': CMSSitemap}}),
url(r'^robots\.txt', include('robots.urls')),
re_path(r'^admin/~cmscloud-api/check-uninstall/$', check_uninstall_ok, name='cms-check-uninstall'),
re_path(r'^sitemap.xml$', sitemap, {'sitemaps': {'cmspages': CMSSitemap}}),
re_path(r'^robots\.txt', include('robots.urls')),
]
8 changes: 3 additions & 5 deletions aldryn_django_cms/urls_i18n.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-

from django.conf.urls import url, include
from django.urls import include, re_path


urlpatterns = [
url(r'^api/~select2/', include('django_select2.urls')),
re_path(r'^api/~select2/', include('django_select2.urls')),

# required by aldryn-forms
url(r'^api/~captcha/', include('captcha.urls')),
re_path(r'^api/~captcha/', include('captcha.urls')),
]
9 changes: 1 addition & 8 deletions aldryn_django_cms/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-

import inspect

from importlib import import_module


Expand All @@ -15,11 +12,7 @@ def is_subclass(cls, base_class):

def get_classes_from_module(app, module_name, from_base_class=None):
module_path = '%s.%s' % (app, module_name)

try:
module_object = import_module(module_path)
except ImportError:
module_object = None
module_object = import_module(module_path)

if not module_object:
raise StopIteration
Expand Down
9 changes: 2 additions & 7 deletions aldryn_django_cms/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# -*- coding: utf-8 -*-

import json

from django.http import (
HttpResponse,
HttpResponseBadRequest
)
from django.http import HttpResponse, HttpResponseBadRequest

from cms.app_base import CMSApp
from cms.models import CMSPlugin, Page
Expand Down Expand Up @@ -72,7 +67,7 @@ def check_uninstall_ok(request):
# will be required in 3.5
new_cms_menu_classes = set(get_classes_from_module(app=app, module_name="cms_menus"))

for menu_class in (old_cms_menu_classes|new_cms_menu_classes):
for menu_class in (old_cms_menu_classes | new_cms_menu_classes):
menu = menu_class.__name__
# Only look at menus that are "cms_enabled"
cms_enabled = getattr(menu_class, 'cms_enabled', False)
Expand Down
27 changes: 27 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[flake8]
max-line-length = 119
exclude =
*.egg-info,
.eggs,
.git,
.settings,
.tox,
build,
data,
dist,
docs,
*migrations*,
requirements,
tmp

[isort]
line_length = 79
skip = manage.py, *migrations*, .tox, .eggs, data
include_trailing_comma = true
multi_line_output = 5
lines_after_imports = 2
default_section = THIRDPARTY
sections = FUTURE, STDLIB, DJANGO, CMS, THIRDPARTY, FIRSTPARTY, LOCALFOLDER
known_first_party = aldryn_django_cms
known_cms = cms, menus
known_django = django
Loading

0 comments on commit b654881

Please sign in to comment.