Adding serializers, mixin, endpoints and views #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
get_json_ld()in Models and SerializersModel-Level get_json_ld
The get_json_ld method defined on our models is intended to directly access and return JSON-LD data from the model’s instance. This is useful for:
Serializer-Level get_json_ld
The get_json_ld method implemented in a serializer is tailored for API responses. It serializes model data and outputs the JSON-LD representation as part of the API response. This is beneficial because:
Closes #9
Mixin
To avoid duplicating the
get_json_ldlogic, we use a reusable JSONLDSerializerMixin. This mixin will dynamically add ajson_ldfield to any serializer by calling the model’sget_json_ldmethod.Closes #18
API Endpoints and Views
Following comments made in #10, we reorganized API Endpoints and Views but also Outbox was added.
Actor
Activities
Notes
PortabilityOutbox
API Response for /api/actors/4/outbox/
The PortabilityOutboxSerializer will call the model’s get_json_ld() method, and the response will look like this:
Closes #10
Explanation of each endpoint and view
1. Actor Endpoint
GET /api/actors/1/2. PortabilityOutbox Endpoint
GET /api/actors/1/outbox/3. Deactivate Account Endpoint
The deactivate account view allows staff users or internal logic to deactivate an Actor account.
This is intended for administrative purposes and is not required to be exposed as an API endpoint. Instead, it is implemented as a regular Django view.
POST /api/actors/1/deactivate/4. Trigger Account
Implementers use this to test the account portability workflow.
5. Report Activity
It helps debug and document the portability process for implementers.
Summary Table of Views
Testing the Endpoint
Actor Request:
GET /api/actors/4/Actor’s Outbox Request
GET /api/actors/4/outbox/