Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API 1 of 3: Refactor Organisation Model #178

Merged
merged 25 commits into from
Feb 26, 2024
Merged

API 1 of 3: Refactor Organisation Model #178

merged 25 commits into from
Feb 26, 2024

Conversation

R2ZER0
Copy link
Contributor

@R2ZER0 R2ZER0 commented Feb 1, 2024

This PR was originally Part 1 of #175

This PR:

  • Refactors out a lot of the Organisation-fetching logic from the OrganisationDetailView, to the Organisation "model" (dataclass) itsself, so it can be reused.
  • Hides Publisher.getter_run from the public API

@R2ZER0 R2ZER0 changed the title API: Add OpenAPI Schema API: Add OpenAPI Schema w/ swagger-ui Feb 1, 2024
@R2ZER0 R2ZER0 force-pushed the rg/api-schema-1 branch 2 times, most recently from 3a83dca to 6fd4904 Compare February 1, 2024 17:36
@R2ZER0 R2ZER0 changed the title API: Add OpenAPI Schema w/ swagger-ui API: Refactor Organisation Model Feb 1, 2024
@R2ZER0 R2ZER0 changed the title API: Refactor Organisation Model API 1 of 3: Refactor Organisation Model Feb 8, 2024
@R2ZER0 R2ZER0 marked this pull request as ready for review February 12, 2024 10:08
@R2ZER0 R2ZER0 assigned michaelwood and unassigned michaelwood Feb 12, 2024
Move the logic to create an Organisation "fake" model instance from db, out of
the view and into the model itsself.
TODO: Perhaps nn future, explicitly handle and return 404, rather than empty list?
In preparation for removing this field from the Model.
@@ -112,7 +97,7 @@ class OrganisationGrantsMadeView(generics.ListAPIView):
filter_backends = [django_filters.rest_framework.DjangoFilterBackend]

def get_queryset(self):
org_id = self.kwargs["org_id"]
org_id = self.kwargs.get("org_id")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a quick comment about why you want an empty list if the org_id is None

).order_by("-getter_run__datetime")[0]
except IndexError:
publisher = None
organisation = api_experimental.Organisation.get(
Copy link
Member

Choose a reason for hiding this comment

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

At some point we'll need to change this from experimental

drf-spectacular is a library which extends rest framework to generate OpenAPI
Schema 3.0, and optionally server a live docs site based on the schema.
Names conflict with dashboard serialisers, drf-spectacular requires serialisers
have unique names.
From drf-spectacular
and restrict the schema/swagger-ui to display only public endpoints.
* Move the new Org API into it's own API submodule
* Make use of dataclass serializer library
To simplify the API, remove redundant single grant detail view.
The other views display all the same data.
Fix a bug in this test missed due toprevious GrantsMadeView behaviour of returning empty list instead of 404.
The OrgDetail view wasn't properly handling object-not-found errors.
Example OrgIDs should start with prefix XE-EXAMPLE
Replace relative imports with absolute imports
@R2ZER0 R2ZER0 merged commit d730069 into master Feb 26, 2024
6 checks passed
@R2ZER0 R2ZER0 deleted the rg/api-schema-1 branch March 8, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants