Skip to content

Commit

Permalink
Fix overriding already existing admin apps & update for poetry 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrThearMan committed Sep 1, 2022
1 parent b01ed2b commit 0da90e3
Show file tree
Hide file tree
Showing 15 changed files with 632 additions and 100 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
paths:
- "docs/**"
- "mkdocs.yml"
- ".github/workflows/docs.yml"

env:
POETRY_VIRTUALENVS_IN_PROJECT: true
Expand All @@ -27,9 +28,9 @@ jobs:
python-version: "3.10"

- name: Set up poetry
uses: abatilo/[email protected].4
uses: abatilo/[email protected].6
with:
poetry-version: "1.1.13"
poetry-version: "1.2.0"

- name: Load cached venv
id: cache-venv
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
python-version: "3.10"

- name: Set up poetry
uses: abatilo/[email protected].4
uses: abatilo/[email protected].6
with:
poetry-version: "1.1.13"
poetry-version: "1.2.0"

- name: Load cached venv
id: cache
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- "**.py"
- "pyproject.toml"
- "poetry.lock"
- ".github/workflows/test.yml"

env:
POETRY_VIRTUALENVS_IN_PROJECT: true
Expand Down Expand Up @@ -39,9 +40,9 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Set up poetry
uses: abatilo/[email protected].4
uses: abatilo/[email protected].6
with:
poetry-version: "1.1.13"
poetry-version: "1.2.0"

- name: Load cached venv
id: cache-venv
Expand Down Expand Up @@ -79,9 +80,9 @@ jobs:
python-version: "3.10"

- name: Set up poetry
uses: abatilo/[email protected].4
uses: abatilo/[email protected].6
with:
poetry-version: "1.1.13"
poetry-version: "1.2.0"

- name: Load cached venv
id: cache-venv
Expand Down
25 changes: 19 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
repos:

- repo: https://github.com/hadialqattan/pycln
rev: v2.1.1
hooks:
- id: pycln
args: [
"--config=pyproject.toml",
]

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
Expand All @@ -21,7 +29,7 @@ repos:
]

- repo: https://github.com/ambv/black
rev: 22.6.0
rev: 22.8.0
hooks:
- id: black
args: [
Expand All @@ -38,11 +46,16 @@ repos:
"--extend-ignore=E203,E501"
]

- repo: https://github.com/pycqa/pylint
rev: v2.14.5
- repo: local
hooks:
- id: pylint
name: pylint
exclude: ^tests/
additional_dependencies:
- Django
- django-settings-holder
entry: env DJANGO_SETTINGS_MODULE=tests.django.settings poetry run pylint
language: system
types: [python]
args: [
"--score=n",
"--load-plugins=pylint_django",
"--django-settings-module=tests.django.settings",
]
33 changes: 21 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,28 @@ args = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
%:
@:

define helptext

Commands:

dev Serve manual testing server
docs Serve mkdocs for development.
translations Make and compile translations.
tests Run all tests with coverage.
test <name> Run all tests maching the given <name>
tox Run all tests with tox.
hook Install pre-commit hook.
pre-commit Run pre-commit hooks on all files.
pre-commit-update Update all pre-commit hooks to latest versions.
mypy Run mypy on all files.

Use quotes (" ") if command contains flags (-h / --help)
endef

export helptext

help:
@echo ""
@echo "Commands:"
@echo " dev Serve manual testing server"
@echo " docs Serve mkdocs for development."
@echo " translations Make and compile translations."
@echo " tests Run all tests with coverage."
@echo " test <name> Run all tests maching the given <name>"
@echo " tox Run all tests with tox."
@echo " hook Install pre-commit hook."
@echo " pre-commit Run pre-commit hooks on all files."
@echo " pre-commit-update Update pre-commit hookds."
@echo " mypy Run mypy on all files."
@echo "$$helptext"

dev:
@poetry run python manage.py runserver localhost:8000
Expand Down
10 changes: 9 additions & 1 deletion admin_data_views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ def get_data_admin_views() -> AppDict:
def get_app_list(self: admin.AdminSite, request: HttpRequest) -> List[AppDict]:
baseroute = admin_data_settings.NAME.lower().replace(" ", "-")
app_dict = self._build_app_dict(request) # pylint: disable=protected-access
app_dict[baseroute] = get_data_admin_views()

data_admin_views = get_data_admin_views()

# Extend models in an already existing app
if baseroute in app_dict:
app_dict[baseroute]["models"].extend(data_admin_views["models"]) # pragma: no cover
else:
app_dict[baseroute] = data_admin_views

# Sort the apps alphabetically.
app_list = sorted(app_dict.values(), key=lambda x: x["name"].lower())

Expand Down
Loading

0 comments on commit 0da90e3

Please sign in to comment.