Skip to content

Commit

Permalink
port-feat: pre-commit config added from the v3 workstream (#117)
Browse files Browse the repository at this point in the history
Changes partially taken from this change: a56091c

Requires additional work when the django-cms 4.0 workstream is official, the version bump code has been ignored because it would generate official releases only: #116
  • Loading branch information
Aiky30 authored May 10, 2022
1 parent 59c22af commit c8562f0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
# Need to drop python 3.5 and 3.6 before we include python upgrade
# - repo: https://github.com/asottile/pyupgrade
# rev: v2.31.0
# hooks:
# - id: pyupgrade
# args: ["--py37-plus"]
#
# FIXME: Should be enabled for codebases that are minimum django 2.2+
# - repo: https://github.com/adamchainz/django-upgrade
# rev: '1.4.0'
# hooks:
# - id: django-upgrade
# args: [--target-version, "2.2"]

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8

- repo: https://github.com/asottile/yesqa
rev: v1.3.0
hooks:
- id: yesqa

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-merge-conflict
- id: mixed-line-ending

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog

Unreleased
==========
* port-feat: pre-commit config added from the v3 workstream
* fix: Added test coverage to admin preview view

4.0.0.dev4 (2022-02-03)
Expand Down
6 changes: 3 additions & 3 deletions djangocms_snippet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def preview_view(self, request, snippet_id=None, form_url='', extra_context=None
def get_urls(self):
info = self.model._meta.app_label, self.model._meta.model_name
return [
url(
url(
r"^(?P<snippet_id>\d+)/preview/$",
self.admin_site.admin_view(self.preview_view),
name="{}_{}_preview".format(*info),
),
] + super().get_urls()
),
] + super().get_urls()

def has_delete_permission(self, request, obj=None):
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from cms.test_utils.testcases import CMSTestCase
from cms.toolbar.utils import get_object_edit_url, get_object_structure_url

from djangocms_snippet.models import Snippet, SnippetGrouper
from djangocms_versioning.models import Version

from djangocms_snippet.models import Snippet, SnippetGrouper

from .utils.factories import SnippetWithVersionFactory


Expand Down
5 changes: 1 addition & 4 deletions tests/utils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
from cms.models import Placeholder

import factory
from factory.fuzzy import (
FuzzyInteger,
FuzzyText,
)
from djangocms_versioning.models import Version
from factory.fuzzy import FuzzyInteger, FuzzyText

from djangocms_snippet.models import Snippet, SnippetGrouper, SnippetPtr

Expand Down

0 comments on commit c8562f0

Please sign in to comment.