Skip to content

Commit

Permalink
Merge pull request #13 from WATonomous/jimmy/update-edit-link
Browse files Browse the repository at this point in the history
Update edit link for new onboarding form
  • Loading branch information
Jimmyj30 authored Apr 6, 2024
2 parents 8c516b1 + 5b20185 commit 543332e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# user-config-lookup

## Local Setup

Get all users from the WATO infra config (code example below) and direct the
output to `user_directory.json`. Place the file in the root of this repo,
under the path `./data/user_directory.json`

```py
# see infra config repo for examples of how to use `get_all_users`
import get_all_users
import json
print(json.dumps(get_all_users(), sort_keys=True))
```

Note that an env file is also required to run the app locally.
It should look like the example below and be placed in `./.env`.

```
EMAIL_ADDRESS=<EMAIL>
EMAIL_PASSWORD=<PASSWORD>
SENTRY_DSN=<DSN>
```

The values of these variables can be found in the WATO infra config.

## Running the program

Running the container:
Expand Down
8 changes: 4 additions & 4 deletions app/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import os
import aiosmtplib
from urllib.parse import quote
import base64
from email.message import EmailMessage


Expand All @@ -11,9 +11,9 @@

def generate_edit_link(user_config: dict) -> str:
config_json_string = json.dumps(user_config)
config_json_string_encoded = quote(config_json_string)
base_url = "https://watonomous.github.io/infra-config/onboarding-form"
edit_link = f"{base_url}/?initialFormData={config_json_string_encoded}"
config_b64_string = base64.b64encode(config_json_string.encode()).decode()
base_url = "https://cloud.watonomous.ca/docs/utilities/onboarding-form"
edit_link = f"{base_url}?initialformdatab64={config_b64_string}"
logger.debug(f"Edit link (truncated): {edit_link[0:100]}...")

return edit_link
Expand Down

0 comments on commit 543332e

Please sign in to comment.