mirror of
https://github.com/django-components/django-components.git
synced 2025-08-31 11:17:21 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
9578ef16cd
11 changed files with 102 additions and 81 deletions
4
.github/workflows/contributors.yml
vendored
4
.github/workflows/contributors.yml
vendored
|
@ -12,8 +12,6 @@ jobs:
|
|||
name: Add contributors to readme
|
||||
steps:
|
||||
- name: Contribute List
|
||||
uses: akhilmhdh/contributors-readme-action@v2.3.5
|
||||
with:
|
||||
is_protected: true
|
||||
uses: akhilmhdh/contributors-readme-action@v2.3.6
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
@ -4,7 +4,7 @@ on: [push, pull_request, workflow_dispatch]
|
|||
|
||||
jobs:
|
||||
run-tests:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
matrix:
|
||||
python-version:
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
repos:
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.10.1
|
||||
rev: 5.11.4
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.6.0
|
||||
rev: 22.12.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 4.0.1
|
||||
rev: 6.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
|
||||
|
|
14
README.md
14
README.md
|
@ -20,7 +20,7 @@ Read on to learn about the details!
|
|||
|
||||
# Release notes
|
||||
|
||||
*Version 0.22* starts autoimporting all files inside components subdirectores, to simplify setup. An existing project might start to get AlreadyRegistered-errors because of this. To solve this, either remove your custom loading of components, or set "autodiscovery": False in settings.COMPONENTS.
|
||||
*Version 0.22* starts autoimporting all files inside components subdirectores, to simplify setup. An existing project might start to get AlreadyRegistered-errors because of this. To solve this, either remove your custom loading of components, or set "autodiscover": False in settings.COMPONENTS.
|
||||
|
||||
*Version 0.17* renames `Component.context` and `Component.template` to `get_context_data` and `get_template_name`. The old methods still work, but emit a deprecation warning. This change was done to sync naming with Django's class based views, and make using django-components more familiar to Django users. `Component.context` and `Component.template` will be removed when version 1.0 is released.
|
||||
|
||||
|
@ -170,13 +170,21 @@ Read on to find out how to build your first component!
|
|||
<sub><b>Real-Gecko</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/mands">
|
||||
<img src="https://avatars.githubusercontent.com/u/1010043?v=4" width="100;" alt="mands"/>
|
||||
<br />
|
||||
<sub><b>Mandeep Gill</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/telenieko">
|
||||
<img src="https://avatars.githubusercontent.com/u/10505?v=4" width="100;" alt="telenieko"/>
|
||||
<br />
|
||||
<sub><b>Marc Fargas</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/spollard">
|
||||
<img src="https://avatars.githubusercontent.com/u/1459574?v=4" width="100;" alt="spollard"/>
|
||||
|
@ -396,7 +404,7 @@ If you specify all the component locations with the setting above and have a lot
|
|||
|
||||
```python
|
||||
COMPONENTS = {
|
||||
"autodiscovery": False,
|
||||
"autodiscover": False,
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class Component(metaclass=SimplifiedInterfaceMediaDefiningClass):
|
|||
self.instance_template = None
|
||||
self.slots = {}
|
||||
|
||||
def get_context_data(self):
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
return {}
|
||||
|
||||
def get_template_name(self, context=None):
|
||||
|
|
|
@ -3,3 +3,4 @@ tox
|
|||
pytest
|
||||
flake8
|
||||
isort
|
||||
pre-commit
|
|
@ -1,62 +1,74 @@
|
|||
#
|
||||
# This file is autogenerated by pip-compile
|
||||
# To update, run:
|
||||
# This file is autogenerated by pip-compile with Python 3.11
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile requirements-dev.in
|
||||
#
|
||||
appdirs==1.4.4
|
||||
# via virtualenv
|
||||
asgiref==3.5.0
|
||||
asgiref==3.6.0
|
||||
# via django
|
||||
attrs==20.3.0
|
||||
attrs==22.2.0
|
||||
# via pytest
|
||||
distlib==0.3.1
|
||||
cachetools==5.2.0
|
||||
# via tox
|
||||
cfgv==3.3.1
|
||||
# via pre-commit
|
||||
chardet==5.1.0
|
||||
# via tox
|
||||
colorama==0.4.6
|
||||
# via tox
|
||||
distlib==0.3.6
|
||||
# via virtualenv
|
||||
django==4.0.6
|
||||
django==4.1.5
|
||||
# via -r requirements-dev.in
|
||||
filelock==3.0.12
|
||||
filelock==3.8.2
|
||||
# via
|
||||
# tox
|
||||
# virtualenv
|
||||
flake8==4.0.1
|
||||
flake8==6.0.0
|
||||
# via -r requirements-dev.in
|
||||
identify==2.5.11
|
||||
# via pre-commit
|
||||
iniconfig==1.1.1
|
||||
# via pytest
|
||||
isort==5.10.1
|
||||
isort==5.11.4
|
||||
# via -r requirements-dev.in
|
||||
mccabe==0.6.1
|
||||
mccabe==0.7.0
|
||||
# via flake8
|
||||
packaging==20.9
|
||||
nodeenv==1.7.0
|
||||
# via pre-commit
|
||||
packaging==22.0
|
||||
# via
|
||||
# pyproject-api
|
||||
# pytest
|
||||
# tox
|
||||
pluggy==0.13.1
|
||||
# via
|
||||
# pytest
|
||||
# tox
|
||||
py==1.10.0
|
||||
# via
|
||||
# pytest
|
||||
# tox
|
||||
pycodestyle==2.8.0
|
||||
# via flake8
|
||||
pyflakes==2.4.0
|
||||
# via flake8
|
||||
pyparsing==2.4.7
|
||||
# via packaging
|
||||
pytest==7.1.2
|
||||
# via -r requirements-dev.in
|
||||
six==1.15.0
|
||||
platformdirs==2.6.0
|
||||
# via
|
||||
# tox
|
||||
# virtualenv
|
||||
sqlparse==0.4.2
|
||||
# via django
|
||||
toml==0.10.2
|
||||
# via tox
|
||||
tomli==2.0.0
|
||||
# via pytest
|
||||
tox==3.25.1
|
||||
pluggy==1.0.0
|
||||
# via
|
||||
# pytest
|
||||
# tox
|
||||
pre-commit==2.21.0
|
||||
# via -r requirements-dev.in
|
||||
virtualenv==20.4.3
|
||||
pycodestyle==2.10.0
|
||||
# via flake8
|
||||
pyflakes==3.0.1
|
||||
# via flake8
|
||||
pyproject-api==1.2.1
|
||||
# via tox
|
||||
pytest==7.2.0
|
||||
# via -r requirements-dev.in
|
||||
pyyaml==6.0
|
||||
# via pre-commit
|
||||
sqlparse==0.4.3
|
||||
# via django
|
||||
tox==4.1.1
|
||||
# via -r requirements-dev.in
|
||||
virtualenv==20.17.1
|
||||
# via
|
||||
# pre-commit
|
||||
# tox
|
||||
|
||||
# The following packages are considered to be unsafe in a requirements file:
|
||||
# setuptools
|
||||
|
|
2
setup.py
2
setup.py
|
@ -3,7 +3,7 @@ import os
|
|||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
VERSION = "0.22"
|
||||
VERSION = "0.23"
|
||||
|
||||
setup(
|
||||
name="django_components",
|
||||
|
|
|
@ -41,7 +41,7 @@ class ComponentTest(SimpleTestCase):
|
|||
comp.render_dependencies(),
|
||||
dedent(
|
||||
"""
|
||||
<link href="style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<link href="style.css" media="all" rel="stylesheet">
|
||||
<script src="script.js"></script>
|
||||
"""
|
||||
).strip(),
|
||||
|
@ -68,8 +68,8 @@ class ComponentTest(SimpleTestCase):
|
|||
comp.render_dependencies(),
|
||||
dedent(
|
||||
"""
|
||||
<link href="style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<link href="style2.css" type="text/css" media="all" rel="stylesheet">
|
||||
<link href="style.css" media="all" rel="stylesheet">
|
||||
<link href="style2.css" media="all" rel="stylesheet">
|
||||
<script src="script.js"></script>
|
||||
<script src="script2.js"></script>
|
||||
"""
|
||||
|
@ -143,7 +143,7 @@ class ComponentMediaTests(SimpleTestCase):
|
|||
comp.render_dependencies(),
|
||||
dedent(
|
||||
"""\
|
||||
<link href="path/to/style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<link href="path/to/style.css" media="all" rel="stylesheet">
|
||||
<script src="path/to/script.js"></script>
|
||||
"""
|
||||
),
|
||||
|
@ -160,8 +160,8 @@ class ComponentMediaTests(SimpleTestCase):
|
|||
comp.render_dependencies(),
|
||||
dedent(
|
||||
"""\
|
||||
<link href="path/to/style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<link href="path/to/style2.css" type="text/css" media="all" rel="stylesheet">
|
||||
<link href="path/to/style.css" media="all" rel="stylesheet">
|
||||
<link href="path/to/style2.css" media="all" rel="stylesheet">
|
||||
<script src="path/to/script.js"></script>
|
||||
"""
|
||||
),
|
||||
|
@ -182,9 +182,9 @@ class ComponentMediaTests(SimpleTestCase):
|
|||
comp.render_dependencies(),
|
||||
dedent(
|
||||
"""\
|
||||
<link href="path/to/style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<link href="path/to/style2.css" type="text/css" media="print" rel="stylesheet">
|
||||
<link href="path/to/style3.css" type="text/css" media="screen" rel="stylesheet">
|
||||
<link href="path/to/style.css" media="all" rel="stylesheet">
|
||||
<link href="path/to/style2.css" media="print" rel="stylesheet">
|
||||
<link href="path/to/style3.css" media="screen" rel="stylesheet">
|
||||
<script src="path/to/script.js"></script>
|
||||
"""
|
||||
),
|
||||
|
@ -201,7 +201,7 @@ class ComponentMediaTests(SimpleTestCase):
|
|||
comp.render_dependencies(),
|
||||
dedent(
|
||||
"""\
|
||||
<link href="path/to/style.css" type="text/css" media="all" rel="stylesheet">
|
||||
<link href="path/to/style.css" media="all" rel="stylesheet">
|
||||
<script src="path/to/script.js"></script>
|
||||
"""
|
||||
),
|
||||
|
|
|
@ -54,7 +54,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
rendered = create_and_process_template_response(template)
|
||||
self.assertInHTML('<script src="script.js">', rendered, count=0)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=0,
|
||||
)
|
||||
|
@ -76,7 +76,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
)
|
||||
rendered = create_and_process_template_response(template)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=0,
|
||||
)
|
||||
|
@ -90,7 +90,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
rendered = create_and_process_template_response(template)
|
||||
self.assertInHTML('<script src="script.js">', rendered, count=1)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
@ -112,7 +112,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
)
|
||||
rendered = create_and_process_template_response(template)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
@ -126,7 +126,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
)
|
||||
rendered = create_and_process_template_response(template)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
@ -141,7 +141,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
)
|
||||
rendered = create_and_process_template_response(template)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
@ -175,7 +175,7 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
)
|
||||
rendered = create_and_process_template_response(template)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
@ -201,12 +201,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
self.assertInHTML('<script src="script.js">', rendered, count=1)
|
||||
self.assertInHTML('<script src="script2.js">', rendered, count=1)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
self.assertInHTML(
|
||||
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style2.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
@ -222,12 +222,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
self.assertInHTML('<script src="script.js">', rendered, count=1)
|
||||
self.assertInHTML('<script src="script2.js">', rendered, count=1)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=0,
|
||||
)
|
||||
self.assertInHTML(
|
||||
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style2.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=0,
|
||||
)
|
||||
|
@ -243,12 +243,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
self.assertInHTML('<script src="script.js">', rendered, count=0)
|
||||
self.assertInHTML('<script src="script2.js">', rendered, count=0)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
self.assertInHTML(
|
||||
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style2.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
@ -266,12 +266,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
self.assertInHTML('<script src="script.js">', rendered, count=0)
|
||||
self.assertInHTML('<script src="script2.js">', rendered, count=0)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=0,
|
||||
)
|
||||
self.assertInHTML(
|
||||
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style2.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=0,
|
||||
)
|
||||
|
@ -288,12 +288,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
)
|
||||
rendered = create_and_process_template_response(template)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
self.assertInHTML(
|
||||
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style2.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=0,
|
||||
)
|
||||
|
@ -326,12 +326,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
self.assertInHTML('<script src="script.js">', rendered, count=0)
|
||||
self.assertInHTML('<script src="script2.js">', rendered, count=1)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=0,
|
||||
)
|
||||
self.assertInHTML(
|
||||
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style2.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
@ -354,12 +354,12 @@ class ComponentMediaRenderingTests(SimpleTestCase):
|
|||
self.assertInHTML('<script src="script.js">', rendered, count=1)
|
||||
self.assertInHTML('<script src="script2.js">', rendered, count=1)
|
||||
self.assertInHTML(
|
||||
'<link href="style.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
self.assertInHTML(
|
||||
'<link href="style2.css" type="text/css" media="all" rel="stylesheet"/>',
|
||||
'<link href="style2.css" media="all" rel="stylesheet"/>',
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
|
|
@ -16,12 +16,14 @@ middleware = ComponentDependencyMiddleware(
|
|||
class Django30CompatibleSimpleTestCase(SimpleTestCase):
|
||||
def assertHTMLEqual(self, left, right):
|
||||
left = left.replace(' type="text/javascript"', "")
|
||||
left = left.replace(' type="text/css"', "")
|
||||
super(Django30CompatibleSimpleTestCase, self).assertHTMLEqual(
|
||||
left, right
|
||||
)
|
||||
|
||||
def assertInHTML(self, needle, haystack, count=None, msg_prefix=""):
|
||||
haystack = haystack.replace(' type="text/javascript"', "")
|
||||
haystack = haystack.replace(' type="text/css"', "")
|
||||
super().assertInHTML(needle, haystack, count, msg_prefix)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue