Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support making migrations #37

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,20 @@ To get started:
```bash
pre-commit install
```

## Making Migrations

As a standalone Django application this plugin provides models to extend the
Coldfront data model. A helper script is provided to generate migrations for
these models. To use it, run the following command:

```bash
python makemigrations.py
```

This is equivalent to running `python manage.py makemigrations` in a Django
project and all the same options are available. See options with:

```bash
python makemigrations.py --help
```
30 changes: 30 additions & 0 deletions makemigrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Minimal script to make migrations without a manage.py file."""

import sys

import django
from django.conf import settings

settings.configure(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.admin",
"django.contrib.contenttypes",
"django.contrib.sites",
"imperial_coldfront_plugin",
],
# below checks do not need to pass to makemigrations
SILENCED_SYSTEM_CHECKS=[
"admin.E403",
"admin.E406",
"admin.E408",
"admin.E409",
"admin.E410",
],
)
django.setup()

if __name__ == "__main__":
from django.core.management import call_command

call_command("makemigrations", *sys.argv[1:])
17 changes: 11 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
description = "A plugin for the Coldfront HPC management platform."
authors = [
{ name = "Christopher Cave-Ayland", email = "[email protected]" },
{ name = "Imperial College London RSE Team", email = "[email protected]" }
{ name = "Imperial College London RSE Team", email = "[email protected]" },
]
requires-python = "~=3.11"
dependencies = [
Expand Down Expand Up @@ -42,7 +42,9 @@ requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
exclude = ["htmlcov"] # Exclude the coverage report file from setuptools package finder
exclude = [
"htmlcov",
] # Exclude the coverage report file from setuptools package finder

[tool.mypy]
disallow_any_explicit = true
Expand All @@ -66,7 +68,7 @@ module = ["imperial_coldfront_plugin.oidc"]
disallow_any_explicit = false

[tool.pytest.ini_options]
addopts = "-v --mypy -p no:warnings --cov=imperial_coldfront_plugin --cov-report=html --doctest-modules --ignore=docs"
addopts = "-v --mypy -p no:warnings --cov=imperial_coldfront_plugin --cov-report=html --doctest-modules --ignore=docs --ignore=makemigrations.py"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to also ignore the migrations folder itself when we make one


[tool.ruff]
exclude = ["*/migrations"]
Expand All @@ -79,12 +81,15 @@ select = [
"F", # Pyflakes
"I", # isort
"UP", # pyupgrade
"RUF" # ruff
"RUF", # ruff
]
pydocstyle.convention = "google"

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["D100", "D104"] # Missing docstring in public module, Missing docstring in public package
"tests/*" = [
"D100",
"D104",
] # Missing docstring in public module, Missing docstring in public package

[tool.django-stubs]
django_settings_module = "imperial_coldfront_plugin" # a lie but seems to satisfy
django_settings_module = "imperial_coldfront_plugin" # a lie but seems to satisfy