Skip to content

chore: registration file upload - #4777

Merged
pbastia merged 11 commits into
developfrom
chore/2123-refactor-registration-file-uploads
Jul 23, 2026
Merged

chore: registration file upload#4777
pbastia merged 11 commits into
developfrom
chore/2123-refactor-registration-file-uploads

Conversation

@pbastia

@pbastia pbastia commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Work done

Backend

  • Refactored the registration endpoints containing data-url files to accept regular, "multipart/form-data" data containing both a JSON payload and file entries.
  • Updated existing ninja schemas and service calls, and deleted data-url transformation steps
  • GET endpoints now serve a serialized JSON structure to display the file name and the

Frontend

  • Updated schemas to only contain only string type for the file schema properties. For RJSF, any file upload will look like a string
  • Updated FileWidget, simplified code, and expose a hook to keep track of uploaded files until submission
  • FileWidget will set the value to a string containing a JSON-serialized render of the file name and scan status

See updated documentation

Work left to do:

@pbastia pbastia changed the title chore: structure with hook chore: registration file upload Jun 9, 2026
@pbastia
pbastia force-pushed the chore/2123-refactor-registration-file-uploads branch 3 times, most recently from 41f11a7 to f213d02 Compare June 23, 2026 17:25
@pbastia
pbastia force-pushed the chore/2123-refactor-registration-file-uploads branch 5 times, most recently from 6285214 to 48eb52f Compare July 2, 2026 21:11
@pbastia
pbastia marked this pull request as ready for review July 2, 2026 21:11
Copilot AI review requested due to automatic review settings July 2, 2026 21:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates registration-related file uploads from data-url-in-JSON payloads to multipart/form-data submissions, updating both the React (RJSF) widgets and the Django/Ninja endpoints, along with extensive test refactors.

Changes:

  • Frontend: reworks FileWidget/read-only rendering to store file metadata as a string value and submit actual Files via FormData through a new useFileUploadWidget context.
  • Backend: updates operation/new-entrant endpoints to accept multipart uploads and introduces dataclass-based service payload types to replace previous schema-driven data-url conversion.
  • Tests/docs: refactors unit/integration/performance tests and begins updating upload documentation.

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
docs/file_uploads.md Adds placeholder note for updated file upload docs.
bciers/libs/components/src/form/widgets/readOnly/ReadOnlyFileWidget.tsx Updates read-only file rendering to use new file metadata format.
bciers/libs/components/src/form/widgets/OldFileWidget.tsx Adds prior widget implementation as a separate file.
bciers/libs/components/src/form/widgets/FileWidget.tsx Implements multipart upload flow + new useFileUploadWidget/FileElement.
bciers/libs/components/src/form/MultiStepBase.tsx Adds support for passing formContext into RJSF forms.
bciers/apps/registration/tests/performance/scenarios/backend/operation.js Adjusts perf scenario payloads (partial) for new upload approach.
bciers/apps/registration/tests/components/operations/registration/OperationInformationForm.test.tsx Updates component test expectations for multipart submission + file metadata strings.
bciers/apps/registration/tests/components/operations/registration/NewEntrantOperationForm.test.tsx Updates new-entrant test to assert multipart payload + attached File.
bciers/apps/registration/app/data/jsonSchema/operationRegistration/newEntrantOperation.ts Removes data-url format from schema for new entrant upload field.
bciers/apps/registration/app/components/operations/registration/OperationInformationForm.tsx Uses useFileUploadWidget and submits via multipart proxy.
bciers/apps/registration/app/components/operations/registration/NewEntrantOperationForm.tsx Uses useFileUploadWidget and submits via multipart proxy.
bciers/apps/administration/tests/components/operations/OperationInformationForm.test.tsx Updates admin operation form tests for new file metadata format.
bciers/apps/administration/app/data/jsonSchema/operationInformation/operationInformation.ts Removes data-url formats for operation document fields.
bciers/apps/administration/app/components/operations/OperationInformationPage.tsx Minor page change (includes a debug log in current diff).
bciers/apps/administration/app/components/operations/OperationInformationForm.tsx Uses useFileUploadWidget and submits via multipart proxy.
bc_obps/tests/test_files.py Adds helper to create UploadedFile instances for tests.
bc_obps/service/tests/test_document_service.py Updates document service tests to use UploadedFile objects.
bc_obps/service/tests/operation_service/test_operation_service.py Refactors operation service tests to use new dataclass payloads + files.
bc_obps/service/tests/data_access_service/test_data_access_opted_in_operation_detail_service.py Updates opted-in operation detail tests to use dataclass payload.
bc_obps/service/operation_service.py Reworks service layer to accept dataclass payloads + uploaded files.
bc_obps/service/document_service.py Updates document service signature to accept File objects.
bc_obps/service/data_types/operation_service_data_types.py Introduces dataclasses for operation payloads and related types.
bc_obps/service/data_access_service/opted_in_operation_detail_service.py Switches to dataclass-to-dict conversion via new asdict.
bc_obps/service/data_access_service/document_service.py Updates data access signature to accept File.
bc_obps/registration/utils.py Removes data-url-to-file conversion helper (no longer needed).
bc_obps/registration/tests/test_utils.py Removes tests tied to data-url conversion behavior.
bc_obps/registration/tests/integration/test_operation_registration.py Updates integration tests to post multipart payloads.
bc_obps/registration/tests/integration/test_changing_registration_purpose.py Updates integration tests to post multipart payloads + files.
bc_obps/registration/tests/endpoints/test_operations.py Updates endpoint tests to post multipart payloads + files.
bc_obps/registration/tests/endpoints/_operations/test_operation_id.py Updates update-operation test to multipart + POST.
bc_obps/registration/tests/endpoints/_operations/_operation_id/_registration/test_operation.py Updates registration-operation endpoint tests to multipart + POST.
bc_obps/registration/tests/endpoints/_operations/_operation_id/_registration/test_new_entrant_application.py Updates new-entrant endpoint tests to multipart + POST.
bc_obps/registration/tests/constants.py Removes large inlined mock data-url constants.
bc_obps/registration/schema/operation.py Serializes documents as JSON strings (name/id/status) instead of data-urls.
bc_obps/registration/api/operations.py Accepts multipart files and wraps payload into OperationData.
bc_obps/registration/api/_operations/operation_id.py Changes update operation to POST + multipart file inputs.
bc_obps/registration/api/_operations/_operation_id/_registration/opted_in_operation.py Wraps opted-in payload into dataclass for service layer.
bc_obps/registration/api/_operations/_operation_id/_registration/operation.py Changes registration operation update to POST + multipart file inputs.
bc_obps/registration/api/_operations/_operation_id/_registration/operation_representative.py Adjusts representative removal to pass scalar ID into service.
bc_obps/registration/api/_operations/_operation_id/_registration/new_entrant_application.py Changes new-entrant upload to POST + multipart file input.
bc_obps/common/tests/lib/dataclasses/test_asdict.py Adds unit tests for custom asdict include/exclude behavior.
bc_obps/common/tests/endpoints/auth/constants.py Updates auth test matrix for POST method changes.
bc_obps/common/lib/dataclasses/dict_factory.py Adds dict factory supporting include/exclude-none semantics.
bc_obps/common/lib/dataclasses/asdict.py Adds asdict wrapper mirroring pydantic-style options.
bc_obps/common/lib/dataclasses/init.py Exposes asdict via package init.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bciers/libs/components/src/form/widgets/FileWidget.tsx
Comment thread bciers/libs/components/src/form/widgets/FileWidget.tsx
Comment thread bciers/libs/components/src/form/widgets/FileWidget.tsx
Comment thread bciers/apps/administration/app/components/operations/OperationInformationPage.tsx Outdated
Comment thread docs/file_uploads.md Outdated
Comment thread bciers/libs/components/src/form/widgets/FileWidget.tsx Outdated
@pbastia
pbastia force-pushed the chore/2123-refactor-registration-file-uploads branch 2 times, most recently from f14b6c7 to a8b5053 Compare July 8, 2026 21:36
@pbastia pbastia added the run-all-ci Trigger label to force all CI to run on a PR. label Jul 8, 2026
@pbastia
pbastia force-pushed the chore/2123-refactor-registration-file-uploads branch 3 times, most recently from 5a8df34 to 6583d8e Compare July 13, 2026 16:07
@pbastia
pbastia force-pushed the chore/2123-refactor-registration-file-uploads branch from 1ffc682 to 85ca349 Compare July 15, 2026 22:57

@Sepehr-Sobhani Sepehr-Sobhani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Amazing work 🤩

Comment thread bc_obps/registration/schema/operation.py
Comment thread bc_obps/service/data_types/operation_service.py
Comment thread bc_obps/registration/schema/operation.py Outdated
Comment thread bc_obps/common/tests/utils/test_files.py
Comment thread bc_obps/registration/api/operations.py Outdated

@Sepehr-Sobhani Sepehr-Sobhani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not directly related to this PR, but do we want to add some backend validation to enforce allowed file extensions? I noticed accept: ".pdf" in the new entrant schema, but that is only a frontend UI hint and users can bypass it.

@pbastia
pbastia force-pushed the chore/2123-refactor-registration-file-uploads branch from 85ca349 to 9dbe043 Compare July 17, 2026 23:17

@Sepehr-Sobhani Sepehr-Sobhani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🥇

@pbastia
pbastia force-pushed the chore/2123-refactor-registration-file-uploads branch 4 times, most recently from 5a1cb3c to c70f5a9 Compare July 22, 2026 22:47
pbastia added 2 commits July 23, 2026 09:04
chore: updating django ninja

reverting ninja update

chore: removing data-url hint from schemas
pbastia added 9 commits July 23, 2026 09:05
chore: data types for operation information service

chore: operation service refactor to use internal classes

test: custom asdict method

test: testing the refactored operation service

test: more working tests

test: API with files

test: changing reg purpose

test: global endpoints config

test: operation update main endpoint

test: removing dependency on mock data urls

test: removing data url utils
chore: almost feature complete

chore: refactoring tests

chore: serialized file info

test: frontend tests
docs: updating file upload docs

test: components

chore: more admin tests
test: updating tests

chore: logs
test: fixing hook test

test: fixing revalidate path
chore: forgotten only in test

chore: forgotten file

chore: moving files
@pbastia
pbastia force-pushed the chore/2123-refactor-registration-file-uploads branch from c70f5a9 to a49c797 Compare July 23, 2026 16:05
@pbastia
pbastia merged commit 0eaf0b3 into develop Jul 23, 2026
68 of 71 checks passed
@pbastia
pbastia deleted the chore/2123-refactor-registration-file-uploads branch July 23, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-all-ci Trigger label to force all CI to run on a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants