apis-datamodel 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. apis_datamodel-0.1.0/.github/workflows/publish.yml +51 -0
  2. apis_datamodel-0.1.0/.gitignore +218 -0
  3. apis_datamodel-0.1.0/PKG-INFO +106 -0
  4. apis_datamodel-0.1.0/README.md +89 -0
  5. apis_datamodel-0.1.0/apis_datamodel/__init__.py +0 -0
  6. apis_datamodel-0.1.0/apis_datamodel/apps.py +9 -0
  7. apis_datamodel-0.1.0/apis_datamodel/checks.py +94 -0
  8. apis_datamodel-0.1.0/apis_datamodel/templates/apis_datamodel/base.html +7 -0
  9. apis_datamodel-0.1.0/apis_datamodel/templates/apis_datamodel/datamodel.html +42 -0
  10. apis_datamodel-0.1.0/apis_datamodel/urls.py +7 -0
  11. apis_datamodel-0.1.0/apis_datamodel/views.py +83 -0
  12. apis_datamodel-0.1.0/manage.py +16 -0
  13. apis_datamodel-0.1.0/pyproject.toml +31 -0
  14. apis_datamodel-0.1.0/sample_project/__init__.py +0 -0
  15. apis_datamodel-0.1.0/sample_project/admin.py +11 -0
  16. apis_datamodel-0.1.0/sample_project/apps.py +6 -0
  17. apis_datamodel-0.1.0/sample_project/management/__init__.py +0 -0
  18. apis_datamodel-0.1.0/sample_project/management/commands/__init__.py +0 -0
  19. apis_datamodel-0.1.0/sample_project/management/commands/populate_sample_data.py +151 -0
  20. apis_datamodel-0.1.0/sample_project/migrations/0001_initial.py +306 -0
  21. apis_datamodel-0.1.0/sample_project/migrations/__init__.py +0 -0
  22. apis_datamodel-0.1.0/sample_project/models.py +85 -0
  23. apis_datamodel-0.1.0/sample_project/settings.py +62 -0
  24. apis_datamodel-0.1.0/sample_project/static/css/pico.min.css +4 -0
  25. apis_datamodel-0.1.0/sample_project/templates/apis_datamodel/base.html +7 -0
  26. apis_datamodel-0.1.0/sample_project/templates/base.html +31 -0
  27. apis_datamodel-0.1.0/sample_project/urls.py +9 -0
  28. apis_datamodel-0.1.0/sample_project/views.py +5 -0
  29. apis_datamodel-0.1.0/uv.lock +534 -0
@@ -0,0 +1,51 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push
5
+
6
+ jobs:
7
+ build:
8
+ name: Build distribution 📦
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ with:
13
+ persist-credentials: false
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.x"
18
+ - name: Install pypa/build
19
+ run: >-
20
+ python3 -m
21
+ pip install
22
+ build
23
+ --user
24
+ - name: Build a binary wheel and a source tarball
25
+ run: python3 -m build
26
+ - name: Store the distribution packages
27
+ uses: actions/upload-artifact@v4
28
+ with:
29
+ name: python-package-distributions
30
+ path: dist/
31
+
32
+ publish-to-pypi:
33
+ name: >-
34
+ Publish Python 🐍 distribution 📦 to PyPI
35
+ if: startsWith(github.ref, 'refs/tags/')
36
+ needs:
37
+ - build
38
+ runs-on: ubuntu-latest
39
+ environment:
40
+ name: pypi
41
+ url: https://pypi.org/p/apis-datamodel/
42
+ permissions:
43
+ id-token: write
44
+ steps:
45
+ - name: Download all the dists
46
+ uses: actions/download-artifact@v4
47
+ with:
48
+ name: python-package-distributions
49
+ path: dist/
50
+ - name: Publish distribution 📦 to PyPI
51
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.4
2
+ Name: apis-datamodel
3
+ Version: 0.1.0
4
+ Summary: Datamodel showing entities and relationships
5
+ Project-URL: Homepage, https://github.com/gythaogg/apis-datamodel
6
+ Author: Saranya Balasubramanian
7
+ License: MIT
8
+ Keywords: datamodel,entities,relationships
9
+ Classifier: Framework :: Django
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.13
14
+ Requires-Dist: apis-core-rdf>=0.62.0
15
+ Provides-Extra: dev
16
+ Description-Content-Type: text/markdown
17
+
18
+ # apis-datamodel
19
+
20
+ A reusable Django app that introspects your [APIS Core](https://github.com/acdh-oeaw/apis-core-rdf) data model and displays a matrix of relations between entity types.
21
+
22
+ ## Features
23
+
24
+ - Automatically discovers all `Relation` subclasses defined in your project
25
+ - Renders a subject × object matrix where each cell shows the `name` and `reverse_name` of the relation
26
+ - Overridable templates via Django's standard app template loading order
27
+ - Django system checks to catch missing dependencies and misconfigured `INSTALLED_APPS` / URL includes early
28
+
29
+ ## Requirements
30
+
31
+ - Python ≥ 3.13
32
+ - Django (any version supported by `apis-core-rdf`)
33
+ - `apis-core-rdf >= 0.62.0`
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install apis-datamodel
39
+ ```
40
+
41
+ ## Setup
42
+
43
+ ### 1. Add to `INSTALLED_APPS`
44
+
45
+ `apis_datamodel` must appear **after** your project app so project-level template overrides are discovered first:
46
+
47
+ ```python
48
+ INSTALLED_APPS = [
49
+ ...
50
+ "apis_core.apis_metainfo",
51
+ "apis_core.relations",
52
+ "apis_core.apis_entities",
53
+ "your_project", # must come before apis_datamodel
54
+ "apis_datamodel",
55
+ ]
56
+ ```
57
+
58
+ ### 2. Include the URLs
59
+
60
+ ```python
61
+ # urls.py
62
+ from django.urls import include, path
63
+
64
+ urlpatterns = [
65
+ ...
66
+ path("datamodel/", include("apis_datamodel.urls")),
67
+ ]
68
+ ```
69
+
70
+ The matrix view is then available at `/datamodel/`.
71
+
72
+ ## Template customisation
73
+
74
+ The package ships with two templates:
75
+
76
+ | Template | Purpose |
77
+ |---|---|
78
+ | `apis_datamodel/base.html` | Wrapper — provides `dm_head` and `dm_content` blocks |
79
+ | `apis_datamodel/datamodel.html` | Renders the relation matrix |
80
+
81
+ To customise the layout, place a file at the same path inside your own app's `templates/` directory. Because your app is listed before `apis_datamodel` in `INSTALLED_APPS`, Django will pick yours up first.
82
+
83
+ The package template for `datamodel.html` extends `apis_datamodel/base.html` by default, but you can point it at your own base template by passing a `parent_template` context variable:
84
+
85
+ ```python
86
+ # e.g. in a subclassed view
87
+ def get_context_data(self, **kwargs):
88
+ ctx = super().get_context_data(**kwargs)
89
+ ctx["parent_template"] = "base.html"
90
+ return ctx
91
+ ```
92
+
93
+ ## System checks
94
+
95
+ The app registers three Django system checks that run with `manage.py check`:
96
+
97
+ | ID | What it validates |
98
+ |---|---|
99
+ | `apis_datamodel.E001` | Required APIS Core apps are present in `INSTALLED_APPS` |
100
+ | `apis_datamodel.E002` | `apis_datamodel.urls` is included in the root URLconf |
101
+ | `apis_datamodel.E003` | `apis_datamodel` appears after the host project app in `INSTALLED_APPS` |
102
+
103
+ ## License
104
+
105
+ MIT
106
+
@@ -0,0 +1,89 @@
1
+ # apis-datamodel
2
+
3
+ A reusable Django app that introspects your [APIS Core](https://github.com/acdh-oeaw/apis-core-rdf) data model and displays a matrix of relations between entity types.
4
+
5
+ ## Features
6
+
7
+ - Automatically discovers all `Relation` subclasses defined in your project
8
+ - Renders a subject × object matrix where each cell shows the `name` and `reverse_name` of the relation
9
+ - Overridable templates via Django's standard app template loading order
10
+ - Django system checks to catch missing dependencies and misconfigured `INSTALLED_APPS` / URL includes early
11
+
12
+ ## Requirements
13
+
14
+ - Python ≥ 3.13
15
+ - Django (any version supported by `apis-core-rdf`)
16
+ - `apis-core-rdf >= 0.62.0`
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install apis-datamodel
22
+ ```
23
+
24
+ ## Setup
25
+
26
+ ### 1. Add to `INSTALLED_APPS`
27
+
28
+ `apis_datamodel` must appear **after** your project app so project-level template overrides are discovered first:
29
+
30
+ ```python
31
+ INSTALLED_APPS = [
32
+ ...
33
+ "apis_core.apis_metainfo",
34
+ "apis_core.relations",
35
+ "apis_core.apis_entities",
36
+ "your_project", # must come before apis_datamodel
37
+ "apis_datamodel",
38
+ ]
39
+ ```
40
+
41
+ ### 2. Include the URLs
42
+
43
+ ```python
44
+ # urls.py
45
+ from django.urls import include, path
46
+
47
+ urlpatterns = [
48
+ ...
49
+ path("datamodel/", include("apis_datamodel.urls")),
50
+ ]
51
+ ```
52
+
53
+ The matrix view is then available at `/datamodel/`.
54
+
55
+ ## Template customisation
56
+
57
+ The package ships with two templates:
58
+
59
+ | Template | Purpose |
60
+ |---|---|
61
+ | `apis_datamodel/base.html` | Wrapper — provides `dm_head` and `dm_content` blocks |
62
+ | `apis_datamodel/datamodel.html` | Renders the relation matrix |
63
+
64
+ To customise the layout, place a file at the same path inside your own app's `templates/` directory. Because your app is listed before `apis_datamodel` in `INSTALLED_APPS`, Django will pick yours up first.
65
+
66
+ The package template for `datamodel.html` extends `apis_datamodel/base.html` by default, but you can point it at your own base template by passing a `parent_template` context variable:
67
+
68
+ ```python
69
+ # e.g. in a subclassed view
70
+ def get_context_data(self, **kwargs):
71
+ ctx = super().get_context_data(**kwargs)
72
+ ctx["parent_template"] = "base.html"
73
+ return ctx
74
+ ```
75
+
76
+ ## System checks
77
+
78
+ The app registers three Django system checks that run with `manage.py check`:
79
+
80
+ | ID | What it validates |
81
+ |---|---|
82
+ | `apis_datamodel.E001` | Required APIS Core apps are present in `INSTALLED_APPS` |
83
+ | `apis_datamodel.E002` | `apis_datamodel.urls` is included in the root URLconf |
84
+ | `apis_datamodel.E003` | `apis_datamodel` appears after the host project app in `INSTALLED_APPS` |
85
+
86
+ ## License
87
+
88
+ MIT
89
+
File without changes
@@ -0,0 +1,9 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class ApisDatamodelConfig(AppConfig):
5
+ name = "apis_datamodel"
6
+
7
+ def ready(self) -> None:
8
+ # Import checks at startup so Django registers system checks.
9
+ from . import checks # noqa: F401
@@ -0,0 +1,94 @@
1
+ from django.apps import apps
2
+ from django.conf import settings
3
+ from django.core.checks import Error, register
4
+ from django.urls import URLResolver, get_resolver
5
+
6
+ REQUIRED_APPS = (
7
+ "apis_core.apis_metainfo",
8
+ "apis_core.relations",
9
+ "apis_core.apis_entities",
10
+ )
11
+ REQUIRED_URLCONF = "apis_datamodel.urls"
12
+
13
+
14
+ @register()
15
+ def check_required_apis_core_apps(app_configs, **kwargs):
16
+ missing = [app_name for app_name in REQUIRED_APPS if not apps.is_installed(app_name)]
17
+ if not missing:
18
+ return []
19
+
20
+ return [
21
+ Error(
22
+ "Missing required APIS Core apps.",
23
+ hint=(
24
+ "Add the following apps to INSTALLED_APPS: "
25
+ + ", ".join(f'\"{app_name}\"' for app_name in missing)
26
+ ),
27
+ id="apis_datamodel.E001",
28
+ )
29
+ ]
30
+
31
+
32
+ def _resolver_includes_urlconf(url_resolver: URLResolver, required_urlconf: str) -> bool:
33
+ current = getattr(url_resolver, "urlconf_name", None)
34
+ if isinstance(current, str) and current == required_urlconf:
35
+ return True
36
+
37
+ module_name = getattr(current, "__name__", None)
38
+ if module_name == required_urlconf:
39
+ return True
40
+
41
+ for pattern in getattr(url_resolver, "url_patterns", []):
42
+ if isinstance(pattern, URLResolver) and _resolver_includes_urlconf(pattern, required_urlconf):
43
+ return True
44
+ return False
45
+
46
+
47
+ @register()
48
+ def check_required_apis_datamodel_urls(app_configs, **kwargs):
49
+ if not apps.is_installed("apis_datamodel"):
50
+ return []
51
+
52
+ resolver = get_resolver(settings.ROOT_URLCONF)
53
+ if _resolver_includes_urlconf(resolver, REQUIRED_URLCONF):
54
+ return []
55
+
56
+ return [
57
+ Error(
58
+ "Missing required APIS datamodel URL include.",
59
+ hint=(
60
+ "Include the app urls in your root urlpatterns, for example: "
61
+ "path('datamodel/', include('apis_datamodel.urls'))"
62
+ ),
63
+ id="apis_datamodel.E002",
64
+ )
65
+ ]
66
+
67
+
68
+ @register()
69
+ def check_apis_datamodel_app_order(app_configs, **kwargs):
70
+ installed_apps = list(getattr(settings, "INSTALLED_APPS", []))
71
+ if "apis_datamodel" not in installed_apps:
72
+ return []
73
+
74
+ project_app = settings.ROOT_URLCONF.split(".", 1)[0]
75
+ if project_app not in installed_apps:
76
+ return []
77
+
78
+ apis_datamodel_index = installed_apps.index("apis_datamodel")
79
+ project_app_index = installed_apps.index(project_app)
80
+
81
+ if apis_datamodel_index > project_app_index:
82
+ return []
83
+
84
+ return [
85
+ Error(
86
+ "apis_datamodel must appear after the host project app in INSTALLED_APPS.",
87
+ hint=(
88
+ "Move 'apis_datamodel' below '"
89
+ f"{project_app}' in INSTALLED_APPS so project templates can override "
90
+ "apis_datamodel templates."
91
+ ),
92
+ id="apis_datamodel.E003",
93
+ )
94
+ ]
@@ -0,0 +1,7 @@
1
+ {% load static %}
2
+
3
+ {% block dm_head %}
4
+ {% endblock dm_head %}
5
+
6
+ {% block dm_content %}
7
+ {% endblock dm_content %}
@@ -0,0 +1,42 @@
1
+ {% extends parent_template|default:"apis_datamodel/base.html" %}
2
+
3
+ {% block title %}Relation Matrix{% endblock %}
4
+
5
+ {% block dm_head %}
6
+
7
+ {% endblock dm_head %}
8
+
9
+ {% block dm_content %}
10
+ <h1>Relation Matrix</h1>
11
+
12
+ <figure>
13
+ <table>
14
+ <thead>
15
+ <tr>
16
+ <th scope="col">Subject \ Object</th>
17
+ {% for model_name in column_models %}
18
+ <th scope="col">{{ model_name }}</th>
19
+ {% endfor %}
20
+ </tr>
21
+ </thead>
22
+ <tbody>
23
+ {% for row in rows %}
24
+ <tr>
25
+ <th scope="row">{{ row.subj_model }}</th>
26
+ {% for cell in row.cells %}
27
+ <td>
28
+ {% if cell.labels %}
29
+ {% for label in cell.labels %}
30
+ <div>{{ label }}</div>
31
+ {% endfor %}
32
+ {% else %}
33
+ -
34
+ {% endif %}
35
+ </td>
36
+ {% endfor %}
37
+ </tr>
38
+ {% endfor %}
39
+ </tbody>
40
+ </table>
41
+ </figure>
42
+ {% endblock dm_content %}
@@ -0,0 +1,7 @@
1
+ from django.contrib import admin
2
+ from django.urls import include, path
3
+ from . import views
4
+ app_name = "apis_datamodel"
5
+ urlpatterns = [
6
+ path("", views.DatamodelView.as_view(), name="datamodel"),
7
+ ]