kopia lustrzana https://github.com/rtts/django-simplecms
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
rodzic
924031f3ac
commit
74c896b86e
|
@ -1,7 +1,7 @@
|
||||||
repos:
|
repos:
|
||||||
|
|
||||||
- repo: https://github.com/rtts/djhtml
|
- repo: https://github.com/rtts/djhtml
|
||||||
rev: v1.4.9
|
rev: v1.4.11
|
||||||
hooks:
|
hooks:
|
||||||
- id: djhtml
|
- id: djhtml
|
||||||
|
|
||||||
|
@ -12,16 +12,17 @@ repos:
|
||||||
args: ['--in-place', '--remove-all-unused-imports']
|
args: ['--in-place', '--remove-all-unused-imports']
|
||||||
|
|
||||||
- repo: https://github.com/pycqa/isort
|
- repo: https://github.com/pycqa/isort
|
||||||
rev: 5.9.1
|
rev: 5.10.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
|
args: ['--resolve-all-configs', '--line-length', '88']
|
||||||
- repo: https://github.com/pycqa/flake8
|
|
||||||
rev: 3.9.2
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 21.6b0
|
rev: 21.12b0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
|
|
||||||
|
- repo: https://github.com/pycqa/flake8
|
||||||
|
rev: 4.0.1
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
|
16
README.md
16
README.md
|
@ -45,8 +45,8 @@ Here's an example `views.py` of an app using SimpleCMS:
|
||||||
And here is the contents of `hello.html`:
|
And here is the contents of `hello.html`:
|
||||||
|
|
||||||
<section type="helloworld">
|
<section type="helloworld">
|
||||||
<h1>{{message}}</h1>
|
<h1>{{ message }}</h1>
|
||||||
{{section.content}}
|
{{ section.content }}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
Everytime a section needs to be rendered, SimpleCMS will call the
|
Everytime a section needs to be rendered, SimpleCMS will call the
|
||||||
|
@ -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
|
and *Section* models, and all the other boilerplate code needed for
|
||||||
new projects.
|
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
|
## Feedback and support
|
||||||
|
|
||||||
We would love to hear from you! Feel free to [open an
|
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).
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
__version__ = "1.0.6"
|
__version__ = "1.0.7"
|
||||||
default_app_config = "cms.apps.CmsConfig"
|
default_app_config = "cms.apps.CmsConfig"
|
||||||
|
|
|
@ -36,11 +36,17 @@ def create_project(project_name, project_dir):
|
||||||
line = f"django-simplecms=={cms.__version__}"
|
line = f"django-simplecms=={cms.__version__}"
|
||||||
print(line, file=f)
|
print(line, file=f)
|
||||||
|
|
||||||
shutil.copytree(
|
example_dir = os.path.dirname(example.__file__)
|
||||||
os.path.dirname(example.__file__),
|
app_dir = os.path.join(project_dir, project_name)
|
||||||
os.path.join(project_dir, project_name),
|
shutil.copytree(example_dir, app_dir, dirs_exist_ok=True)
|
||||||
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(
|
with open(
|
||||||
os.open(
|
os.open(
|
||||||
os.path.join(project_dir, "manage.py"), os.O_CREAT | os.O_WRONLY, 0o755
|
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",
|
"w",
|
||||||
) as f:
|
) as f:
|
||||||
print(
|
print(
|
||||||
"#!/usr/bin/env python",
|
f"""#!/usr/bin/env python
|
||||||
"import os, sys",
|
import os
|
||||||
f"os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{project_name}.settings')",
|
import sys
|
||||||
"from django.core.management import execute_from_command_line",
|
|
||||||
"execute_from_command_line(sys.argv)",
|
from django.core.management import execute_from_command_line
|
||||||
sep="\n",
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{project_name}.settings")
|
||||||
|
execute_from_command_line(sys.argv)""",
|
||||||
file=f,
|
file=f,
|
||||||
)
|
)
|
||||||
with open(os.path.join(project_dir, project_name, "wsgi.py"), "w") as f:
|
with open(os.path.join(project_dir, project_name, "wsgi.py"), "w") as f:
|
||||||
print(
|
print(
|
||||||
"import os",
|
f"""import os
|
||||||
"from django.core.wsgi import get_wsgi_application",
|
|
||||||
f"os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{project_name}.settings')",
|
from django.core.wsgi import get_wsgi_application
|
||||||
"application = get_wsgi_application()",
|
|
||||||
sep="\n",
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{project_name}.settings")
|
||||||
|
application = get_wsgi_application()""",
|
||||||
file=f,
|
file=f,
|
||||||
)
|
)
|
||||||
with open(os.path.join(project_dir, ".gitignore"), "w") as f:
|
with open(os.path.join(project_dir, ".gitignore"), "w") as f:
|
||||||
print("*.pyc\n__pycache__/", file=f)
|
print("*.pyc\n__pycache__/", file=f)
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f'Successfully created project "{project_name}"',
|
f"""
|
||||||
"",
|
Successfully created project "{project_name}"
|
||||||
"Things to do next:",
|
|
||||||
"- create a database",
|
Things to do next:
|
||||||
"- ./manage.py makemigrations",
|
- create a database
|
||||||
"- ./manage.py migrate",
|
- ./manage.py makemigrations
|
||||||
"- ./manage.py createsuperuser",
|
- ./manage.py migrate
|
||||||
"- ./manage.py runserver",
|
- ./manage.py createsuperuser
|
||||||
sep="\n",
|
- ./manage.py runserver
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
[settings]
|
||||||
|
known_third_party=cms
|
|
@ -15,13 +15,14 @@ repos:
|
||||||
rev: main
|
rev: main
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
|
args: ['--line-length', '88']
|
||||||
- repo: https://github.com/pycqa/flake8
|
|
||||||
rev: master
|
|
||||||
hooks:
|
|
||||||
- id: flake8
|
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: main
|
rev: main
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
|
|
||||||
|
- repo: https://github.com/pycqa/flake8
|
||||||
|
rev: main
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
|
|
@ -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.decorators import page_model, section_model
|
||||||
from cms.models import BasePage, BaseSection
|
from cms.models import BasePage, BaseSection
|
||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
@page_model
|
@page_model
|
||||||
class Page(BasePage):
|
class Page(BasePage):
|
||||||
"""Add custom fields here. Already existing fields: title, slug,
|
pass
|
||||||
number, menu
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
@section_model
|
@section_model
|
||||||
class Section(BaseSection):
|
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)
|
page = models.ForeignKey(Page, related_name="sections", on_delete=models.PROTECT)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
|
|
||||||
from cms.decorators import section_view
|
from cms.decorators import section_view
|
||||||
from cms.forms import ContactForm
|
from cms.forms import ContactForm
|
||||||
from cms.views import SectionFormView, SectionView
|
from cms.views import SectionFormView, SectionView
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
@section_view
|
@section_view
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -34,6 +34,7 @@ setup(
|
||||||
"easy-thumbnails",
|
"easy-thumbnails",
|
||||||
"libsass",
|
"libsass",
|
||||||
"markdown",
|
"markdown",
|
||||||
|
"pre-commit",
|
||||||
"psycopg2",
|
"psycopg2",
|
||||||
"pylibmc",
|
"pylibmc",
|
||||||
],
|
],
|
||||||
|
|
Ładowanie…
Reference in New Issue