Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/semver-5.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun authored Dec 12, 2023
2 parents 987e328 + 21288bc commit f7bbb7f
Show file tree
Hide file tree
Showing 58 changed files with 1,670 additions and 572 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-live-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
Expand Down
36 changes: 34 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ jobs:
- 3.9
- '3.10'
- '3.11'
- '3.12'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -49,7 +50,7 @@ jobs:
runs-on: ubuntu-20.04
needs: unit-tests
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
Expand All @@ -75,3 +76,34 @@ jobs:
with:
name: html-report
path: htmlcov

unit-tests-django-main:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.11']
requirements-file: [
'py311-djmain-cms41-default.txt',
'py311-djmain-cms41-versioning.txt',
]
os: [
ubuntu-20.04,
]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}

uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements/${{ matrix.requirements-file }}
python setup.py install
- name: Run coverage
run: coverage run setup.py test
continue-on-error: true
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ ci:

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.8.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.14.0'
rev: '1.15.0'
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
Expand Down
24 changes: 15 additions & 9 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
Changelog
=========

2.0.0rc1
========
* Django 4.0, 4.1, and 4.2 support added
* Django 2.2 support removed
* Python 3.7 support removed
* Changed test setup to run tox from github actions for consistency in testing
* Use django CMS 4.1 GrouperModelAdmin utility (breaking change wrt. django CMS 4.0)
* Admin menu entry show alias change list in the language of the currently shown object
* Automatically create static aliases in the language needed (fixing #162)
2.0.0rc3 (2023-12-12)
=====================
* fix: avoid generating migrations based on settings.LANGUAGE by @vasekch in https://github.com/django-cms/djangocms-alias/pull/186
* fix: Enable caching for `static_alias` template tag by @vasekch in https://github.com/django-cms/djangocms-alias/pull/200
* fix: `static_alias` unnecessarily creates new content objects when used with versioning by @fsbraun in https://github.com/django-cms/djangocms-alias/pull/202
* feat: Django 5.0 support, fixed test suite by @fsbraun in https://github.com/django-cms/djangocms-alias/pull/203
* fix: Migration dependency on latest django-cms migration.
* fix: Allow using a variable as the identifier in static_alias template tag
* fest: Django 4.0, 4.1, and 4.2 support added
* fest: Django 2.2 support removed
* fest: Python 3.7 support removed
* ci: Changed test setup to run tox from github actions for consistency in testing
* feat: Use django CMS 4.1 GrouperModelAdmin utility (breaking change wrt. django CMS 4.0)
* fix: Admin menu entry show alias change list in the language of the currently shown object
* fix: Automatically create static aliases in the language needed (fixing #162)

1.11.0 (2022-10-14)
===================
Expand Down
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Security Policy

## Reporting a Vulnerability

As ever, we remind our users and contributors that all security reports, patches and concerns be addressed only to our security team by email, at [email protected].
2 changes: 1 addition & 1 deletion djangocms_alias/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.0.0rc1'
__version__ = '2.0.0rc3'
22 changes: 12 additions & 10 deletions djangocms_alias/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,26 @@ def can_detach(cls, user, target_placeholder, plugins):

@classmethod
def detach_alias_plugin(cls, plugin, language):
source_placeholder = plugin.alias.get_placeholder(language)
source_placeholder = plugin.alias.get_placeholder(language, show_draft_content=True) # We're in edit mode
target_placeholder = plugin.placeholder
source_plugins = plugin.alias.get_plugins(language)

# Deleting uses a copy of a plugin to preserve pk on existing
# ``plugin`` object. This is done due to
# plugin.get_plugin_toolbar_info requiring a PK in a passed
# instance.
source_placeholder.delete_plugin(copy(plugin))
target_placeholder.delete_plugin(copy(plugin))
target_placeholder._shift_plugin_positions(
language,
plugin.position,
offset=target_placeholder.get_last_plugin_position(language),
)
copied_plugins = copy_plugins_to_placeholder(
source_plugins,
placeholder=target_placeholder,
language=language,
start_positions={language: plugin.position},
)
return copied_plugins
if source_placeholder:
source_plugins = source_placeholder.get_plugins_list()
copied_plugins = copy_plugins_to_placeholder(
source_plugins,
placeholder=target_placeholder,
language=language,
start_positions={language: plugin.position},
)
return copied_plugins
return []
28 changes: 28 additions & 0 deletions djangocms_alias/migrations/0003_auto_20230725_1547.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.1.8 on 2023-07-25 15:47

from django.db import migrations, models
import django.db.models.deletion

class Migration(migrations.Migration):

dependencies = [
('cms', '__first__'),
('djangocms_alias', '0002_auto_20200723_1424'),
]

operations = [
migrations.AlterField(
model_name='aliasplugin',
name='cmsplugin_ptr',
field=models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='%(app_label)s_%(class)s', serialize=False, to='cms.cmsplugin'),
),
migrations.AlterField(
model_name='categorytranslation',
name='name',
field=models.CharField(max_length=120, verbose_name='name'),
),
migrations.AlterUniqueTogether(
name='categorytranslation',
unique_together={('language_code', 'master'), ('name', 'language_code')},
),
]
19 changes: 19 additions & 0 deletions djangocms_alias/migrations/0004_alter_aliascontent_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.20 on 2023-07-26 13:43

from django.db import migrations, models
import django.utils.translation


class Migration(migrations.Migration):

dependencies = [
('djangocms_alias', '0003_auto_20230725_1547'),
]

operations = [
migrations.AlterField(
model_name='aliascontent',
name='language',
field=models.CharField(default=django.utils.translation.get_language, max_length=10),
),
]
7 changes: 5 additions & 2 deletions djangocms_alias/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class Category(TranslatableModel):
name=models.CharField(
verbose_name=_('name'),
max_length=120,
unique=True,
),
meta={'unique_together': [('name', 'language_code')]},
)

class Meta:
Expand Down Expand Up @@ -268,7 +268,6 @@ class AliasContent(models.Model):
placeholder_slotname = 'content'
language = models.CharField(
max_length=10,
choices=settings.LANGUAGES,
default=get_language,
)

Expand All @@ -278,6 +277,10 @@ class Meta:
verbose_name = _('alias content')
verbose_name_plural = _('alias contents')

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._meta.get_field('language').choices = settings.LANGUAGES

def __str__(self):
return f'{self.name} ({self.language})'

Expand Down
7 changes: 4 additions & 3 deletions djangocms_alias/templatetags/djangocms_alias_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class StaticAlias(Tag):
"""
name = 'static_alias'
options = PlaceholderOptions(
Argument('static_code', resolve=False),
Argument('static_code', resolve=True),
MultiValueArgument('extra_bits', required=False, resolve=False),
blocks=[
('endstatic_alias', 'nodelist'),
Expand Down Expand Up @@ -109,7 +109,7 @@ def _get_alias(self, request, static_code, extra_bits):
if is_versioning_enabled() and not request.user.is_authenticated:
return None

# Parlers get_or_create doesn't work well with translations, so we must perform our own get or create
# Parler's get_or_create doesn't work well with translations, so we must perform our own get or create
default_category = Category.objects.filter(translations__name=DEFAULT_STATIC_ALIAS_CATEGORY_NAME).first()
if not default_category:
default_category = Category.objects.create(name=DEFAULT_STATIC_ALIAS_CATEGORY_NAME)
Expand All @@ -124,7 +124,7 @@ def _get_alias(self, request, static_code, extra_bits):

alias = Alias.objects.create(category=default_category, **alias_creation_kwargs)

if not AliasContent._default_manager.filter(alias=alias, language=language).exists():
if not AliasContent._base_manager.filter(alias=alias, language=language).exists():
# Create a first content object if none exists in the given language.
# If versioning is enabled we can only create the records with a logged-in user / staff member
if is_versioning_enabled() and not request.user.is_authenticated:
Expand Down Expand Up @@ -176,6 +176,7 @@ def render_tag(self, context, static_code, extra_bits, nodelist=None):
placeholder=placeholder,
context=context,
nodelist=nodelist,
use_cache=True,
)
return content
return ''
Expand Down
Loading

0 comments on commit f7bbb7f

Please sign in to comment.