- Published on
Release: test coverage, audit check, documentation, presto React18 support
- Authors
- Name
- Dave Coates
This release contains changes up until release/2022-06-14
.
To upgrade any existing projects it's recommended to pull in the relevant commits from upstream.
git remote add upstream git@gitlab.internal.alliancesoftware.com.au:alliance/template-django.git
git cherry-pick XXX1 XXX2
In cases where you are significantly behind it may be easier to pull the whole app (eg. common_audit
) in but you'll
need to review the relevant branch.
In this release
- Test coverage
- Audit field detect breaking AlterField
- Documentation restructure
- New FAQ
- Presto API documentation update
- Presto release - React18 / StrictMode support
- Other changes
Test coverage
Thanks to Vitaly the template project will now generate coverage reports.
See commit 3b1d3796.
Audit field detect breaking AlterField
The audit module relies on triggers to track changes to fields. If the type of a field is changed (eg. from CharField
to TextField
) then the trigger needs to be removed and recreated. There is now a system check to detect these cases. It
will output something like:
ERRORS:
migration: (common_audit.E005) Audited field `last_name` of model
`<class 'xenopus_frog_app.models.baseuser.User'>` got an AlterField inside `xenopus_frog_app.migrations.0002_lastname_textfield`.
You need to have a pair of DropOperation and InstallOperation around the AlterField.
eg: `trigger = AuditTriggers('xenopus_frog_app', 'user')` then in operations `trigger.DropOperation(),`
Then to resolve you need to update the migration like so:
# Generated by Django 3.2.13 on 2022-06-13 23:36
from django.db import migrations
from django.db import models
from common_audit.utils import AuditTriggers
trigger = AuditTriggers("xenopus_frog_app", "user")
class Migration(migrations.Migration):
dependencies = [
("xenopus_frog_app", "0001_initial"),
]
operations = [
trigger.DropOperation(),
migrations.AlterField(
model_name="user",
name="last_name",
field=models.TextField(),
),
migrations.AlterField(
model_name="userauditevent",
name="last_name",
field=models.TextField(),
),
trigger.InstallOperation(),
]
If you don't wish to re-install triggers immediately you can use trigger.NoInstallOperation
instead.
See commit 6b3a26d1.
Thanks to Fang for this one.
Documentation restructure
As shown previously the documentation has been restructured and enhanced. The easiest way to get these changes is to
copy the /doc/
directory.
See this MR for more details (there are many commits).
New FAQ
There's a new FAQ section for testing in the documentation.
Presto API documentation update
The Presto API documentation is now 10% complete
(this is 10% thoroughly reviewed and updated to include examples - in practice there's a lot more done but not yet reviewed)
Presto release - React18 / StrictMode support
Version 0.0.31 has been released with the major change being support for React StrictMode and React 18. Requires antd >= 0.20.
The major change here was in useAsync
which would previously stop working after a component was unmounted (to avoid
setState
after unmount). This is no longer required and has the added benefit that hot loading will now work fine
with useAsync
(previously it would stop working in some cases when hot-loading triggered).
Other changes
- Field now accepts
widgetProps
andformatterProps
to make it more convenient to pass through props to the relevant widget and formatter components.
class ExampleModel extends viewModelFactory(
{
id: new IntegerField(),
name: new CharField({
widgetProps: { placeholder: 'Enter you name' },
}),
activatedAt: new DateTimeField({
formatterProps: {
locales: ['en-AU'],
},
}),
},
{ pkFieldName: 'id' }
) {}
IntegerField
andFloatField
will now parse the incoming value into a number (eg. if model is constructed with a string value it will be converted to anumber
).DecimalField
used withDecimalWidget
will now set precision and store the value as a string to support high precision (it's no longer converted to a number at any point).All
NumberField
based widgets now respect theminValue
andmaxValue
optionsIntegerWidget
will not only accept integers
Other changes
- 97719103 Delete summary was previously deleted accidentally; this has been restored
- ec3d3ab3 AsyncFile resolving
upload_url
is now done at render time rather than startup to avoid import order issues - 2d9b490e Both django view
CrudFilterSet
and DRFFilterSet
now supportextra_kwargs
(previously didn't work for DRF) - d891c1c9 init-dev-virtualenv support m1 mac