Skip to content

Update /assets endpoint #713

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 5 commits into from
Feb 15, 2021
Merged

Update /assets endpoint #713

merged 5 commits into from
Feb 15, 2021

Conversation

bnjmnt4n
Copy link
Contributor

I've created a v2 branch, which me and @qreoct will use over the course of the semester to stage our changes.

This PR removes the role validation from the Assets model, since models should not be concerned with validation, and removes the user parameter from the function definitions. It also updates the routes to shift the /v1/assets endpoint into /v2/admin/assets and performs validation in the router.

The endpoint is updated to `/v2/admin/assets`, and validation is
performed within the router instead.
@bnjmnt4n bnjmnt4n added _backend The issue concerns backend component _API labels Jan 27, 2021
@bnjmnt4n bnjmnt4n self-assigned this Jan 27, 2021
assert response(conn, 403) =~ "User not allowed to manage assets"
assert response(conn, 403) =~ "Forbidden"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We've lost the more informative error message, but I think there's a fair trade-off in terms of improving code de-duplication.

@bnjmnt4n bnjmnt4n removed _API _backend The issue concerns backend component labels Jan 27, 2021
@bnjmnt4n bnjmnt4n marked this pull request as ready for review January 31, 2021 12:48
Copy link
Contributor

@angelsl angelsl left a comment

Choose a reason for hiding this comment

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

Looks good to me aside from with/case which is mostly a minor stylistic thing.

Actually, I was thinking that you might keep the v1 routes around until the v2 routes were ready, but honestly this is fine too.

@bnjmnt4n bnjmnt4n merged commit 85501dc into v2 Feb 15, 2021
@bnjmnt4n bnjmnt4n deleted the cleanup/assets branch February 15, 2021 08:50
angelsl pushed a commit that referenced this pull request Apr 17, 2021
* Update `/assets` endpoint (#713)

* Assets: remove role validation in model

* AssetsController: update API endpoint and validation

The endpoint is updated to `/v2/admin/assets`, and validation is
performed within the router instead.

* Shift to `AdminAssetsController`

* Rename `AdminAssetsController` to `.exs`

* Assets: switch to `case` instead of `with`

* (1) Clearer Swagger documentation in Grading (2) Code documentation cleaup in auth_controller

* Notifications changed to plural throughout

* Settings swagger docs cleanup

* User docs typo fix

* CI fix formatting

* Update `/settings` endpoint (#722)

* `/auth`: shift `/auth` to `/auth/login`

* `/devices`: fix typo and shift to v2

* Update `/grading` endpoint (#727)

* shift role validation for Settings

* shift Grading controller to AdminGrading

* fix formatting and add details to docs

Co-authored-by: Benjamin Tan <benjamin@dev.ofcr.se>

* Rename `assets_controller_test` to `admin_assets_controller_test`

* update swagger docs for /grading

* Update `/assessments` endpoint (#729)

* `/assessments`: split out separate `/admin` endpoint

* Consistently use `/assessments/:assessmentid`

* Merge `/admin/assessments/:assessmentid/{update,publish}` endpoints

* Quick swagger docs fix for `AdminAssessmentsController`

* Format code via `mix format`

* Formatting fix

* `/assessments/{assessmentid}/submit`: shift role validation to controller

* Add more guards

* `/assessments/question/{questionid}/submit`: shift role validation to AnswerController

* clean up some docs

* Modify `AnswerController#submit` path

* Assessments: remove unused definitions

* Remove leftover unused route

* Split `AssesmentsController#unlock` out of `AssessmentsController#show`

`AssesmentsController#unlock` unlocks password-protected assessments and
creates a Submission for them, following which the assessments do not
require requests with the password.

* Fix formatting issues

* `/assessments`: split out separate `/admin` endpoint

* Consistently use `/assessments/:assessmentid`

* Merge `/admin/assessments/:assessmentid/{update,publish}` endpoints

* Quick swagger docs fix for `AdminAssessmentsController`

* Format code via `mix format`

* `/assessments/{assessmentid}/submit`: shift role validation to controller

* Add more guards

* `/assessments/question/{questionid}/submit`: shift role validation to AnswerController

* clean up some docs

* Modify `AnswerController#submit` path

* Assessments: remove unused definitions

* Remove leftover unused route

* Split `AssesmentsController#unlock` out of `AssessmentsController#show`

`AssesmentsController#unlock` unlocks password-protected assessments and
creates a Submission for them, following which the assessments do not
require requests with the password.

* Fix formatting issues

* formatting

* Update per PR feedback

* Remove unused variable

Co-authored-by: qreoct <9080974+qreoct@users.noreply.github.com>

* Change to v2 API throughout

* Fix Swagger references

* AdminGradingControllerTest: Add swagger path definition

* Remove duplicated route

* Rename file as per convention

* Swagger documentation: Switch to enums for string values

* /auth/login: shift parameters to query string in docs

* UserController: add an empty UserGameStates map to the schema

* Add comments to clarify invalid OpenAPI 2.0 types

* Swagger: shift request parameters to separate schemas

Request parameters were previously declared as separate body parameters
in the Swagger schema, which was technically invalid. For endpoints
which require more than 1 parameter, which is sent as JSON, I've created
separated schemas which represent the parameters, to make the generated
`swagger.json` more compliant.

* Story: Fix inaccurate Swagger documentation

* Shift all Swagger enums into their own schemas

This allows `swagger-typescript-api` in `cadet-frontend` to generate
TypeScript `enum`s for the corresponding type.

* Fix inaccurate types

* Update based on code review feedback

* clean up docs

* clean up docs

* Endpoints: update to mark as required

* More changes to the Swagger types

* Even more type updates

* more swagger docs consistency

* /admin/assessments: update swagger to FormData parameters

Co-authored-by: qreoct <9080974+qreoct@users.noreply.github.com>
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.

2 participants