Skip to content

Commit

Permalink
docs(add-model): adjust annotations
Browse files Browse the repository at this point in the history
Repositioned and combined a couple of them.
  • Loading branch information
fyliu committed Jun 6, 2024
1 parent 271f9e5 commit d3fd074
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/architecture/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ These are the steps involved:
1. Backend verifies token and processes request
1. User gets response from authenticated API

``` mermaid
```mermaid
sequenceDiagram
autonumber
participant Cognito User Pool
Expand All @@ -35,7 +35,6 @@ sequenceDiagram
Backend-->>-User:response from authenticated API
```


## Current Dev Setup

1. Created app client called "backend within the vrms-dev user pool, with ALLOW_ADMIN_USER_PASSWORD_AUTH enabled
Expand All @@ -49,6 +48,7 @@ sequenceDiagram
1. Backend should return the user's profile data

## Authentication Guide for Cognito

Before following the below instruction, please ensure you have docker up and running and the build-image running, you can run it with the command `./scripts/buildrun.sh`.

1. Login (or register first then login) to a cognito account [here](https://hackforla-vrms-dev.auth.us-west-2.amazoncognito.com/login?client_id=3e3bi1ct2ks9rcktrde8v60v3u&response_type=token&scope=openid&redirect_uri=http://localhost:8000/admin). Do not worry if you see error messages - you will be using the url to authenticate.
Expand Down
11 changes: 6 additions & 5 deletions docs/how-to/add-model-and-api-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,11 @@ In `app/core/api/views.py`
class UserViewSet(viewsets.ModelViewSet):
...

# (1)!
def get_queryset(self): # (2)!
def get_queryset(self): # (1)!
"""
Optionally filter users by an 'email' and/or 'username' query paramerter in the URL
"""
queryset = get_user_model().objects.all() # (3)!
queryset = get_user_model().objects.all() # (2)!
email = self.request.query_params.get("email")
if email is not None:
queryset = queryset.filter(email=email)
Expand All @@ -412,7 +411,9 @@ In `app/core/api/views.py`
```

1. Notice the `queryset` property is now the `get_queryset(()` function which returns the queryset.
1. The `get_queryset()` function overrides the default and lets us filter the objects returned to the client if they pass in a query param.
The `get_queryset()` function overrides the default and lets us filter the objects returned to the client if they pass in a query param.
1. Start with all the model objects and filter them based on any available query params.
### Register API endpoints
Expand All @@ -428,8 +429,8 @@ In `app/core/api/urls.py`
1. [Register](https://www.django-rest-framework.org/api-guide/routers/#usage) the viewset to the [router](https://www.django-rest-framework.org/api-guide/routers/)
```python title="app/core/api/urls.py" linenums="1"
# (1)!
router.register(r"recurring-events", RecurringEventViewSet, basename="recurring-event")
# (1)!
```
1. Params
Expand Down

0 comments on commit d3fd074

Please sign in to comment.