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

Restful API for orders #133

Merged
merged 26 commits into from
Feb 11, 2021
Merged

Restful API for orders #133

merged 26 commits into from
Feb 11, 2021

Conversation

KiOui
Copy link
Owner

@KiOui KiOui commented Dec 11, 2020

Added a Restful API for orders application.

Added the following:

  • API views for listing, creating, retrieving and updating Shift objects
  • API views for listing, creating, retrieving, updating and destroying Order objects
  • API views for listing Product objects
  • API views for the features available on the Shift admin screen
  • Serializers for all the above methods
  • VueJS to easily manage the state of the HTML document in the browser
  • A CustomAutoSchema to make adjustments to the provided AutoSchema
  • SwaggerUI

Removed the following:

  • All views that we were using to provide API-like features that are now implemented in the API
  • A couple of templates that are now included in bigger ones to optimize the VueJS and API implementation

To test you can visit /api/docs.

Closes #125
Closes #101

@KiOui KiOui self-assigned this Dec 11, 2020
Copy link
Collaborator

@JobDoesburg JobDoesburg left a comment

Choose a reason for hiding this comment

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

How does authentication work?

website/orders/api/serializers/orders.py Outdated Show resolved Hide resolved
website/orders/api/serializers/orders.py Outdated Show resolved Hide resolved
website/tosti/settings/settings.py Show resolved Hide resolved
website/orders/api/v1/permissions.py Outdated Show resolved Hide resolved
website/orders/api/v1/serializers.py Outdated Show resolved Hide resolved
website/orders/api/v1/serializers.py Outdated Show resolved Hide resolved
website/orders/api/v1/serializers.py Outdated Show resolved Hide resolved
website/orders/api/v1/serializers.py Outdated Show resolved Hide resolved
website/orders/api/v1/views.py Show resolved Hide resolved
website/orders/api/v1/views.py Outdated Show resolved Hide resolved
website/orders/services.py Show resolved Hide resolved
website/orders/api/v1/urls.py Show resolved Hide resolved
website/orders/api/v1/urls.py Outdated Show resolved Hide resolved
@JobDoesburg
Copy link
Collaborator

JobDoesburg commented Jan 28, 2021

  • We still need to style swagger UI with some TOSTI styling
  • In my opinion the API should accept POST to /orders instead of POST to /cart-order or /orders/add
  • We should add / improve documentation to the schema

@KiOui
Copy link
Owner Author

KiOui commented Jan 28, 2021

  • In my opinion the API should accept POST to /orders instead of POST to /cart-order or /orders/add

The /cart-order endpoint will still be necessary, I'll try to add the POST to the /orders endpoint.

@KiOui
Copy link
Owner Author

KiOui commented Jan 30, 2021

We also need to implement token support for the authenticator

product = ProductSerializer(many=False, read_only=True)
user = UserRelatedField(many=False, read_only=True)

def validate_product_id(self, value):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be formulated better

Copy link
Owner Author

Choose a reason for hiding this comment

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

What do you mean?

website/orders/api/v1/views.py Outdated Show resolved Hide resolved
website/orders/services.py Show resolved Hide resolved
website/tosti/api/openapi.py Outdated Show resolved Hide resolved
website/marietje/api/v1/views.py Outdated Show resolved Hide resolved
website/marietje/api/v1/views.py Outdated Show resolved Hide resolved
@KiOui
Copy link
Owner Author

KiOui commented Feb 10, 2021

As stated here, there is no easy way to implement manual schema adjustments to AutoSchema of OpenAPI for now, so we have to write our own.

website/marietje/api/v1/views.py Outdated Show resolved Hide resolved
website/marietje/api/v1/views.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@JobDoesburg JobDoesburg left a comment

Choose a reason for hiding this comment

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

Ja opzicht nice, we moeten alleen ff een issue openen om wat uitgebreidere documentatie hier toe te voegen en OAuth scopes toe te voegen.

@KiOui KiOui merged commit d816f9a into master Feb 11, 2021
@KiOui KiOui deleted the feature/rest-api branch February 11, 2021 11:05
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.

Enhancement: More structured POST views Refactor: refresh views should return proper JSON, not HTML-in-JSON
3 participants