-
Notifications
You must be signed in to change notification settings - Fork 5
Create students in Profile API #370
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ad48cc5
to
0a24f45
Compare
0a24f45
to
78803f8
Compare
78803f8
to
b8d52cb
Compare
fd14dd2
to
b8677c6
Compare
b8677c6
to
bfccdd1
Compare
bfccdd1
to
9b8cf3a
Compare
9b8cf3a
to
4a80abe
Compare
4a80abe
to
0052659
Compare
0052659
to
2d47a97
Compare
2d47a97
to
7867f7c
Compare
7867f7c
to
bd7b4b7
Compare
bd7b4b7
to
70aa257
Compare
c332139
to
a04fbf5
Compare
a04fbf5
to
2695350
Compare
🔧 I can't comment against it but there's a rogue |
sra405
reviewed
Jul 8, 2024
spec/features/school_student/creating_a_batch_of_school_students_spec.rb
Outdated
Show resolved
Hide resolved
sra405
reviewed
Jul 8, 2024
spec/features/school_student/creating_a_batch_of_school_students_spec.rb
Outdated
Show resolved
Hide resolved
sra405
reviewed
Jul 8, 2024
sra405
reviewed
Jul 8, 2024
sra405
reviewed
Jul 8, 2024
2695350
to
5d6330e
Compare
sra405
approved these changes
Jul 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 nice! LGTM
I think it probably makes sense to think of ProfileApiClient as an external library that wraps Profile API but doesn't know anything about our domain objects.
To automatically serialise the request body as JSON and set the `Content-Type` header[1]. [1]: https://lostisland.github.io/faraday/#/middleware/included/json?id=json-requests
To automatically deserialize the response body when the `Content-Type` indicates that it contains JSON[1] [1]: https://lostisland.github.io/faraday/#/middleware/included/json?id=json-responses
This is probably more idiomatic than setting them in the `apply_default_headers` method.
To list the Safeguarding flags for the user associated with the access token. Note that I'm intentionally not doing anything different if `BYPASS_OAUTH` is set. Given how tightly coupled Editor API and Profile API are I'm less convinced it makes sense to attempt to run one without the other in development. API docs: https://my.raspberrypi.org/api/v1/documentation/#/Safeguarding%20Flags/get_safeguarding_flags
In preparation for creating the relevant teacher or owner safeguarding flags for the authenticated user so that they have permission to CRUD students in Profile API. Note that Profile API returns 201 if the flag was created and 303 if it already exists. Note that I'm intentionally not doing anything different if `BYPASS_OAUTH` is set. Given how tightly coupled Editor API and Profile API are I'm less convinced it makes sense to attempt to run one without the other in development. API docs: https://my.raspberrypi.org/api/v1/documentation/#/Safeguarding%20Flags/post_safeguarding_flags
We're not using this at the moment but it makes it easier to test in development if we can create and delete safeguarding flags for a user. Note that I'm intentionally not doing anything different if `BYPASS_OAUTH` is set. Given how tightly coupled Editor API and Profile API are I'm less convinced it makes sense to attempt to run one without the other in development. API docs: https://my.raspberrypi.org/api/v1/documentation/#/Safeguarding%20Flags/delete_safeguarding_flags__flag_
The Profile API requires that the authenticated user has: - either the school:owner or school:teacher safeguarding flags set in order to be able to create, edit and list students - the school:owner safeguarding flag set in order to be able to delete students Safeguarding flags can only be set in Profile API for the authenticated user so we're conditionally creating them here before the user then attempts to interact with Profile API to CRUD students.
Note that if the student is successfully created in Profile API then we receive their ID in the response. We use this to create the relevant student role and also make it available in the OperationResponse returned by `SchoolStudent::Create.call` so that clients of Editor API can use it if necessary. I'm stripping any extraneous leading and trailing spaces from name, username and password in ProfileApiClient.create_school_student to avoid the sorts of problems that can occur when usernames and passwords include these unnecessary spaces. I've tested the Profile API and it's not (currently, at least) doing any kind of normalizing of what we pass to it. Note that I'm intentionally not doing anything different if `BYPASS_OAUTH` is set. Given how tightly coupled Editor API and Profile API are I'm less convinced it makes sense to attempt to run one without the other in development. API docs: https://my.raspberrypi.org/api/v1/documentation/#/Students/post_schools__schoolId__students
5d6330e
to
2d8ec2e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
With this PR we're now creating students in Profile API when they're added in editor-standalone. There are a number of commits but they should all be fairly easy to follow in isolation:
ProfileApiClient
in preparation for implementing.create_school_student
.ProfileApiClient
to list, create and destroy safeguarding flags in Profile API.before_filter
toSchoolStudentsController
that creates the relevant (teacher and/or owner) safeguarding flags in Profile API for the authenticated user..create_school_student
so that it creates a student in Profile API.Although the create student endpoint in Profile API allows us to create multiple students in a single request, we're currently only ever calling it with a single student: even in the
SchoolStudent::CreateBatch
operation. We're also not currently using the create batch endpoint in the editor-standalone CSV import functionality, and are instead making a request for each row in the CSV file. This will need more work as it currently only displays a single error message, rather than all error messages preventing students from being created.