Fix deletion of configurations with location actions
When I try to delete a configuration with associated dynamic location begin actions from the frontend, I get an error:
{
"errors": [
{
"detail": "Deletion failed for the configuration.",
"source": "Delete object error: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)\n(psycopg2.errors.NotNullViolation) null value in column \"configuration_id\" violates not-null constraint\nDETAIL: Failing row contains (2021-09-30 08:48:25.894893, 2021-10-06 06:00:48.045985, 11, null, 2021-09-30 08:44:44.163, , 3, 213, 212, 214, 4326, MSL, , null, null).\n\n[SQL: UPDATE configuration_dynamic_location_begin_action SET updated_at=%(updated_at)s, configuration_id=%(configuration_id)s WHERE configuration_dynamic_location_begin_action.id = %(configuration_dynamic_location_begin_action_id)s]\n[parameters: {'updated_at': datetime.datetime(2021, 10, 6, 6, 0, 48, 45985), 'configuration_id': None, 'configuration_dynamic_location_begin_action_id': 11}]\n(Background on this error at: https://sqlalche.me/e/14/gkpj)",
"status": 409,
"title": "Conflict"
}
],
"jsonapi": {
"version": "1.0"
}
}
Regarding that we discussed that it should be possible to delete those for SMS admins, we need to fix it.
Acceptance criteria:
- one test to delete a configuration with each of the location actions (1 for static location begin action, one for dynamic location begin action, 1 for each of the end actions)
- all tests pass