Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port-feat: pre-commit config added from the v3 workstream #117

34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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"]

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.4.0'
hooks:
- id: django-upgrade
args: [--target-version, "2.2"]
Aiky30 marked this conversation as resolved.
Show resolved Hide resolved

- 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
@@ -1,12 +1,12 @@
from django.conf import settings
from django.conf.urls import url
from django.contrib import admin
from django.contrib.admin import helpers
from django.contrib.admin.exceptions import DisallowedModelAdminToField
from django.contrib.admin.options import IS_POPUP_VAR, TO_FIELD_VAR
from django.contrib.admin.utils import flatten_fieldsets, unquote
from django.db import models
from django.forms import Textarea
from django.urls import path
from django.utils.translation import gettext as _

from cms.utils.permissions import get_model_permission_codename
Expand Down Expand Up @@ -142,8 +142,8 @@ 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(
r"^(?P<snippet_id>\d+)/preview/$",
path(
'<int:snippet_id>/preview/',
self.admin_site.admin_view(self.preview_view),
name="{}_{}_preview".format(*info),
),
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