Skip to content
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
15 changes: 14 additions & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,17 @@ jobs:
run: pip install tox
- run: tox
env:
TOXENV: ruff
TOXENV: ruff

check-migrations:
name: Check for missing migrations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Install dependencies
run: pip install tox
- name: Check for missing migrations
run: tox -e check-migrations
41 changes: 39 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,45 @@ Changelog
=========


[0.4.1 (2025-12-03)]
====================
[Unreleased]
============

New features
------------

* Replaced dataclasses with pydantic models for better validation.

Bugfixes
--------

* Incorrect attributes where used in get_healthy() and get_objects()
(the bug was introduced in an earlier refactor in which these calls
were overlooked).
* Incorrect fields where used to check if API services are configured.

Maintenance and refactoring
---------------------------

* Added check for missing migrations in CI.
* Cleaned up utility function get_object_type_choices() which had unused
parameter and made a useless check for None as result of instantiating
ObjectsAPIService.
* Removed bump-my-version for version upgrades.
* Improved test coverage for model fields, API clients, and utils.
* Improved code quality:
- Added/corrected type hints.
- Replaced magic number for cache timeout with named constant.
- Replaced old '.format()' syntax with modern f-strings.
* Improved error-handling for API clients.
* Renamed 'ObjectsClientConfiguration' to 'ObjectsAPIServiceConfiguration'
as well as the fields for the ZGW client configurations. This is lesss
confusing and captures the intent of the code better.
* Added 'default_auto_field' to app config and 'DEFAULT_AUTO_FIELD' to
testapp settings to silence warnings.


0.4.1 (2025-12-03)
==================

* Added CI check to publishing workflow to ensure the changelog is ready for
release (must contain new version and release date)
Expand Down
18 changes: 17 additions & 1 deletion objectsapiclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
default_app_config = "objectsapiclient.apps.ObjectsAPIClientConfig"
from objectsapiclient.dataclasses import (
DataClassification,
Object,
ObjectRecord,
ObjectType,
ObjectTypeVersion,
UpdateFrequency,
)

__all__ = [
"DataClassification",
"UpdateFrequency",
"Object",
"ObjectRecord",
"ObjectType",
"ObjectTypeVersion",
]
29 changes: 16 additions & 13 deletions objectsapiclient/admin.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
from django.contrib import admin
from django.contrib.admin.templatetags.admin_list import _boolean_icon
from django.core.exceptions import ImproperlyConfigured
from django.utils.html import format_html
from django.utils.safestring import SafeString

from solo.admin import SingletonModelAdmin

from .client import Client
from .models import ObjectsClientConfiguration
from .models import ObjectsAPIServiceConfiguration
from .services import ObjectsAPIService


@admin.register(ObjectsClientConfiguration)
class ObjectsServiceConfigurationAdmin(SingletonModelAdmin):
@admin.register(ObjectsAPIServiceConfiguration)
class ObjectsAPIServiceConfigurationAdmin(SingletonModelAdmin):
fieldsets = (
(
None,
{
"fields": (
"objects_api_service_config",
"object_type_api_service_config",
"objects_api_client_config",
"objecttypes_api_client_config",
"status",
)
},
Expand All @@ -24,10 +27,10 @@ class ObjectsServiceConfigurationAdmin(SingletonModelAdmin):
readonly_fields = ("status",)

@admin.display
def status(self, obj):
from django.contrib.admin.templatetags.admin_list import _boolean_icon

client = Client()

healthy, message = client.is_healthy()
return format_html("{} {}", _boolean_icon(healthy), message)
def status(self, obj: ObjectsAPIServiceConfiguration) -> SafeString:
try:
service = ObjectsAPIService()
healthy, message = service.is_healthy()
return format_html("{} {}", _boolean_icon(healthy), message)
except ImproperlyConfigured as exc:
return format_html("{} {}", _boolean_icon(False), str(exc))
1 change: 1 addition & 0 deletions objectsapiclient/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

class ObjectsAPIClientConfig(AppConfig):
name = "objectsapiclient"
default_auto_field = "django.db.models.AutoField"
92 changes: 0 additions & 92 deletions objectsapiclient/client.py

This file was deleted.

Loading