Properly sort out pre-commit hook handling

What this means is that the source code of SimpleCMS now passes all the the
pre-commit hooks, and that the code generated by `simplecms` _also_ passes
all the pre-commit hooks.
main
Jaap Joris Vens 2022-01-29 12:56:45 +01:00
rodzic 924031f3ac
commit 74c896b86e
21 zmienionych plików z 340 dodań i 347 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
repos:
- repo: https://github.com/rtts/djhtml
rev: v1.4.9
rev: v1.4.11
hooks:
- id: djhtml
@ -12,16 +12,17 @@ repos:
args: ['--in-place', '--remove-all-unused-imports']
- repo: https://github.com/pycqa/isort
rev: 5.9.1
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
args: ['--resolve-all-configs', '--line-length', '88']
- repo: https://github.com/psf/black
rev: 21.6b0
rev: 21.12b0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8

Wyświetl plik

@ -72,17 +72,7 @@ SimpleCMS includes a variety of useful template tags, default *Page*
and *Section* models, and all the other boilerplate code needed for
new projects.
One notable inclusion is the `eval` template tag. It will pass its
argument first through Django's templating system and then through
Markdown, making for instance the following possible. (Disclaimer: use
with caution!)
Welcome to **{% now 'Y' %}!**
Another useful feature is the automatic compilation of `SCSS` files to
`CSS` files using a custom middleware.
## Feedback and support
We would love to hear from you! Feel free to [open an
issue](../../issues) or [send us an email](mailto:jj+cms@rtts.eu).
issue](../../issues) or [send us an email](mailto:cms@jj.rtts.eu).

Wyświetl plik

@ -1,2 +1,2 @@
__version__ = "1.0.6"
__version__ = "1.0.7"
default_app_config = "cms.apps.CmsConfig"

Wyświetl plik

@ -36,11 +36,17 @@ def create_project(project_name, project_dir):
line = f"django-simplecms=={cms.__version__}"
print(line, file=f)
shutil.copytree(
os.path.dirname(example.__file__),
os.path.join(project_dir, project_name),
dirs_exist_ok=True,
example_dir = os.path.dirname(example.__file__)
app_dir = os.path.join(project_dir, project_name)
shutil.copytree(example_dir, app_dir, dirs_exist_ok=True)
shutil.move(
os.path.join(app_dir, "setup.cfg"), os.path.join(project_dir, "setup.cfg")
)
shutil.move(
os.path.join(app_dir, ".pre-commit-config.yaml"),
os.path.join(project_dir, ".pre-commit-config.yaml"),
)
with open(
os.open(
os.path.join(project_dir, "manage.py"), os.O_CREAT | os.O_WRONLY, 0o755
@ -48,36 +54,40 @@ def create_project(project_name, project_dir):
"w",
) as f:
print(
"#!/usr/bin/env python",
"import os, sys",
f"os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{project_name}.settings')",
"from django.core.management import execute_from_command_line",
"execute_from_command_line(sys.argv)",
sep="\n",
f"""#!/usr/bin/env python
import os
import sys
from django.core.management import execute_from_command_line
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{project_name}.settings")
execute_from_command_line(sys.argv)""",
file=f,
)
with open(os.path.join(project_dir, project_name, "wsgi.py"), "w") as f:
print(
"import os",
"from django.core.wsgi import get_wsgi_application",
f"os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{project_name}.settings')",
"application = get_wsgi_application()",
sep="\n",
f"""import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{project_name}.settings")
application = get_wsgi_application()""",
file=f,
)
with open(os.path.join(project_dir, ".gitignore"), "w") as f:
print("*.pyc\n__pycache__/", file=f)
print(
f'Successfully created project "{project_name}"',
"",
"Things to do next:",
"- create a database",
"- ./manage.py makemigrations",
"- ./manage.py migrate",
"- ./manage.py createsuperuser",
"- ./manage.py runserver",
sep="\n",
f"""
Successfully created project "{project_name}"
Things to do next:
- create a database
- ./manage.py makemigrations
- ./manage.py migrate
- ./manage.py createsuperuser
- ./manage.py runserver
"""
)

Wyświetl plik

@ -1,3 +1 @@
from django.test import TestCase
# Create your tests here.

Wyświetl plik

@ -0,0 +1,2 @@
[settings]
known_third_party=cms

Wyświetl plik

@ -15,13 +15,14 @@ repos:
rev: main
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: master
hooks:
- id: flake8
args: ['--line-length', '88']
- repo: https://github.com/psf/black
rev: main
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: main
hooks:
- id: flake8

Wyświetl plik

@ -1,25 +1,16 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from cms.decorators import page_model, section_model
from cms.models import BasePage, BaseSection
from django.db import models
from django.utils.translation import gettext_lazy as _
@page_model
class Page(BasePage):
"""Add custom fields here. Already existing fields: title, slug,
number, menu
"""
pass
@section_model
class Section(BaseSection):
"""Add custom fields here. Already existing fields: title, type,
number, content, image, video, href
"""
page = models.ForeignKey(Page, related_name="sections", on_delete=models.PROTECT)

Wyświetl plik

@ -1,8 +1,7 @@
from django.utils.translation import gettext_lazy as _
from cms.decorators import section_view
from cms.forms import ContactForm
from cms.views import SectionFormView, SectionView
from django.utils.translation import gettext_lazy as _
@section_view

Wyświetl plik

@ -34,6 +34,7 @@ setup(
"easy-thumbnails",
"libsass",
"markdown",
"pre-commit",
"psycopg2",
"pylibmc",
],