Skip to content

Commit

Permalink
fix: visualise data models (#30)
Browse files Browse the repository at this point in the history
* add foreign key id fields

* add permissions

* support checking admin teachers

* replace permissions

* remove unused requirements and fix test discovery

* fix unit tests

* add module docstrings

* pylint disable

* create unit tests

* call action

* use ocadotech org

* use sub dir

* in .github sub dir

* feedback

* fix pipeline

* graph django models

* remove test for now

* chore: entity relationship diagram [skip ci]

* test 2 pushes in a row

* test modifying model fields

* chore: entity relationship diagram [skip ci]

* remove middle name

* chore: entity relationship diagram [skip ci]

* add middle_name

* chore: entity relationship diagram [skip ci]

* remove middle name

* chore: entity relationship diagram [skip ci]

* use actions

* add pytest-xdist

---------

Co-authored-by: cfl-bot <[email protected]>
  • Loading branch information
SKairinos and cfl-bot authored Dec 18, 2023
1 parent c5c11c2 commit d449917
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 33 deletions.
37 changes: 11 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,26 @@ jobs:
matrix:
python-version: [3.8]
steps:
- name: 🛫 Checkout
uses: actions/checkout@v3

- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: ocadotechnology/codeforlife-workspace/.github/actions/python/test@main
with:
python-version: ${{ matrix.python-version }}

- name: 🛠 Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
pipenv install --dev
- name: 🔎 Check Code Format
run: if ! pipenv run black --check .; then exit 1; fi

- name: 🔎 Check Migrations
run: pipenv run python manage.py makemigrations --check --dry-run

# TODO: assert code coverage target.
- name: 🧪 Test Code Units
run: pipenv run pytest
docs:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: ocadotechnology/codeforlife-workspace/.github/actions/python/docs@main
with:
python-version: ${{ env.PYTHON_VERSION }}

release:
concurrency: release
runs-on: ubuntu-latest
needs: [test]
needs: [docs]
if: github.ref_name == 'main'
steps:
- name: 🛫 Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
Expand All @@ -67,10 +55,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install python-semantic-release~=7.33
- name: ⚙️ Configure Git
run: |
git config --local user.name cfl-bot
git config --local user.email [email protected]
- uses: ocadotechnology/codeforlife-workspace/.github/actions/git/setup-bot@main

- name: 🚀 Publish Semantic Release
env:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ pip-log.txt
pip-delete-this-directory.txt

# Any graphs generated in the docs
docs/*.png
# docs/*.png

# Any dot files generated by pydot
*.dot
# *.dot

# Unit test / coverage reports
htmlcov/
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"--load-plugins=pylint_django"
],
"python.testing.pytestArgs": [
"-n=auto",
"-c=pyproject.toml",
"."
],
Expand Down
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ django-stubs = {version = "==4.2.6", extras = ["compatible-mypy"]}
djangorestframework-stubs = {version = "==3.14.4", extras = ["compatible-mypy"]}
pylint = "==3.0.2"
pylint-django = "==2.5.5"
pygraphviz = "==1.11"
pytest-xdist = {version = "==3.5.0", extras = ["psutil"]}

[requires]
python_version = "3.8"
55 changes: 51 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions codeforlife/settings/third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@
],
"DEFAULT_PAGINATION_CLASS": "codeforlife.pagination.LimitOffsetPagination",
}

# Django Extensions - Graph Models
# https://django-extensions.readthedocs.io/en/latest/graph_models.html?highlight=graph_models#default-settings

GRAPH_MODELS = {
"all_applications": True,
"group_models": True,
"pygraphviz": True,
"output": "docs/entity_relationship_diagram.png",
"arrow_shape": "normal",
"color_code_deletions": True,
"rankdir": "BT",
}
2 changes: 1 addition & 1 deletion codeforlife/user/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.20 on 2023-12-15 17:11
# Generated by Django 3.2.20 on 2023-12-18 11:09

from django.conf import settings
import django.core.validators
Expand Down
Binary file added docs/entity_relationship_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"django.contrib.staticfiles",
"django.contrib.sites",
"codeforlife.user",
"django_extensions",
]

MIDDLEWARE = [
Expand Down

0 comments on commit d449917

Please sign in to comment.