Compare commits
4 Commits
ecayer-pat
...
1669-toggl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86d25bcf7c | ||
|
|
43114494ec | ||
|
|
42d11315be | ||
|
|
c94c3de9f0 |
26
.ds.baseline
@@ -135,6 +135,14 @@
|
||||
"is_verified": false,
|
||||
"line_number": 68,
|
||||
"is_secret": false
|
||||
},
|
||||
{
|
||||
"type": "Basic Auth Credentials",
|
||||
"filename": ".github/workflows/checks.yml",
|
||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
||||
"is_verified": false,
|
||||
"line_number": 103,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
"app/assets/js/uswds.min.js": [
|
||||
@@ -161,7 +169,7 @@
|
||||
"filename": "app/config.py",
|
||||
"hashed_secret": "577a4c667e4af8682ca431857214b3a920883efc",
|
||||
"is_verified": false,
|
||||
"line_number": 120,
|
||||
"line_number": 117,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
@@ -405,7 +413,7 @@
|
||||
"filename": "app/templates/new/components/head.html",
|
||||
"hashed_secret": "ee5048791fc7ff45a1545e24f85bec3317371327",
|
||||
"is_verified": false,
|
||||
"line_number": 33,
|
||||
"line_number": 34,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
@@ -425,7 +433,7 @@
|
||||
"filename": "deploy-config/sandbox.yml",
|
||||
"hashed_secret": "113151dd10316fcb0d5507b6215d78e2f3fe9e54",
|
||||
"is_verified": false,
|
||||
"line_number": 9,
|
||||
"line_number": 8,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
@@ -527,7 +535,7 @@
|
||||
"filename": "tests/app/main/views/test_accept_invite.py",
|
||||
"hashed_secret": "07f0a6c13923fc3b5f0c57ffa2d29b715eb80d71",
|
||||
"is_verified": false,
|
||||
"line_number": 631,
|
||||
"line_number": 626,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
@@ -555,7 +563,7 @@
|
||||
"filename": "tests/app/main/views/test_register.py",
|
||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
||||
"is_verified": false,
|
||||
"line_number": 199,
|
||||
"line_number": 201,
|
||||
"is_secret": false
|
||||
},
|
||||
{
|
||||
@@ -563,7 +571,7 @@
|
||||
"filename": "tests/app/main/views/test_register.py",
|
||||
"hashed_secret": "bb5b7caa27d005d38039e3797c3ddb9bcd22c3c8",
|
||||
"is_verified": false,
|
||||
"line_number": 272,
|
||||
"line_number": 274,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
@@ -593,7 +601,7 @@
|
||||
"filename": "tests/app/main/views/test_user_profile.py",
|
||||
"hashed_secret": "8072d7aad32964ec43fbcb699c75dc38890792f7",
|
||||
"is_verified": false,
|
||||
"line_number": 336,
|
||||
"line_number": 350,
|
||||
"is_secret": false
|
||||
},
|
||||
{
|
||||
@@ -601,7 +609,7 @@
|
||||
"filename": "tests/app/main/views/test_user_profile.py",
|
||||
"hashed_secret": "4c9dbb972da179e4f66f023eaa5fb9451d835030",
|
||||
"is_verified": false,
|
||||
"line_number": 337,
|
||||
"line_number": 351,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
@@ -684,5 +692,5 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"generated_at": "2025-02-26T18:19:37Z"
|
||||
"generated_at": "2024-08-07T14:36:40Z"
|
||||
}
|
||||
|
||||
11
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
@@ -64,17 +64,6 @@ body:
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: '**Accessibility:**'
|
||||
- type: textarea
|
||||
id: accessibility
|
||||
attributes:
|
||||
label: "List any specific accessibility guidance or tests that need to be considered for this user story."
|
||||
description: "List what type of accessibility tests need to pass."
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: '**Notes:**'
|
||||
|
||||
16
.github/actions/deploy-proxy/action.yml
vendored
@@ -1,9 +1,6 @@
|
||||
name: Deploy egress proxy
|
||||
description: Set egress space security groups and deploy proxy
|
||||
inputs:
|
||||
cf_org:
|
||||
description: The org the target app exists in.
|
||||
required: true
|
||||
cf_space:
|
||||
description: The space the target app exists in.
|
||||
required: true
|
||||
@@ -19,19 +16,6 @@ inputs:
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Install cf-cli
|
||||
shell: bash
|
||||
run: |
|
||||
curl -A "cg-deploy-action" -v -L -o cf-cli_amd64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=v8&source=github'
|
||||
sudo dpkg -i cf-cli_amd64.deb
|
||||
- name: Login to cf-cli
|
||||
shell: bash
|
||||
run: |
|
||||
cf api api.fr.cloud.gov
|
||||
cf auth
|
||||
- name: Target org and space
|
||||
shell: bash
|
||||
run: cf target -o ${{ inputs.cf_org }} -s ${{ inputs.cf_space }}
|
||||
- name: Set restricted space egress
|
||||
shell: bash
|
||||
run: ./terraform/set_space_egress.sh -t -s ${{ inputs.cf_space }}
|
||||
|
||||
2
.github/actions/setup-project/action.yml
vendored
@@ -15,7 +15,7 @@ runs:
|
||||
python-version: "3.12.3"
|
||||
- name: Install poetry
|
||||
shell: bash
|
||||
run: pip install poetry==1.8.5
|
||||
run: pip install poetry
|
||||
- name: Install application dependencies
|
||||
shell: bash
|
||||
run: make bootstrap
|
||||
|
||||
8
.github/dependabot.yml
vendored
@@ -9,16 +9,8 @@ updates:
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "daily"
|
||||
assignees:
|
||||
- "A-Shumway42"
|
||||
reviewers:
|
||||
- "A-Shumway42"
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
versioning-strategy: increase
|
||||
assignees:
|
||||
- "alexjanousekGSA"
|
||||
reviewers:
|
||||
- "alexjanousekGSA"
|
||||
|
||||
7
.github/pull_request_template.md
vendored
@@ -20,10 +20,3 @@ Please enter a detailed description here.
|
||||
* Consideration 1
|
||||
* Consideration 2
|
||||
* Consideration ...
|
||||
|
||||
## A11y Checks (if applicable)
|
||||
|
||||
* Double check work is getting picked up by the automated E2E tests
|
||||
* Conduct browser-based tests through [AxeDevTools](https://www.deque.com/axe/devtools/) and [WAVE](https://wave.webaim.org/)
|
||||
* Review the [Manual Checklist](https://docs.google.com/document/d/192bBXStebdXWtYhZQ73qaWMJhGcuSB1W6c9YBXhWZvc/edit?usp=sharing)
|
||||
* Make sure there are no linting errors in VSCode or other IDE of choice
|
||||
|
||||
88
.github/workflows/checks.yml
vendored
@@ -10,7 +10,7 @@ env:
|
||||
FLASK_APP: application.py
|
||||
WERKZEUG_DEBUG_PIN: off
|
||||
REDIS_ENABLED: 0
|
||||
NODE_VERSION: 22.3.0
|
||||
NODE_VERSION: 16.15.1
|
||||
AWS_US_TOLL_FREE_NUMBER: "+18556438890"
|
||||
ADMIN_BASE_URL: http://localhost:6012
|
||||
|
||||
@@ -38,12 +38,14 @@ jobs:
|
||||
output: report-markdown
|
||||
annotations: failed-tests
|
||||
prnumber: ${{ steps.findPr.outputs.number }}
|
||||
- name: Check imports alphabetized
|
||||
run: poetry run isort --check-only ./app ./tests
|
||||
- name: Run style checks
|
||||
run: poetry run flake8 .
|
||||
- name: Check imports alphabetized
|
||||
run: poetry run isort --check-only ./app ./tests
|
||||
- name: Check dead code
|
||||
run: make dead-code
|
||||
- name: Run js lint
|
||||
run: npm run lint
|
||||
- name: Run js tests
|
||||
run: npm test
|
||||
- name: Run py tests with coverage
|
||||
@@ -53,13 +55,11 @@ jobs:
|
||||
|
||||
end-to-end-tests:
|
||||
if: ${{ github.actor != 'dependabot[bot]' }}
|
||||
|
||||
permissions:
|
||||
checks: write
|
||||
pull-requests: write
|
||||
contents: write
|
||||
runs-on: ubuntu-latest
|
||||
environment: staging
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
@@ -91,33 +91,65 @@ jobs:
|
||||
- uses: ./.github/actions/setup-project
|
||||
- uses: jwalton/gh-find-current-pr@v1
|
||||
id: findPr
|
||||
- name: Check API Server availability
|
||||
run: |
|
||||
curl --fail -v https://notify-api-staging.app.cloud.gov || exit 1
|
||||
- name: Run Admin server
|
||||
# If we want to log stuff and see what's broken,
|
||||
# insert this line:
|
||||
# tail -f admin-server.log &
|
||||
# above make e2e-test
|
||||
|
||||
|
||||
run: |
|
||||
make run-flask > admin-server.log 2>&1 &
|
||||
tail -f admin-server.log &
|
||||
make e2e-test
|
||||
|
||||
- name: Clone API
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: GSA/notifications-api
|
||||
path: "notifications-api"
|
||||
- name: Install API dependencies
|
||||
working-directory: "notifications-api"
|
||||
run: make bootstrap
|
||||
env:
|
||||
API_HOST_NAME: https://notify-api-staging.app.cloud.gov/
|
||||
SECRET_KEY: ${{ secrets.SECRET_KEY }}
|
||||
DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api
|
||||
SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api
|
||||
REDIS_URL: redis://localhost:6379
|
||||
NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }}
|
||||
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
|
||||
NOTIFY_ENVIRONMENT: development
|
||||
- name: Run API server
|
||||
working-directory: "notifications-api"
|
||||
run: make run-procfile &
|
||||
env:
|
||||
DATABASE_URL: postgresql://user:password@localhost:5432/test_notification_api
|
||||
SQLALCHEMY_DATABASE_TEST_URI: postgresql://user:password@localhost:5432/test_notification_api
|
||||
REDIS_URL: redis://localhost:6379
|
||||
NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }}
|
||||
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
|
||||
NOTIFY_ENVIRONMENT: development
|
||||
- name: Run Admin server
|
||||
run: make run-flask &
|
||||
env:
|
||||
# API_HOST_NAME: https://notify-api-staging.app.cloud.gov
|
||||
API_HOST_NAME: http://localhost:6011
|
||||
DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }}
|
||||
SECRET_KEY: ${{ secrets.SECRET_KEY }}
|
||||
ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }}
|
||||
ADMIN_CLIENT_USERNAME: notify-admin
|
||||
NOTIFY_ENVIRONMENT: e2etest
|
||||
NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }}
|
||||
NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }}
|
||||
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
|
||||
NOTIFY_E2E_TEST_URI: http://localhost:6012/
|
||||
VCAP_SERVICES: ${{ secrets.VCAP_SERVICES }}
|
||||
NOTIFY_E2E_TEST_URI: http://localhost:6012
|
||||
- name: Run E2E tests
|
||||
# Run the E2E tests against the code found in this PR.
|
||||
# run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end
|
||||
# --browser webkit doesn't work at this time.
|
||||
run: make e2e-test
|
||||
# Debugging for now to troubleshoot a connectivity issue to the local servers
|
||||
# run: curl --request GET --url "http://localhost:6012"
|
||||
env:
|
||||
API_HOST_NAME: http://localhost:6011
|
||||
DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }}
|
||||
SECRET_KEY: ${{ secrets.SECRET_KEY }}
|
||||
ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }}
|
||||
ADMIN_CLIENT_USERNAME: notify-admin
|
||||
|
||||
NOTIFY_ENVIRONMENT: e2etest
|
||||
NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }}
|
||||
NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }}
|
||||
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
|
||||
NOTIFY_E2E_TEST_URI: http://localhost:6012
|
||||
|
||||
validate-new-relic-config:
|
||||
runs-on: ubuntu-latest
|
||||
environment: staging
|
||||
@@ -139,12 +171,11 @@ jobs:
|
||||
- uses: ./.github/actions/setup-project
|
||||
- name: Create requirements.txt
|
||||
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
|
||||
- uses: pypa/gh-action-pip-audit@v1.1.0
|
||||
- uses: pypa/gh-action-pip-audit@v1.0.8
|
||||
with:
|
||||
inputs: requirements.txt
|
||||
ignore-vulns: |
|
||||
PYSEC-2024-60
|
||||
PYSEC-2022-43162
|
||||
- name: Run npm audit
|
||||
run: make npm-audit
|
||||
|
||||
@@ -165,9 +196,8 @@ jobs:
|
||||
run: make run-flask &
|
||||
env:
|
||||
NOTIFY_ENVIRONMENT: scanning
|
||||
FEATURE_ABOUT_PAGE_ENABLED: true
|
||||
- name: Run OWASP Baseline Scan
|
||||
uses: zaproxy/action-baseline@v0.14.0
|
||||
uses: zaproxy/action-baseline@v0.9.0
|
||||
with:
|
||||
docker_name: "ghcr.io/zaproxy/zaproxy:weekly"
|
||||
target: "http://localhost:6012"
|
||||
@@ -177,7 +207,7 @@ jobs:
|
||||
cmd_options: "-I"
|
||||
|
||||
a11y-scan:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/setup-project
|
||||
|
||||
6
.github/workflows/daily_checks.yml
vendored
@@ -16,7 +16,7 @@ env:
|
||||
FLASK_APP: application.py
|
||||
WERKZEUG_DEBUG_PIN: off
|
||||
REDIS_ENABLED: 0
|
||||
NODE_VERSION: 22.3.0
|
||||
NODE_VERSION: 16.15.1
|
||||
|
||||
jobs:
|
||||
dependency-audits:
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
- uses: ./.github/actions/setup-project
|
||||
- name: Create requirements.txt
|
||||
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
|
||||
- uses: pypa/gh-action-pip-audit@v1.1.0
|
||||
- uses: pypa/gh-action-pip-audit@v1.0.6
|
||||
with:
|
||||
inputs: requirements.txt
|
||||
- name: Run npm audit
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
env:
|
||||
NOTIFY_ENVIRONMENT: scanning
|
||||
- name: Run OWASP Full Scan
|
||||
uses: zaproxy/action-full-scan@v0.12.0
|
||||
uses: zaproxy/action-full-scan@v0.7.0
|
||||
with:
|
||||
docker_name: 'ghcr.io/zaproxy/zaproxy:weekly'
|
||||
target: 'http://localhost:6012'
|
||||
|
||||
29
.github/workflows/deploy-demo.yml
vendored
@@ -16,17 +16,9 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Check for changes to Terraform
|
||||
id: changed-terraform-files
|
||||
uses: tj-actions/changed-files@v45
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files: |
|
||||
terraform/demo/**
|
||||
@@ -55,12 +47,11 @@ jobs:
|
||||
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
|
||||
|
||||
- name: Deploy to cloud.gov
|
||||
uses: cloud-gov/cg-cli-tools@main
|
||||
uses: 18f/cg-deploy-action@main
|
||||
env:
|
||||
DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }}
|
||||
SECRET_KEY: ${{ secrets.SECRET_KEY }}
|
||||
ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }}
|
||||
ADMIN_CLIENT_USERNAME: "notify-admin"
|
||||
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
|
||||
NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }}
|
||||
COMMIT_HASH: ${{ github.sha }}
|
||||
@@ -72,22 +63,21 @@ jobs:
|
||||
LOGIN_DOT_GOV_BASE_LOGOUT_URL: "https://secure.login.gov/openid_connect/logout?"
|
||||
LOGIN_DOT_GOV_SIGNOUT_REDIRECT: "https://notify-demo.app.cloud.gov/sign-out"
|
||||
LOGIN_DOT_GOV_INITIAL_SIGNIN_URL: "https://secure.login.gov/openid_connect/authorize?acr_values=http%3A%2F%2Fidmanagement.gov%2Fns%2Fassurance%2Fial%2F1&client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&nonce=NONCE&prompt=select_account&redirect_uri=https://notify-demo.app.cloud.gov/sign-in&response_type=code&scope=openid+email&state=STATE"
|
||||
LOGIN_DOT_GOV_CERTS_URL: "https://secure.login.gov/api/openid_connect/certs"
|
||||
with:
|
||||
cf_username: ${{ secrets.CLOUDGOV_USERNAME }}
|
||||
cf_password: ${{ secrets.CLOUDGOV_PASSWORD }}
|
||||
cf_org: gsa-tts-benefits-studio
|
||||
cf_space: notify-demo
|
||||
cf_command: >-
|
||||
push -f manifest.yml
|
||||
push_arguments: >-
|
||||
--vars-file deploy-config/demo.yml
|
||||
--var DANGEROUS_SALT="$DANGEROUS_SALT"
|
||||
--var SECRET_KEY="$SECRET_KEY"
|
||||
--var ADMIN_CLIENT_USERNAME="notify-admin"
|
||||
--var ADMIN_CLIENT_SECRET="$ADMIN_CLIENT_SECRET"
|
||||
--var ADMIN_CLIENT_USERNAME="$ADMIN_CLIENT_USERNAME"
|
||||
--var NEW_RELIC_LICENSE_KEY="$NEW_RELIC_LICENSE_KEY"
|
||||
--var NR_BROWSER_KEY="$NR_BROWSER_KEY"
|
||||
--var COMMIT_HASH="$COMMIT_HASH"
|
||||
--var LOGIN_PEM="$LOGIN_PEM"
|
||||
--var LOGIN_DOT_GOV_CLIENT_ID="$LOGIN_DOT_GOV_CLIENT_ID"
|
||||
--var LOGIN_DOT_GOV_USER_INFO_URL="$LOGIN_DOT_GOV_USER_INFO_URL"
|
||||
--var LOGIN_DOT_GOV_ACCESS_TOKEN_URL="$LOGIN_DOT_GOV_ACCESS_TOKEN_URL"
|
||||
@@ -95,13 +85,10 @@ jobs:
|
||||
--var LOGIN_DOT_GOV_BASE_LOGOUT_URL="$LOGIN_DOT_GOV_BASE_LOGOUT_URL"
|
||||
--var LOGIN_DOT_GOV_SIGNOUT_REDIRECT="$LOGIN_DOT_GOV_SIGNOUT_REDIRECT"
|
||||
--var LOGIN_DOT_GOV_INITIAL_SIGNIN_URL="$LOGIN_DOT_GOV_INITIAL_SIGNIN_URL"
|
||||
--var LOGIN_DOT_GOV_CERTS_URL="$LOGIN_DOT_GOV_CERTS_URL"
|
||||
--var LOGIN_PEM="$LOGIN_PEM"
|
||||
--strategy rolling
|
||||
|
||||
- name: Check for changes to egress config
|
||||
id: changed-egress-config
|
||||
uses: tj-actions/changed-files@v45
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files: |
|
||||
deploy-config/egress_proxy/notify-admin-demo.*.acl
|
||||
@@ -110,10 +97,6 @@ jobs:
|
||||
- name: Deploy egress proxy
|
||||
if: steps.changed-egress-config.outputs.any_changed == 'true'
|
||||
uses: ./.github/actions/deploy-proxy
|
||||
env:
|
||||
CF_USERNAME: ${{ secrets.CLOUDGOV_USERNAME }}
|
||||
CF_PASSWORD: ${{ secrets.CLOUDGOV_PASSWORD }}
|
||||
with:
|
||||
cf_org: gsa-tts-benefits-studio
|
||||
cf_space: notify-demo
|
||||
app: notify-admin-demo
|
||||
|
||||
29
.github/workflows/deploy-prod.yml
vendored
@@ -16,17 +16,9 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Check for changes to Terraform
|
||||
id: changed-terraform-files
|
||||
uses: tj-actions/changed-files@v45
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files: |
|
||||
terraform/production/**
|
||||
@@ -55,12 +47,11 @@ jobs:
|
||||
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
|
||||
|
||||
- name: Deploy to cloud.gov
|
||||
uses: cloud-gov/cg-cli-tools@main
|
||||
uses: 18f/cg-deploy-action@main
|
||||
env:
|
||||
DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }}
|
||||
SECRET_KEY: ${{ secrets.SECRET_KEY }}
|
||||
ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }}
|
||||
ADMIN_CLIENT_USERNAME: "notify-admin"
|
||||
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
|
||||
NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }}
|
||||
COMMIT_HASH: ${{ github.sha }}
|
||||
@@ -72,22 +63,21 @@ jobs:
|
||||
LOGIN_DOT_GOV_BASE_LOGOUT_URL: "https://secure.login.gov/openid_connect/logout?"
|
||||
LOGIN_DOT_GOV_SIGNOUT_REDIRECT: "https://beta.notify.gov/sign-out"
|
||||
LOGIN_DOT_GOV_INITIAL_SIGNIN_URL: "https://secure.login.gov/openid_connect/authorize?acr_values=http%3A%2F%2Fidmanagement.gov%2Fns%2Fassurance%2Fial%2F1&client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&nonce=NONCE&prompt=select_account&redirect_uri=https://beta.notify.gov/sign-in&response_type=code&scope=openid+email&state=STATE"
|
||||
LOGIN_DOT_GOV_CERTS_URL: "https://secure.login.gov/api/openid_connect/certs"
|
||||
with:
|
||||
cf_username: ${{ secrets.CLOUDGOV_USERNAME }}
|
||||
cf_password: ${{ secrets.CLOUDGOV_PASSWORD }}
|
||||
cf_org: gsa-tts-benefits-studio
|
||||
cf_space: notify-production
|
||||
cf_command: >-
|
||||
push -f manifest.yml
|
||||
push_arguments: >-
|
||||
--vars-file deploy-config/production.yml
|
||||
--var DANGEROUS_SALT="$DANGEROUS_SALT"
|
||||
--var SECRET_KEY="$SECRET_KEY"
|
||||
--var ADMIN_CLIENT_USERNAME="notify-admin"
|
||||
--var ADMIN_CLIENT_SECRET="$ADMIN_CLIENT_SECRET"
|
||||
--var ADMIN_CLIENT_USERNAME="$ADMIN_CLIENT_USERNAME"
|
||||
--var NEW_RELIC_LICENSE_KEY="$NEW_RELIC_LICENSE_KEY"
|
||||
--var NR_BROWSER_KEY="$NR_BROWSER_KEY"
|
||||
--var COMMIT_HASH="$COMMIT_HASH"
|
||||
--var LOGIN_PEM="$LOGIN_PEM"
|
||||
--var LOGIN_DOT_GOV_CLIENT_ID="$LOGIN_DOT_GOV_CLIENT_ID"
|
||||
--var LOGIN_DOT_GOV_USER_INFO_URL="$LOGIN_DOT_GOV_USER_INFO_URL"
|
||||
--var LOGIN_DOT_GOV_ACCESS_TOKEN_URL="$LOGIN_DOT_GOV_ACCESS_TOKEN_URL"
|
||||
@@ -95,13 +85,10 @@ jobs:
|
||||
--var LOGIN_DOT_GOV_BASE_LOGOUT_URL="$LOGIN_DOT_GOV_BASE_LOGOUT_URL"
|
||||
--var LOGIN_DOT_GOV_SIGNOUT_REDIRECT="$LOGIN_DOT_GOV_SIGNOUT_REDIRECT"
|
||||
--var LOGIN_DOT_GOV_INITIAL_SIGNIN_URL="$LOGIN_DOT_GOV_INITIAL_SIGNIN_URL"
|
||||
--var LOGIN_DOT_GOV_CERTS_URL="$LOGIN_DOT_GOV_CERTS_URL"
|
||||
--var LOGIN_PEM="$LOGIN_PEM"
|
||||
--strategy rolling
|
||||
|
||||
- name: Check for changes to egress config
|
||||
id: changed-egress-config
|
||||
uses: tj-actions/changed-files@v45
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files: |
|
||||
deploy-config/egress_proxy/notify-admin-production.*.acl
|
||||
@@ -110,10 +97,6 @@ jobs:
|
||||
- name: Deploy egress proxy
|
||||
if: steps.changed-egress-config.outputs.any_changed == 'true'
|
||||
uses: ./.github/actions/deploy-proxy
|
||||
env:
|
||||
CF_USERNAME: ${{ secrets.CLOUDGOV_USERNAME }}
|
||||
CF_PASSWORD: ${{ secrets.CLOUDGOV_PASSWORD }}
|
||||
with:
|
||||
cf_org: gsa-tts-benefits-studio
|
||||
cf_space: notify-production
|
||||
app: notify-admin-production
|
||||
|
||||
31
.github/workflows/deploy.yml
vendored
@@ -21,17 +21,9 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Check for changes to Terraform
|
||||
id: changed-terraform-files
|
||||
uses: tj-actions/changed-files@v45
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files: |
|
||||
terraform/staging/**
|
||||
@@ -61,12 +53,11 @@ jobs:
|
||||
|
||||
|
||||
- name: Deploy to cloud.gov
|
||||
uses: cloud-gov/cg-cli-tools@main
|
||||
uses: 18f/cg-deploy-action@main
|
||||
env:
|
||||
DANGEROUS_SALT: ${{ secrets.DANGEROUS_SALT }}
|
||||
SECRET_KEY: ${{ secrets.SECRET_KEY }}
|
||||
ADMIN_CLIENT_SECRET: ${{ secrets.ADMIN_CLIENT_SECRET }}
|
||||
ADMIN_CLIENT_USERNAME: "notify-admin"
|
||||
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
|
||||
NR_BROWSER_KEY: ${{ secrets.NR_BROWSER_KEY }}
|
||||
COMMIT_HASH: ${{ github.sha }}
|
||||
@@ -77,23 +68,22 @@ jobs:
|
||||
LOGIN_DOT_GOV_LOGOUT_URL: "https://secure.login.gov/openid_connect/logout?client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&post_logout_redirect_uri=https://notify-staging.app.cloud.gov/sign-out"
|
||||
LOGIN_DOT_GOV_BASE_LOGOUT_URL: "https://secure.login.gov/openid_connect/logout?"
|
||||
LOGIN_DOT_GOV_SIGNOUT_REDIRECT: "https://notify-staging.app.cloud.gov/sign-out"
|
||||
LOGIN_DOT_GOV_INITIAL_SIGNIN_URL: "https://secure.login.gov/openid_connect/authorize?acr_values=http%3A%2F%2Fidmanagement.gov%2Fns%2Fassurance%2Fial%2F1&client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&nonce=NONCE&prompt=select_account&redirect_uri=https://notify-staging.app.cloud.gov/sign-in&response_type=code&scope=openid+email&state=STATE"
|
||||
LOGIN_DOT_GOV_CERTS_URL: "https://secure.login.gov/api/openid_connect/certs"
|
||||
LOGIN_DOT_GOV_INITIAL_SIGNIN_URL: "https://secure.login.gov/openid_connect/authorize?acr_values=http%3A%2F%2Fidmanagement.gov%2Fns%2Fassurance%2Fial%2F1&client_id=urn:gov:gsa:openidconnect.profiles:sp:sso:gsa:notify-gov&nonce=NONCE&prompt=select_account&redirect_uri=https://notify-staging.app.cloud.gov/sign-in&response_type=code&scope=openid+email&state=STATEE"
|
||||
with:
|
||||
cf_username: ${{ secrets.CLOUDGOV_USERNAME }}
|
||||
cf_password: ${{ secrets.CLOUDGOV_PASSWORD }}
|
||||
cf_org: gsa-tts-benefits-studio
|
||||
cf_space: notify-staging
|
||||
cf_command: >-
|
||||
push -f manifest.yml
|
||||
push_arguments: >-
|
||||
--vars-file deploy-config/staging.yml
|
||||
--var DANGEROUS_SALT="$DANGEROUS_SALT"
|
||||
--var SECRET_KEY="$SECRET_KEY"
|
||||
--var ADMIN_CLIENT_USERNAME="notify-admin"
|
||||
--var ADMIN_CLIENT_SECRET="$ADMIN_CLIENT_SECRET"
|
||||
--var ADMIN_CLIENT_USERNAME="$ADMIN_CLIENT_USERNAME"
|
||||
--var NEW_RELIC_LICENSE_KEY="$NEW_RELIC_LICENSE_KEY"
|
||||
--var NR_BROWSER_KEY="$NR_BROWSER_KEY"
|
||||
--var COMMIT_HASH="$COMMIT_HASH"
|
||||
--var LOGIN_PEM="$LOGIN_PEM"
|
||||
--var LOGIN_DOT_GOV_CLIENT_ID="$LOGIN_DOT_GOV_CLIENT_ID"
|
||||
--var LOGIN_DOT_GOV_USER_INFO_URL="$LOGIN_DOT_GOV_USER_INFO_URL"
|
||||
--var LOGIN_DOT_GOV_ACCESS_TOKEN_URL="$LOGIN_DOT_GOV_ACCESS_TOKEN_URL"
|
||||
@@ -101,14 +91,11 @@ jobs:
|
||||
--var LOGIN_DOT_GOV_BASE_LOGOUT_URL="$LOGIN_DOT_GOV_BASE_LOGOUT_URL"
|
||||
--var LOGIN_DOT_GOV_SIGNOUT_REDIRECT="$LOGIN_DOT_GOV_SIGNOUT_REDIRECT"
|
||||
--var LOGIN_DOT_GOV_INITIAL_SIGNIN_URL="$LOGIN_DOT_GOV_INITIAL_SIGNIN_URL"
|
||||
--var LOGIN_DOT_GOV_CERTS_URL="$LOGIN_DOT_GOV_CERTS_URL"
|
||||
--var LOGIN_PEM="$LOGIN_PEM"
|
||||
--strategy rolling
|
||||
|
||||
|
||||
- name: Check for changes to egress config
|
||||
id: changed-egress-config
|
||||
uses: tj-actions/changed-files@v45
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files: |
|
||||
deploy-config/egress_proxy/notify-admin-staging.*.acl
|
||||
@@ -117,11 +104,7 @@ jobs:
|
||||
- name: Deploy egress proxy
|
||||
if: steps.changed-egress-config.outputs.any_changed == 'true'
|
||||
uses: ./.github/actions/deploy-proxy
|
||||
env:
|
||||
CF_USERNAME: ${{ secrets.CLOUDGOV_USERNAME }}
|
||||
CF_PASSWORD: ${{ secrets.CLOUDGOV_PASSWORD }}
|
||||
with:
|
||||
cf_org: gsa-tts-benefits-studio
|
||||
cf_space: notify-staging
|
||||
app: notify-admin-staging
|
||||
|
||||
|
||||
24
.github/workflows/drift.yml
vendored
@@ -15,14 +15,6 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Check for drift
|
||||
uses: dflook/terraform-check@v1
|
||||
env:
|
||||
@@ -43,14 +35,6 @@ jobs:
|
||||
with:
|
||||
ref: 'production'
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Check for drift
|
||||
uses: dflook/terraform-check@v1
|
||||
env:
|
||||
@@ -71,14 +55,6 @@ jobs:
|
||||
with:
|
||||
ref: 'production'
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Check for drift
|
||||
uses: dflook/terraform-check@v1
|
||||
env:
|
||||
|
||||
10
.github/workflows/terraform-demo.yml
vendored
@@ -18,14 +18,6 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Terraform format
|
||||
id: format
|
||||
run: terraform fmt -check
|
||||
@@ -59,7 +51,7 @@ jobs:
|
||||
|
||||
# inspiration: https://learn.hashicorp.com/tutorials/terraform/github-actions#review-actions-workflow
|
||||
- name: Update PR
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@v6
|
||||
# we would like to update the PR even when a prior step failed
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
|
||||
10
.github/workflows/terraform-production.yml
vendored
@@ -18,14 +18,6 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Terraform format
|
||||
id: format
|
||||
run: terraform fmt -check
|
||||
@@ -59,7 +51,7 @@ jobs:
|
||||
|
||||
# inspiration: https://learn.hashicorp.com/tutorials/terraform/github-actions#review-actions-workflow
|
||||
- name: Update PR
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@v6
|
||||
# we would like to update the PR even when a prior step failed
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
|
||||
10
.github/workflows/terraform-staging.yml
vendored
@@ -18,14 +18,6 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Looks like we need to install Terraform ourselves now!
|
||||
# https://github.com/actions/runner-images/issues/10796#issuecomment-2417064348
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: "^1.7.5"
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Terraform format
|
||||
id: format
|
||||
run: terraform fmt -check
|
||||
@@ -59,7 +51,7 @@ jobs:
|
||||
|
||||
# inspiration: https://learn.hashicorp.com/tutorials/terraform/github-actions#review-actions-workflow
|
||||
- name: Update PR
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@v6
|
||||
# we would like to update the PR even when a prior step failed
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
|
||||
10
.gitignore
vendored
@@ -14,11 +14,6 @@
|
||||
*.XLSX
|
||||
|
||||
## Non user files allowed to be commited
|
||||
!app/assets/pdf/tcpa_overview.pdf
|
||||
!app/assets/pdf/investing-notifications-tts-public-benefits-memo.pdf
|
||||
!app/assets/pdf/out-of-pilot-announcement.pdf
|
||||
!app/assets/pdf/studio-research-snapshot-2022-07-external.pdf
|
||||
!app/assets/pdf/TCPA-Overview.pdf
|
||||
!tests/test_pdf_files/no_eof_marker.pdf
|
||||
!tests/test_pdf_files/multi_page_pdf.pdf
|
||||
!tests/test_pdf_files/big.pdf
|
||||
@@ -139,8 +134,3 @@ playwright/
|
||||
|
||||
# Nodenv
|
||||
.node-version
|
||||
|
||||
# BackstopJS
|
||||
backstop_data/bitmaps_test/
|
||||
backstop_data/html_report/
|
||||
backstop_data/engine_scripts/playwright/
|
||||
|
||||
5
.pa11yci
@@ -1,10 +1,7 @@
|
||||
{
|
||||
"defaults": {
|
||||
"standard": "WCAG2AA",
|
||||
"runners": ["htmlcs"],
|
||||
"chromeLaunchConfig": {
|
||||
"executablePath": "/usr/bin/google-chrome"
|
||||
},
|
||||
"runners": ["htmlcs"],
|
||||
"concurrency": 1,
|
||||
"hideElements": [
|
||||
"nav > ol a",
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"singleQuote": true
|
||||
}
|
||||
15
Makefile
@@ -15,6 +15,7 @@ NVMSH := $(shell [ -f "$(HOME)/.nvm/nvm.sh" ] && echo "$(HOME)/.nvm/nvm.sh" || e
|
||||
|
||||
.PHONY: bootstrap
|
||||
bootstrap: generate-version-file ## Set up everything to run the app
|
||||
poetry self update
|
||||
poetry self add poetry-dotenv-plugin
|
||||
poetry lock --no-update
|
||||
poetry install --sync --no-root
|
||||
@@ -62,13 +63,6 @@ py-lint: ## Run python linting scanners and black
|
||||
poetry run flake8 .
|
||||
poetry run isort --check-only ./app ./tests
|
||||
|
||||
.PHONY: tada
|
||||
tada: ## Run python linting scanners and black
|
||||
poetry run isort ./app ./tests
|
||||
poetry run black .
|
||||
poetry run flake8 .
|
||||
|
||||
|
||||
.PHONY: avg-complexity
|
||||
avg-complexity:
|
||||
echo "*** Shows average complexity in radon of all code ***"
|
||||
@@ -94,7 +88,7 @@ dead-code: ## 60% is our aspirational goal, but currently breaks the build
|
||||
.PHONY: e2e-test
|
||||
e2e-test: export NEW_RELIC_ENVIRONMENT=test
|
||||
e2e-test: ## Run end-to-end integration tests; note that --browser webkit isn't currently working
|
||||
DEBUG=pw:api,pw:browser poetry run pytest -vv --browser chromium --browser firefox tests/end_to_end
|
||||
poetry run pytest -vv --browser chromium --browser firefox tests/end_to_end
|
||||
|
||||
.PHONY: js-lint
|
||||
js-lint: ## Run javascript linting scanners
|
||||
@@ -162,8 +156,3 @@ upload-static:
|
||||
# @cf map-route notify-admin ${DNS_NAME} --hostname www
|
||||
# @cf unmap-route notify-admin-failwhale ${DNS_NAME} --hostname www
|
||||
# @echo "Failwhale is disabled"
|
||||
|
||||
.PHONY: test-single
|
||||
test-single: export NEW_RELIC_ENVIRONMENT=test
|
||||
test-single: ## Run a single test file
|
||||
poetry run pytest $(TEST_FILE)
|
||||
|
||||
20
README.md
@@ -372,9 +372,15 @@ After you have completed all setup steps, you will be unable to log in, because
|
||||
will not be a user in the database to link to the login.gov account you are using. So
|
||||
you will need to create that user in your database using the 'create-test-user' command.
|
||||
|
||||
Open a terminal pointing to the api project and then run this command.
|
||||
Open two terminals pointing to the api project and then run these commands in the
|
||||
respective terminals.
|
||||
|
||||
```poetry run flask command create-test-user --admin=True```
|
||||
(Server 1)
|
||||
env ALLOW_EXPIRED_API_TOKEN=1 make run-flask
|
||||
|
||||
(Server 2)
|
||||
poetry run flask command create-admin-jwt | tail -n 1 | pbcopy
|
||||
poetry run flask command create-test-user --admin=True;
|
||||
|
||||
Supply your name, email address, mobile number, and password when prompted. Make sure the email address
|
||||
is the same one you are using in login.gov and make sure your phone number is in the format 5555555555.
|
||||
@@ -501,13 +507,3 @@ insurance.
|
||||
For more information on what we're working on, the Notify tool, and how to get
|
||||
involved with our team,
|
||||
[see our flyer.](https://github.com/GSA/notifications-admin/blob/main/docs/notify-pilot-flyer.md)
|
||||
|
||||
## Updating secrets for the E2E tests
|
||||
|
||||
At some point, E2E tests will fail because the secrets held in VCAP_SERVICES have expired. To refresh
|
||||
them, you will need to do the following:
|
||||
|
||||
1. Log in the normal way to access cloudfoundry command line options
|
||||
2. In your terminal, run `chmod +x print_vcap.sh`
|
||||
3. In your terminal, run `./print_vcap.sh`
|
||||
4. Copy the value in your terminal and paste it into the VCAP_SERVICES secret in Github on the staging tier.
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Contact: mailto:notify-support@gsa.gov
|
||||
Expires: 2035-10-15T23:59:59Z
|
||||
@@ -1,10 +1,8 @@
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import secrets
|
||||
from functools import partial
|
||||
from time import monotonic
|
||||
from urllib.parse import unquote, urlparse, urlunparse
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
|
||||
import jinja2
|
||||
from flask import (
|
||||
@@ -20,6 +18,7 @@ from flask import (
|
||||
)
|
||||
from flask.globals import request_ctx
|
||||
from flask_login import LoginManager, current_user
|
||||
from flask_socketio import SocketIO
|
||||
from flask_talisman import Talisman
|
||||
from flask_wtf import CSRFProtect
|
||||
from flask_wtf.csrf import CSRFError
|
||||
@@ -116,11 +115,12 @@ from notifications_utils.formatters import (
|
||||
get_lines_with_normalised_whitespace,
|
||||
)
|
||||
from notifications_utils.recipients import format_phone_number_human_readable
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
|
||||
login_manager = LoginManager()
|
||||
csrf = CSRFProtect()
|
||||
talisman = Talisman()
|
||||
socketio = SocketIO()
|
||||
|
||||
|
||||
# The current service attached to the request stack.
|
||||
current_service = LocalProxy(partial(getattr, request_ctx, "service"))
|
||||
@@ -142,10 +142,6 @@ def _csp(config):
|
||||
logo_domain = config["LOGO_CDN_DOMAIN"]
|
||||
return {
|
||||
"default-src": ["'self'", asset_domain],
|
||||
"frame-src": [
|
||||
"https://www.youtube.com",
|
||||
"https://www.youtube-nocookie.com",
|
||||
],
|
||||
"frame-ancestors": "'none'",
|
||||
"form-action": "'self'",
|
||||
"script-src": [
|
||||
@@ -169,41 +165,6 @@ def _csp(config):
|
||||
|
||||
|
||||
def create_app(application):
|
||||
@application.context_processor
|
||||
def inject_feature_flags():
|
||||
feature_about_page_enabled = application.config.get(
|
||||
"FEATURE_ABOUT_PAGE_ENABLED", False
|
||||
)
|
||||
return dict(
|
||||
FEATURE_ABOUT_PAGE_ENABLED=feature_about_page_enabled,
|
||||
)
|
||||
|
||||
@application.context_processor
|
||||
def inject_initial_signin_url():
|
||||
ttl = 24 * 60 * 60
|
||||
|
||||
# make and store the state
|
||||
state = generate_token(
|
||||
str(request.remote_addr),
|
||||
current_app.config["SECRET_KEY"],
|
||||
current_app.config["DANGEROUS_SALT"],
|
||||
)
|
||||
|
||||
state_key = f"login-state-{unquote(state)}"
|
||||
redis_client.set(state_key, state, ex=ttl)
|
||||
|
||||
# make and store the nonce
|
||||
nonce = secrets.token_urlsafe()
|
||||
nonce_key = f"login-nonce-{unquote(nonce)}"
|
||||
redis_client.set(nonce_key, nonce, ex=ttl)
|
||||
|
||||
url = os.getenv("LOGIN_DOT_GOV_INITIAL_SIGNIN_URL")
|
||||
if url is not None:
|
||||
url = url.replace("NONCE", nonce)
|
||||
url = url.replace("STATE", state)
|
||||
|
||||
return {"initial_signin_url": url}
|
||||
|
||||
notify_environment = os.environ["NOTIFY_ENVIRONMENT"]
|
||||
|
||||
application.config.from_object(configs[notify_environment])
|
||||
@@ -216,6 +177,7 @@ def create_app(application):
|
||||
|
||||
init_govuk_frontend(application)
|
||||
init_jinja(application)
|
||||
socketio.init_app(application, cors_allowed_origins=['http://localhost:6012'])
|
||||
|
||||
for client in (
|
||||
csrf,
|
||||
@@ -617,8 +579,6 @@ def setup_event_handlers():
|
||||
|
||||
|
||||
def add_template_filters(application):
|
||||
application.add_template_filter(slugify)
|
||||
|
||||
for fn in [
|
||||
format_auth_type,
|
||||
format_billions,
|
||||
@@ -676,10 +636,3 @@ def init_jinja(application):
|
||||
]
|
||||
jinja_loader = jinja2.FileSystemLoader(template_folders)
|
||||
application.jinja_loader = jinja_loader
|
||||
|
||||
|
||||
def slugify(text):
|
||||
"""
|
||||
Converts text to lowercase, replaces spaces with hyphens, and removes invalid characters.
|
||||
"""
|
||||
return re.sub(r'[^a-z0-9-]', '', re.sub(r'\s+', '-', text.lower()))
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
href="/static/images/apple-touch-icon.png?a0f7e1b728a42016b247dc54ee40d055">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/images/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/static/images/favicon-16x16.png">
|
||||
<link rel="manifest" href="{{ asset_url('images/site.webmanifest') }}">
|
||||
<link rel="manifest" href="/static/images/site.webmanifest">
|
||||
|
||||
<link rel="stylesheet" media="screen" href="/static/stylesheets/main.css?d077f86473501ab244de0b30600536ee" />
|
||||
<link rel="stylesheet" media="print" href="/static/stylesheets/print.css?28010888ca5719dc83d7c2c80f6ed2b2" />
|
||||
@@ -68,8 +68,11 @@
|
||||
<p class="usa-body">
|
||||
Try again later.
|
||||
</p>
|
||||
<p>To report a problem you can email us at <a class="usa-link" href="mailto:notify-support@gsa.gov">notify-support@gsa.gov</a>.</p>
|
||||
<p>You can expect a response within one business day.</p>
|
||||
<p class="usa-body">
|
||||
You can check our <a class="usa-link"
|
||||
href="https://status.notifications.service.gov.uk/">system status</a> page to see if there are any known
|
||||
issues.<br />To report a problem, email <a
|
||||
href="mailto:gov-uk-notify-support@digital.cabinet-office.gov.uk">gov-uk-notify-support@digital.cabinet-office.gov.uk</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
Before Width: | Height: | Size: 5.2 KiB |
@@ -1 +0,0 @@
|
||||
<svg id="Capa_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g><g><g><path d="m377.64 347.666c-4.473 0-8.1 3.626-8.1 8.099s3.626 8.1 8.1 8.1c4.473 0 8.099-3.626 8.099-8.1s-3.626-8.099-8.099-8.099z"/><path d="m377.716 334.615c4.149 0 7.511-3.363 7.511-7.511v-67.172c0-4.148-3.362-7.511-7.511-7.511-4.148 0-7.511 3.363-7.511 7.511v67.172c0 4.148 3.362 7.511 7.511 7.511z"/><path d="m377.64 219.085c-7.974 0-15.716 1.011-23.105 2.912v-14.937c0-59.921-37.644-111.208-90.522-131.476 2.741-6.491 4.267-13.614 4.267-21.092 0-30.047-24.445-54.492-54.492-54.492s-54.491 24.445-54.491 54.491c0 7.469 1.522 14.586 4.256 21.071-16.063 6.135-30.994 15.219-44.006 26.957-3.081 2.778-3.325 7.528-.547 10.608 2.781 3.081 7.53 3.324 10.608.546 23.118-20.854 53.014-32.339 84.18-32.339 69.324 0 125.725 56.4 125.725 125.725v20.222c-32.217 14.573-54.688 47.021-54.688 84.618 0 11.997 2.288 23.47 6.45 34.005h-203.212v-138.845c0-24.475 7.036-48.196 20.346-68.599 2.267-3.474 1.288-8.128-2.187-10.394-3.474-2.266-8.129-1.288-10.394 2.186-14.907 22.851-22.787 49.41-22.787 76.807v143.829l-28.543 37.616c-1.903 2.506-2.952 5.62-2.952 8.768v27.183c0 7.996 6.505 14.501 14.501 14.501h94.92c-.468 3.102-.719 6.274-.719 9.504 0 35.036 28.504 63.541 63.541 63.541 35.036 0 63.541-28.504 63.541-63.541 0-3.232-.263-6.402-.735-9.504h29.487c4.149 0 7.511-3.363 7.511-7.511s-3.362-7.511-7.511-7.511h-249.514v-26.486l27.713-36.521h214.585c15.307 24.506 41.72 41.39 72.142 43.548v19.459h-29.946c-4.148 0-7.511 3.363-7.511 7.511s3.362 7.511 7.511 7.511h30.467c7.996 0 14.5-6.505 14.5-14.501v-20.125c47.261-4.255 84.425-44.082 84.425-92.431 0-51.178-41.636-92.814-92.814-92.814zm-127.992-148.137c-11.454-3.02-23.471-4.636-35.86-4.636-12.217 0-24.259 1.583-35.863 4.634-2.311-5.012-3.607-10.584-3.607-16.455 0-21.764 17.706-39.469 39.469-39.469s39.469 17.706 39.469 39.469c.002 5.873-1.295 11.445-3.608 16.457zm-83.427 368.007h95.144c.616 3.074.942 6.251.942 9.504 0 26.753-21.765 48.519-48.519 48.519s-48.519-21.766-48.519-48.519c.001-3.254.335-6.429.952-9.504zm211.419-49.263c-42.895 0-77.793-34.898-77.793-77.793s34.897-77.793 77.793-77.793 77.793 34.898 77.793 77.793c-.001 42.895-34.898 77.793-77.793 77.793z"/></g></g></g></svg>
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
@@ -1,17 +0,0 @@
|
||||
<svg width="48" height="49" viewBox="0 0 48 49" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_6378_116)">
|
||||
<path d="M13.3517 3.77441H4.3344C3.40346 3.80666 3.40421 5.14865 4.3344 5.18053H13.3516C14.2826 5.14828 14.2819 3.80629 13.3517 3.77441Z" fill="black"/>
|
||||
<path d="M15.8219 10.6309H5.94759C4.67037 10.6309 3.63135 11.6699 3.63135 12.9471V13.9669C3.63135 15.2441 4.67037 16.2832 5.94759 16.2832H15.8219C17.0991 16.2832 18.1381 15.2441 18.1381 13.9669V12.9471C18.1381 11.67 17.0991 10.6309 15.8219 10.6309ZM16.732 13.9669C16.732 14.4688 16.3238 14.877 15.8219 14.877H5.94759C5.4457 14.877 5.03746 14.4688 5.03746 13.9669V12.9471C5.03746 12.4452 5.4457 12.037 5.94759 12.037H15.8219C16.3238 12.037 16.732 12.4452 16.732 12.9471V13.9669Z" fill="black"/>
|
||||
<path d="M10.2759 20.161V23.0556C10.2759 24.3328 11.3149 25.3718 12.5921 25.3718H22.4664C23.7436 25.3718 24.7826 24.3328 24.7826 23.0556V20.161C24.7826 18.8838 23.7436 17.8447 22.4664 17.8447H12.5921C11.3149 17.8446 10.2759 18.8838 10.2759 20.161ZM23.3765 20.161V23.0556C23.3765 23.5575 22.9683 23.9657 22.4664 23.9657H12.5921C12.0902 23.9657 11.682 23.5575 11.682 23.0556V20.161C11.682 19.6591 12.0902 19.2508 12.5921 19.2508H22.4664C22.9683 19.2507 23.3765 19.6591 23.3765 20.161Z" fill="black"/>
|
||||
<path d="M3.63135 32.1435C3.63135 33.4207 4.67037 34.4597 5.94759 34.4597H15.8219C17.0991 34.4597 18.1381 33.4207 18.1381 32.1435V29.2489C18.1381 27.9716 17.0991 26.9326 15.8219 26.9326H5.94759C4.67037 26.9326 3.63135 27.9716 3.63135 29.2489V32.1435ZM5.03746 29.2489C5.03746 28.747 5.4457 28.3387 5.94759 28.3387H15.8219C16.3238 28.3387 16.732 28.747 16.732 29.2489V32.1435C16.732 32.6454 16.3238 33.0536 15.8219 33.0536H5.94759C5.4457 33.0536 5.03746 32.6454 5.03746 32.1435V29.2489Z" fill="black"/>
|
||||
<path d="M38.1102 19.9331C33.5406 19.9331 29.6852 23.0494 28.5583 27.2682V3.4397C28.5583 1.81976 27.2404 0.501953 25.6205 0.501953H2.93784C1.3179 0.501953 0 1.81986 0 3.4397V20.0432C0 20.4314 0.314688 20.7462 0.703056 20.7462C1.09142 20.7462 1.40611 20.4314 1.40611 20.0432V8.45258H27.1521V28.8182C23.2126 29.346 20.0003 32.203 18.9507 35.9537H5.77819C4.52478 35.9537 3.50497 36.9735 3.50497 38.227C3.50497 39.4805 4.52478 40.5002 5.77819 40.5002H18.7678C18.9094 41.2299 19.1315 41.9311 19.4245 42.5943H2.93784C2.09323 42.5943 1.40611 41.9072 1.40611 41.0626V23.6671C1.40611 23.2788 1.09142 22.964 0.703056 22.964C0.314688 22.964 0 23.2788 0 23.6671V41.0626C0 42.6825 1.3179 44.0004 2.93784 44.0004H20.1877C22.6379 47.9355 28.1585 49.6822 32.5122 47.6362L34.4133 48.4393C34.9706 48.5729 35.2962 48.357 35.39 47.7917V45.6731C37.0359 44.0629 38.0518 41.9709 38.2985 39.6981C39.9145 39.6673 41.5059 39.2395 42.9126 38.4563C43.7068 38.0141 43.0228 36.7855 42.2286 37.2278C39.8606 38.5633 36.8283 38.6501 34.3934 37.4377C34.2107 37.3484 33.9984 37.3426 33.8112 37.4218L32.5984 37.9342V36.5738C32.5984 36.3771 32.516 36.1895 32.3712 36.0564C26.7203 30.87 30.4316 21.3351 38.1102 21.3392C45.1057 21.3061 49.1324 29.5318 44.8031 35.021C44.2444 35.738 45.3535 36.6024 45.9122 35.8853C50.961 29.4838 46.2654 19.8946 38.1102 19.9331ZM1.40611 7.04647V3.4397C1.40611 2.59509 2.09323 1.90807 2.93784 1.90807H25.6205C26.4651 1.90807 27.1522 2.59519 27.1522 3.4397V7.04647H1.40611ZM5.77819 39.0941C4.62902 39.0477 4.6277 37.4068 5.77819 37.3598H18.6662C18.5935 37.9316 18.5709 38.5182 18.5987 39.0941H5.77819ZM31.1924 36.8756V38.9945C31.2862 39.5598 31.6118 39.7757 32.169 39.6421L34.0701 38.839C34.9717 39.2439 35.9161 39.5072 36.8914 39.6264C36.6543 41.6316 35.7171 43.4683 34.211 44.8537C34.0663 44.9869 33.9839 45.1745 33.9839 45.3712V46.7316L32.7711 46.2192C32.5838 46.1401 32.3715 46.1458 32.1888 46.2351C26.6793 49.009 19.9179 44.7879 19.9931 38.6138C19.993 34.0203 23.6664 30.2683 28.2304 30.14C28.3143 32.6748 29.3798 35.0983 31.1924 36.8756Z" fill="black"/>
|
||||
<path d="M40.2727 27.1796C41.2036 27.1473 41.2028 25.8053 40.2727 25.7734H35.9479C35.017 25.8057 35.0177 27.1477 35.9479 27.1796H40.2727Z" fill="black"/>
|
||||
<path d="M42.9383 29.1133H33.2819C32.351 29.1455 32.3517 30.4875 33.2819 30.5194H42.9383C43.8692 30.4871 43.8685 29.1452 42.9383 29.1133Z" fill="black"/>
|
||||
<path d="M35.9479 32.4531C35.017 32.4854 35.0177 33.8274 35.9479 33.8592H40.2727C41.2036 33.827 41.2028 32.485 40.2727 32.4531H35.9479Z" fill="black"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_6378_116">
|
||||
<rect width="48" height="48" fill="white" transform="translate(0 0.5)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 4.3 KiB |
@@ -1,22 +0,0 @@
|
||||
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_6311_9508)">
|
||||
<path d="M126.125 15.0417C127.161 15.0417 128 14.2022 128 13.1667V6.11825C128 2.74475 125.255 0 121.882 0H79.0155C75.6418 0 72.897 2.74475 72.897 6.11825V32.04C72.897 32.1707 72.8253 32.2905 72.71 32.3522L66.7345 35.552C65.5993 36.16 64.8943 37.3375 64.8943 38.625C64.8943 39.9125 65.5993 41.09 66.7345 41.698L72.71 44.8975C72.8255 44.9595 72.8973 45.079 72.8973 45.21V60.1317C72.8973 63.5055 75.642 66.25 79.0158 66.25H121.882C125.255 66.25 128 63.5052 128 60.1317V21.8333C128 20.7978 127.161 19.9583 126.125 19.9583C125.09 19.9583 124.25 20.7978 124.25 21.8333V60.1315C124.25 61.4375 123.188 62.4997 121.882 62.4997H79.0155C77.7095 62.4997 76.647 61.4373 76.647 60.1315V45.21C76.647 43.694 75.8168 42.3075 74.4803 41.5918L68.9398 38.625L74.4805 35.658C75.817 34.9422 76.6473 33.556 76.6473 32.04V6.11825C76.6473 4.81225 77.7098 3.75 79.0158 3.75H121.882C123.188 3.75 124.25 4.8125 124.25 6.11825V13.1665C124.25 14.2023 125.09 15.0417 126.125 15.0417Z" fill="black"/>
|
||||
<path d="M45 49.6535V46.1367C47.5645 45.614 49.5 43.3415 49.5 40.625C49.5 37.5233 46.9767 35 43.875 35H34.875C31.7733 35 29.25 37.5233 29.25 40.625C29.25 43.3415 31.1855 45.6142 33.75 46.1367V49.6535C14.6938 52.3915 0 68.8232 0 88.625C0 100.683 5.4325 111.92 14.9047 119.453C15.7153 120.098 16.8947 119.964 17.5392 119.153C18.184 118.342 18.0495 117.163 17.239 116.519C8.6665 109.701 3.75 99.5338 3.75 88.625C3.75 68.9813 19.7313 53 39.375 53C59.0187 53 75 68.9813 75 88.625C75 108.269 59.0187 124.25 39.375 124.25C34.1278 124.25 29.0715 123.131 24.3463 120.923C23.408 120.485 22.2922 120.89 21.8538 121.828C21.4153 122.766 21.8205 123.882 22.7588 124.32C27.9848 126.762 33.5752 128 39.375 128C61.0865 128 78.75 110.337 78.75 88.625C78.75 68.8232 64.0563 52.3915 45 49.6535ZM33 40.625C33 39.591 33.841 38.75 34.875 38.75H43.875C44.909 38.75 45.75 39.591 45.75 40.625C45.75 41.659 44.909 42.5 43.875 42.5H34.875C33.841 42.5 33 41.659 33 40.625ZM37.5 49.2957V46.25H41.25V49.2957C40.6285 49.2665 40.0037 49.25 39.375 49.25C38.7463 49.25 38.1215 49.2665 37.5 49.2957Z" fill="black"/>
|
||||
<path d="M71.25 88.625C71.25 71.049 56.951 56.75 39.375 56.75C21.799 56.75 7.5 71.049 7.5 88.625C7.5 106.201 21.799 120.5 39.375 120.5C56.951 120.5 71.25 106.201 71.25 88.625ZM11.25 88.625C11.25 73.1167 23.8667 60.5 39.375 60.5C54.8833 60.5 67.5 73.1167 67.5 88.625C67.5 104.133 54.8833 116.75 39.375 116.75C23.8667 116.75 11.25 104.133 11.25 88.625Z" fill="black"/>
|
||||
<path d="M114.771 35.4187C116.496 33.7365 117.106 31.268 116.361 28.9762C115.616 26.6845 113.672 25.0457 111.288 24.6992L108.759 24.3317C108.149 24.243 107.622 23.86 107.349 23.3072L106.219 21.0152C105.152 18.8542 102.993 17.5117 100.583 17.5117C98.1738 17.5117 96.0145 18.8542 94.9483 21.015L93.8175 23.3067C93.5448 23.8597 93.0175 24.243 92.4073 24.3317L89.879 24.6992C87.4945 25.0457 85.5508 26.6845 84.806 28.9762C84.0613 31.268 84.6705 33.7365 86.3958 35.4187L88.226 37.2032C88.6678 37.634 88.869 38.254 88.7648 38.862L88.3325 41.3825C87.9253 43.7575 88.8835 46.1122 90.8328 47.5285C91.9343 48.3287 93.2228 48.7352 94.52 48.7352C95.519 48.7352 96.523 48.4942 97.4508 48.0062L99.7123 46.817C100.258 46.5302 100.909 46.53 101.455 46.817L103.715 48.0055C105.848 49.1267 108.384 48.944 110.334 47.5277C112.284 46.1115 113.242 43.7562 112.834 41.381L112.402 38.862C112.298 38.254 112.5 37.634 112.941 37.2035L114.771 35.4187ZM112.153 32.7337L110.323 34.5182C108.998 35.8105 108.393 37.6715 108.706 39.4957L109.138 42.0147C109.305 42.9872 108.928 43.914 108.13 44.4937C107.332 45.0737 106.334 45.1457 105.46 44.6865L103.2 43.498C101.562 42.6365 99.6053 42.6367 97.9668 43.498L95.7053 44.6872C94.8323 45.1462 93.8348 45.0742 93.0368 44.4945C92.2388 43.9147 91.862 42.9885 92.0285 42.0162L92.4608 39.496C92.7738 37.6715 92.1693 35.8107 90.8438 34.5182L89.0135 32.7337C88.307 32.045 88.0673 31.0737 88.3723 30.1352C88.6773 29.197 89.442 28.5522 90.4183 28.4102L92.9465 28.0427C94.7785 27.7765 96.3613 26.6262 97.1803 24.9662L98.311 22.6745C98.7475 21.79 99.5968 21.262 100.583 21.262C101.57 21.262 102.419 21.79 102.855 22.6745L103.986 24.9665C104.805 26.6265 106.388 27.7765 108.22 28.0427L110.748 28.4102C111.725 28.5522 112.489 29.197 112.794 30.1352C113.099 31.0735 112.86 32.045 112.153 32.7337Z" fill="black"/>
|
||||
<path d="M39.375 69.328C40.4105 69.328 41.25 68.4885 41.25 67.453V66.625C41.25 65.5895 40.4105 64.75 39.375 64.75C38.3395 64.75 37.5 65.5895 37.5 66.625V67.453C37.5 68.4885 38.3395 69.328 39.375 69.328Z" fill="black"/>
|
||||
<path d="M41.25 110.625V109.797C41.25 108.761 40.4105 107.922 39.375 107.922C38.3395 107.922 37.5 108.761 37.5 109.797V110.625C37.5 111.66 38.3395 112.5 39.375 112.5C40.4105 112.5 41.25 111.66 41.25 110.625Z" fill="black"/>
|
||||
<path d="M55.6717 74.9795L56.2572 74.394C56.9895 73.6618 56.9895 72.4745 56.2572 71.7425C55.525 71.0103 54.3377 71.0103 53.6057 71.7425L53.0202 72.328C52.288 73.0603 52.2625 74.2738 53.0202 74.9795C53.802 75.708 55.0207 75.6248 55.6717 74.9795Z" fill="black"/>
|
||||
<path d="M23.0783 102.27L22.4928 102.855C21.7605 103.588 21.7605 104.775 22.4928 105.507C23.203 106.217 24.4155 106.236 25.1443 105.507L25.7298 104.921C26.462 104.189 26.462 103.002 25.7298 102.27C24.9978 101.538 23.8105 101.538 23.0783 102.27Z" fill="black"/>
|
||||
<path d="M60.5471 90.5H61.3751C62.4106 90.5 63.2501 89.6605 63.2501 88.625C63.2501 87.5895 62.4106 86.75 61.3751 86.75H60.5471C59.5116 86.75 58.6721 87.5895 58.6721 88.625C58.6721 89.6605 59.5116 90.5 60.5471 90.5Z" fill="black"/>
|
||||
<path d="M18.203 86.75H17.375C16.3395 86.75 15.5 87.5895 15.5 88.625C15.5 89.6605 16.3395 90.5 17.375 90.5H18.203C19.2385 90.5 20.078 89.6605 20.078 88.625C20.078 87.5895 19.2385 86.75 18.203 86.75Z" fill="black"/>
|
||||
<path d="M53.6054 105.507C54.3159 106.217 55.5276 106.236 56.2569 105.507C56.9891 104.775 56.9891 103.587 56.2569 102.855L55.6714 102.27C54.9391 101.538 53.7519 101.538 53.0199 102.27C52.2876 103.002 52.2876 104.189 53.0199 104.921L53.6054 105.507Z" fill="black"/>
|
||||
<path d="M25.1445 71.7425C24.4123 71.0103 23.225 71.0103 22.493 71.7425C21.7608 72.4748 21.7608 73.662 22.493 74.394C22.493 74.394 23.0778 74.9788 23.0785 74.9795C23.784 75.685 25.0075 75.702 25.73 74.9795C26.4623 74.2473 26.4623 73.06 25.73 72.328L25.1445 71.7425Z" fill="black"/>
|
||||
<path d="M42.5417 93.2714L49.2532 98.3992C49.593 98.6587 49.9932 98.7844 50.3902 98.7844C50.9545 98.7844 51.5125 98.5307 51.8815 98.0477C52.5102 97.2247 52.3527 96.0482 51.53 95.4194L44.7607 90.2474C44.9157 89.7337 45.0002 89.1892 45.0002 88.6254C45.0002 86.1809 43.4325 84.0969 41.2502 83.3229V74.9092C41.2502 73.8737 40.4107 73.0342 39.3752 73.0342C38.3397 73.0342 37.5002 73.8737 37.5002 74.9092V83.3229C35.318 84.0969 33.7502 86.1809 33.7502 88.6254C33.7502 91.7272 36.2735 94.2504 39.3752 94.2504C40.5487 94.2504 41.6392 93.8887 42.5417 93.2714ZM37.5 88.6254C37.5 87.5914 38.341 86.7504 39.375 86.7504C40.409 86.7504 41.25 87.5914 41.25 88.6254C41.25 89.6594 40.409 90.5004 39.375 90.5004C38.341 90.5004 37.5 89.6594 37.5 88.6254Z" fill="black"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_6311_9508">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 13.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="719px" height="720px" viewBox="0 0 129.996 130.238" enable-background="new 0 0 129.996 130.238"
|
||||
xml:space="preserve">
|
||||
<rect fill="#00538E" width="129.996" height="130.238"/>
|
||||
<path fill="#FFFFFF" d="M78.611,96.076c0,9.138-7.175,12.953-15.451,12.688c-2.938-0.095-5.799-0.838-8.916-1.855l0.707-6.578
|
||||
c2.638,1.086,6.057,2.263,8.92,2.219c3.74-0.058,7.477-1.794,7.477-6.124c0-3.335-2.67-4.976-5.252-6.283
|
||||
c-5.709-2.896-12.275-4.907-12.275-12.998c0-7.65,6.084-11.64,13.625-11.64c2.741,0,6.014,0.477,9.299,1.641l-0.985,6.478
|
||||
c-3.577-1.403-5.14-1.901-8.078-1.901c-3.253,0-6.597,1.143-6.597,4.896c0,2.933,3.01,4.456,5.248,5.573
|
||||
C72.398,85.218,78.611,87.703,78.611,96.076"/>
|
||||
<path fill="#FFFFFF" d="M44.561,106.8c-2.632,0.901-6.662,1.964-13.092,1.964c-13.195,0-22.027-8.529-22.027-21.805
|
||||
c0-12.882,9.375-21.455,22.086-21.455c6.036,0,8.727,0.896,12.541,2.212l-0.574,7.216c-3.51-2.294-6.498-3.211-11.674-3.211
|
||||
c-9.09,0-15.158,6.578-15.115,15.412c0.043,9.506,6.648,15.416,14.822,15.416c2.437,0,4.508-0.178,5.996-0.569V91.15h-7.861v-6.103
|
||||
h14.898V106.8"/>
|
||||
<polyline fill="#FFFFFF" points="102.041,64.587 112.063,86.918 105.08,86.918 102.041,79.497 98.996,86.918 92.014,86.918
|
||||
102.041,64.587 "/>
|
||||
<polyline fill="#FFFFFF" points="112.178,87.179 121.507,108.029 114.176,108.029 107.203,91.839 112.178,87.179 "/>
|
||||
<polyline fill="#FFFFFF" points="91.9,87.183 96.873,91.841 93.199,100.24 102.027,95.611 107.109,99.525 89.727,108.031
|
||||
82.57,108.031 91.9,87.183 "/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
@@ -1,10 +0,0 @@
|
||||
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M117.375 5.82422H27.1625C26.127 5.82422 25.2875 6.66347 25.2875 7.69922C25.2875 8.73497 26.127 9.57422 27.1625 9.57422H117.375C121.166 9.57422 124.25 12.6582 124.25 16.4492V29.1212H3.75V16.4492C3.75 12.6585 6.834 9.57422 10.625 9.57422H18.4125C19.448 9.57422 20.2875 8.73497 20.2875 7.69922C20.2875 6.66347 19.448 5.82422 18.4125 5.82422H10.625C4.76625 5.82422 0 10.5905 0 16.4492V107.668C0 113.527 4.76625 118.293 10.625 118.293H48.4953C53.1185 120.77 58.3983 122.176 64 122.176C69.6018 122.176 74.8815 120.77 79.5048 118.293H117.375C123.234 118.293 128 113.527 128 107.668V16.4492C128 10.5905 123.234 5.82422 117.375 5.82422ZM37.2557 77.5242H47.687C47.0868 80.5977 46.7183 83.9017 46.6203 87.3632H34.8717C35.0877 83.9435 35.8947 80.6245 37.2557 77.5242ZM73.674 116.778C76.1003 113.758 78.0847 109.612 79.4355 104.702H88.7452C85.26 110.259 79.956 114.565 73.674 116.778ZM73.3053 68.1122C74.1665 69.8347 74.909 71.7352 75.5245 73.774H65.875V60.3527C68.5888 61.2235 71.2215 63.945 73.3053 68.1122ZM76.4805 77.5242C77.1335 80.613 77.5238 83.9302 77.628 87.3632H65.875V77.5242H76.4805ZM77.6277 91.1132C77.5235 94.5462 77.1332 97.8635 76.4802 100.952H65.875V91.1132H77.6277ZM75.5242 104.702C74.9087 106.741 74.1663 108.642 73.305 110.364C71.2215 114.531 68.5887 117.253 65.8747 118.124V104.702H75.5242ZM62.125 100.952H51.5195C50.8665 97.8637 50.4763 94.5465 50.372 91.1135H62.125V100.952ZM62.125 104.702V118.124C59.4113 117.253 56.7785 114.531 54.6948 110.364C53.8335 108.642 53.0913 106.741 52.4757 104.702H62.125ZM90.733 100.952H80.313C80.9133 97.879 81.2818 94.575 81.3798 91.1135H93.128C92.9062 94.5922 92.0723 97.9077 90.733 100.952ZM81.3798 87.3632C81.2818 83.9015 80.9135 80.5977 80.313 77.5242H90.733C92.0725 80.569 92.9062 83.8842 93.128 87.3632H81.3798ZM79.4355 73.7742C78.0847 68.8642 76.1003 64.7182 73.674 61.6985C79.956 63.9117 85.26 68.2172 88.7452 73.7742H79.4355ZM62.125 60.353V73.7742H52.4757C53.0913 71.7355 53.8338 69.8347 54.6948 68.1125C56.7785 63.945 59.4113 61.2235 62.125 60.353ZM62.125 77.5242V87.3632H50.3722C50.4765 83.9302 50.8667 80.613 51.5197 77.5242H62.125ZM46.6203 91.1132C46.7183 94.575 47.0865 97.8787 47.687 100.952H37.267C35.9277 97.9075 35.0938 94.5922 34.872 91.1132H46.6203ZM48.5645 104.702C49.9152 109.612 51.8997 113.758 54.326 116.778C48.044 114.565 42.74 110.259 39.2547 104.702H48.5645ZM124.25 107.668C124.25 111.459 121.166 114.543 117.375 114.543H85.0622C92.3148 108.496 96.9375 99.397 96.9375 89.2382C96.9375 71.1897 82.282 56.3007 64 56.3007C56.5457 56.3007 49.2417 58.8607 43.4333 63.5095C42.6248 64.1565 42.494 65.3365 43.141 66.145C43.7878 66.9532 44.968 67.0847 45.7765 66.4372C48.3908 64.345 51.276 62.7467 54.347 61.6722C51.9113 64.694 49.9193 68.8497 48.5645 73.774H39.2405C39.506 73.35 39.783 72.932 40.0715 72.5197C40.6652 71.6712 40.4592 70.5022 39.6107 69.9085C38.7625 69.3142 37.5933 69.5202 36.9995 70.369C33.1152 75.917 31.0623 82.442 31.0623 89.2382C31.0623 99.397 35.6852 108.496 42.9375 114.543H10.625C6.834 114.543 3.75 111.459 3.75 107.668V48.4022H78.2968C79.3325 48.4022 80.1718 47.563 80.1718 46.5272C80.1718 45.4915 79.3325 44.6522 78.2968 44.6522H3.75V32.871H124.25V36.8865H104.122C102.787 36.8865 101.531 37.4065 100.587 38.3507L94.6523 44.2855C94.4157 44.5217 94.1017 44.652 93.768 44.652H87.2968C86.261 44.652 85.4218 45.4912 85.4218 46.527C85.4218 47.5627 86.261 48.402 87.2968 48.402H93.768C95.1032 48.402 96.3585 47.882 97.3037 46.9377L103.239 41.0027C103.475 40.7667 103.788 40.6365 104.122 40.6365H124.25V107.668Z" fill="black"/>
|
||||
<path d="M120.234 19.3476C120.234 16.1728 117.651 13.5898 114.477 13.5898C111.302 13.5898 108.719 16.1728 108.719 19.3476C108.719 22.5223 111.302 25.1053 114.477 25.1053C117.651 25.1053 120.234 22.5223 120.234 19.3476ZM112.469 19.3476C112.469 18.2403 113.369 17.3398 114.476 17.3398C115.583 17.3398 116.484 18.2406 116.484 19.3476C116.484 20.4546 115.583 21.3553 114.476 21.3553C113.369 21.3553 112.469 20.4546 112.469 19.3476Z" fill="black"/>
|
||||
<path d="M104.703 19.3476C104.703 16.1728 102.12 13.5898 98.9453 13.5898C95.7705 13.5898 93.1875 16.1726 93.1875 19.3476C93.1875 22.5226 95.7705 25.1053 98.9453 25.1053C102.12 25.1053 104.703 22.5223 104.703 19.3476ZM96.9375 19.3476C96.9375 18.2403 97.8383 17.3398 98.9453 17.3398C100.052 17.3398 100.953 18.2406 100.953 19.3476C100.953 20.4546 100.052 21.3553 98.9453 21.3553C97.8383 21.3553 96.9375 20.4546 96.9375 19.3476Z" fill="black"/>
|
||||
<path d="M89.172 19.3476C89.172 16.1728 86.589 13.5898 83.4142 13.5898C80.2395 13.5898 77.6565 16.1728 77.6565 19.3476C77.6565 22.5223 80.2395 25.1053 83.4142 25.1053C86.589 25.1053 89.172 22.5223 89.172 19.3476ZM81.4062 19.3476C81.4062 18.2403 82.307 17.3398 83.414 17.3398C84.521 17.3398 85.4217 18.2406 85.4217 19.3476C85.4217 20.4546 84.521 21.3553 83.414 21.3553C82.307 21.3553 81.4062 20.4546 81.4062 19.3476Z" fill="black"/>
|
||||
<path d="M7.76538 17.3398V21.3553C7.76538 23.4231 9.44763 25.1053 11.5154 25.1053H38.8279C40.8956 25.1053 42.5779 23.4231 42.5779 21.3553V17.3398C42.5779 15.2721 40.8956 13.5898 38.8279 13.5898H11.5154C9.44788 13.5898 7.76538 15.2721 7.76538 17.3398ZM38.8304 21.3556H11.5154V17.3398H38.8279L38.8304 21.3556Z" fill="black"/>
|
||||
<path d="M93.0546 38.7617C93.0546 37.726 92.2154 36.8867 91.1796 36.8867H25.1716C24.1361 36.8867 23.2966 37.726 23.2966 38.7617C23.2966 39.7975 24.1361 40.6367 25.1716 40.6367H91.1794C92.2151 40.6367 93.0546 39.7972 93.0546 38.7617Z" fill="black"/>
|
||||
<path d="M17.4062 40.6367C18.4418 40.6367 19.2812 39.7973 19.2812 38.7617C19.2812 37.7262 18.4418 36.8867 17.4062 36.8867C16.3707 36.8867 15.5312 37.7262 15.5312 38.7617C15.5312 39.7973 16.3707 40.6367 17.4062 40.6367Z" fill="black"/>
|
||||
<path d="M9.64038 40.6367C10.6759 40.6367 11.5154 39.7973 11.5154 38.7617C11.5154 37.7262 10.6759 36.8867 9.64038 36.8867C8.60485 36.8867 7.76538 37.7262 7.76538 38.7617C7.76538 39.7973 8.60485 40.6367 9.64038 40.6367Z" fill="black"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 5.8 KiB |
@@ -1,3 +0,0 @@
|
||||
<svg viewBox="0 0 563 670" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M553.831 334.751V335.974L555.03 335.731C555.104 335.716 555.181 335.708 555.262 335.708H557.846C558.483 335.708 559 336.224 559 336.862V418.708C559 419.345 558.483 419.862 557.846 419.862H555.262C555.181 419.862 555.104 419.853 555.03 419.838L553.831 419.595V420.818V955.446C553.831 970.12 547.528 991.015 535.312 1008.3C522.978 1025.76 503.794 1040.6 477.723 1040.6H82.2769C56.206 1040.6 37.022 1025.76 24.6885 1008.3C12.472 991.015 6.16923 970.12 6.16923 955.446V420.818V419.595L4.97026 419.838C4.89621 419.853 4.8188 419.862 4.73846 419.862H2.15385C1.51659 419.862 1 419.345 1 418.708V358.4C1 357.763 1.51659 357.246 2.15385 357.246H4.73846C4.8188 357.246 4.89621 357.254 4.97026 357.269L6.16923 357.513V356.289V347.588V346.364L4.97026 346.608C4.89621 346.623 4.8188 346.631 4.73846 346.631H2.15385C1.51659 346.631 1 346.114 1 345.477V285.169C1 284.532 1.51659 284.015 2.15385 284.015H4.73846C4.8188 284.015 4.89621 284.023 4.97026 284.038L6.16923 284.282V283.058V261.434V260.21L4.97026 260.454C4.89621 260.469 4.8188 260.477 4.73846 260.477H2.15385C1.51659 260.477 1 259.96 1 259.323V220.554C1 219.917 1.51659 219.4 2.15385 219.4H4.73846C4.8188 219.4 4.89624 219.408 4.97036 219.423L6.16923 219.666V218.443V86.1538C6.16923 71.4804 12.472 50.5848 24.6885 33.2974C37.022 15.8443 56.206 1 82.2769 1H477.723C503.794 1 522.978 15.8443 535.312 33.2974C547.528 50.5848 553.831 71.4804 553.831 86.1538V334.751ZM400.615 16.2308H399.615V17.2308V43.0769C399.615 49.6619 394.277 55 387.692 55H172.308C165.723 55 160.385 49.6619 160.385 43.0769V17.2308V16.2308H159.385H82.2769C62.6883 16.2308 47.6257 27.2304 37.1269 42.0872C26.5125 57.1076 21.4 74.9813 21.4 86.1538V955.446C21.4 966.619 26.5125 984.492 37.1269 999.513C47.6257 1014.37 62.6883 1025.37 82.2769 1025.37H477.723C497.312 1025.37 512.374 1014.37 522.873 999.513C533.487 984.492 538.6 966.619 538.6 955.446V86.1538C538.6 74.9813 533.488 57.1076 522.873 42.0872C512.374 27.2304 497.312 16.2308 477.723 16.2308H400.615Z" stroke="black" stroke-width="2"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
@@ -1,17 +0,0 @@
|
||||
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_6311_9575)">
|
||||
<path d="M13.1356 105.339H93.2878C94.3236 105.339 95.1628 104.5 95.1628 103.464C95.1628 102.428 94.3236 101.589 93.2878 101.589H13.1356C11.6753 101.589 10.4873 100.401 10.4873 98.9407V26.0474H44.2016C41.9081 29.6852 40.5788 33.9892 40.5788 38.5982V46.6989C37.1923 47.1732 34.5773 50.0874 34.5773 53.6027V86.9362C34.5773 90.7812 37.7053 93.9092 41.5503 93.9092H86.8113C90.6563 93.9092 93.7843 90.7812 93.7843 86.9362V53.6029C93.7843 50.0877 91.1693 47.1734 87.7826 46.6992V38.5984C87.7826 33.9892 86.4533 29.6854 84.1598 26.0477H119.138V98.9409C119.138 100.401 117.95 101.589 116.49 101.589H102.282C101.246 101.589 100.407 102.428 100.407 103.464C100.407 104.5 101.246 105.339 102.282 105.339H116.49C120.018 105.339 122.888 102.469 122.888 98.9409V14.1582C122.888 9.20744 118.86 5.17969 113.909 5.17969H38.9261C37.8903 5.17969 37.0511 6.01894 37.0511 7.05469C37.0511 8.09044 37.8903 8.92969 38.9261 8.92969H113.909C116.792 8.92969 119.138 11.2752 119.138 14.1582V22.2974H81.3611C81.3201 22.2974 81.2798 22.3009 81.2393 22.3034C76.9391 17.8034 70.8815 14.9962 64.1805 14.9962C57.4533 14.9962 51.3748 17.8257 47.0716 22.3564C46.9241 22.3192 10.4873 22.2972 10.4873 22.2972V14.1582C10.4873 11.2752 12.8328 8.92969 15.7158 8.92969H30.1583C31.1941 8.92969 32.0333 8.09044 32.0333 7.05469C32.0333 6.01894 31.1941 5.17969 30.1583 5.17969H15.7158C10.7651 5.17969 6.7373 9.20744 6.7373 14.1582V98.9409C6.7373 102.469 9.60755 105.339 13.1356 105.339ZM90.0343 53.6029V86.9364C90.0343 88.7134 88.5886 90.1594 86.8113 90.1594H41.5503C39.7733 90.1594 38.3273 88.7137 38.3273 86.9364V53.6029C38.3273 51.8259 39.7731 50.3799 41.5503 50.3799H86.8113C88.5886 50.3802 90.0343 51.8259 90.0343 53.6029ZM74.5733 46.6302H53.7881V38.5984C53.7881 32.8677 58.4501 28.2057 64.1805 28.2057C69.911 28.2057 74.5731 32.8677 74.5731 38.5984V46.6302H74.5733ZM64.1808 18.7464C75.1271 18.7464 84.0326 27.6519 84.0326 38.5982V46.6299H78.3233V38.5982C78.3233 30.7999 71.979 24.4554 64.1808 24.4554C56.3826 24.4554 50.0383 30.7999 50.0383 38.5982V46.6299H44.3291V38.5982C44.3288 27.6519 53.2346 18.7464 64.1808 18.7464Z" fill="black"/>
|
||||
<path d="M91.6201 17.4883C92.6558 17.4883 93.4951 16.649 93.4951 15.6133C93.4951 14.5775 92.6558 13.7383 91.6201 13.7383H89.5701C88.5343 13.7383 87.6951 14.5775 87.6951 15.6133C87.6951 16.649 88.5343 17.4883 89.5701 17.4883H91.6201Z" fill="black"/>
|
||||
<path d="M100.641 17.4883C101.676 17.4883 102.516 16.649 102.516 15.6133C102.516 14.5775 101.676 13.7383 100.641 13.7383H98.5906C97.5548 13.7383 96.7156 14.5775 96.7156 15.6133C96.7156 16.649 97.5548 17.4883 98.5906 17.4883H100.641Z" fill="black"/>
|
||||
<path d="M109.661 17.4883C110.697 17.4883 111.536 16.649 111.536 15.6133C111.536 14.5775 110.697 13.7383 109.661 13.7383H107.611C106.575 13.7383 105.736 14.5775 105.736 15.6133C105.736 16.649 106.575 17.4883 107.611 17.4883H109.661Z" fill="black"/>
|
||||
<path d="M126.125 113.899H105.969C105.146 110.921 102.414 108.728 99.1775 108.728C95.9412 108.728 93.2095 110.921 92.3863 113.899H35.6138C34.7905 110.921 32.0588 108.728 28.8228 108.728C25.5865 108.728 22.8547 110.921 22.0315 113.899H1.875C0.83925 113.899 0 114.738 0 115.774C0 116.81 0.83925 117.649 1.875 117.649H22.0315C22.8547 120.627 25.5865 122.82 28.8228 122.82C32.0588 122.82 34.7905 120.627 35.6138 117.649H92.3865C93.2097 120.627 95.9415 122.82 99.1777 122.82C102.414 122.82 105.146 120.627 105.969 117.649H126.125C127.161 117.649 128 116.81 128 115.774C128 114.738 127.161 113.899 126.125 113.899ZM28.8228 119.07C27.005 119.07 25.5263 117.591 25.5263 115.774C25.5263 113.956 27.005 112.477 28.8228 112.477C30.6402 112.477 32.119 113.956 32.119 115.774C32.119 117.591 30.6402 119.07 28.8228 119.07ZM99.1775 119.07C97.3597 119.07 95.881 117.591 95.881 115.774C95.881 113.956 97.3597 112.477 99.1775 112.477C100.995 112.477 102.474 113.956 102.474 115.774C102.474 117.591 100.995 119.07 99.1775 119.07Z" fill="black"/>
|
||||
<path d="M74.6482 63.1457C73.9162 62.4137 72.7289 62.4135 71.9967 63.146C71.2644 63.8782 71.2644 65.0655 71.9969 65.7975L76.4694 70.2697L71.9967 74.7422C71.2644 75.4747 71.2644 76.6617 71.9967 77.394C72.3629 77.76 72.8429 77.943 73.3227 77.943C73.8024 77.943 74.2824 77.76 74.6487 77.394L80.4469 71.5957C80.7984 71.244 80.9959 70.7672 80.9959 70.2697C80.9959 69.7722 80.7984 69.2957 80.4467 68.9437L74.6482 63.1457Z" fill="black"/>
|
||||
<path d="M51.8922 70.2697L56.3647 65.7974C57.0972 65.0652 57.0972 63.8779 56.365 63.1459C55.6327 62.4139 54.4455 62.4134 53.7135 63.1456L47.9152 68.9436C47.5635 69.2954 47.366 69.7722 47.366 70.2697C47.366 70.7672 47.5635 71.2436 47.915 71.5956L53.7132 77.3939C54.0795 77.7599 54.5595 77.9429 55.0392 77.9429C55.519 77.9429 55.999 77.7599 56.3652 77.3939C57.0975 76.6614 57.0975 75.4744 56.3652 74.7421L51.8922 70.2697Z" fill="black"/>
|
||||
<path d="M66.0639 62.6508C65.0587 62.4026 64.0422 63.0161 63.7937 64.0211L60.9274 75.6176C60.6792 76.6228 61.2927 77.6393 62.2977 77.8878C62.4487 77.9251 62.6002 77.9431 62.7492 77.9431C63.5912 77.9431 64.3569 77.3716 64.5679 76.5176L67.4342 64.9211C67.6824 63.9158 67.0689 62.8996 66.0639 62.6508Z" fill="black"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_6311_9575">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 5.2 KiB |
@@ -1,12 +0,0 @@
|
||||
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_6311_9539)">
|
||||
<path d="M107.26 81.0871C108.302 81.0871 109.145 80.2431 109.145 79.2021V61.7874C109.145 60.7464 108.302 59.9023 107.26 59.9023H103.538C102.497 59.9023 101.653 60.7464 101.653 61.7874C101.653 62.8285 102.497 63.6725 103.538 63.6725H105.375V79.2021C105.375 80.2431 106.219 81.0871 107.26 81.0871Z" fill="black"/>
|
||||
<path d="M105.03 95.3332C104.018 95.0871 102.999 95.7069 102.752 96.7186L97.7374 117.306C97.6188 117.793 97.2262 117.927 97.0625 117.963C96.8997 117.998 96.486 118.037 96.1776 117.642L59.5854 70.7809L122.95 13.8064L115.318 45.1362C115.072 46.1479 115.692 47.1676 116.703 47.4139C116.853 47.4503 117.003 47.4679 117.151 47.4679C118 47.4679 118.771 46.8901 118.981 46.0285L127.914 9.35889C128.13 8.46888 127.846 7.53061 127.173 6.91004C126.499 6.28972 125.541 6.08387 124.671 6.37267L34.2959 36.438C33.3079 36.7667 32.7735 37.8339 33.1023 38.8217C33.4308 39.8095 34.4985 40.3441 35.4858 40.0153L119.097 12.2011L56.5961 68.3984L5.56399 49.9696L27.7773 42.58C28.7653 42.2513 29.2997 41.1841 28.9709 40.1963C28.6424 39.2088 27.5755 38.6744 26.5874 39.0027L1.98209 47.1877C0.793983 47.5828 0.0163241 48.647 0.000238096 49.8989C-0.0153452 51.1506 0.735168 52.2342 1.91221 52.6592L37.0421 65.3453V98.9988C37.0421 100.55 37.8471 101.934 39.1953 102.701C39.8571 103.077 40.5798 103.265 41.3014 103.265C42.0504 103.265 42.7986 103.062 43.4772 102.659L51.7857 97.7167C52.6807 97.1843 52.9743 96.0276 52.4422 95.1328C51.9098 94.2378 50.7532 93.9442 49.8584 94.4763L41.5499 99.4185C41.3479 99.5386 41.1717 99.4871 41.0591 99.4233C40.9465 99.3592 40.8122 99.2335 40.8122 98.9988V66.7068L55.8657 72.1429L65.8687 84.9529L56.7635 90.3691C55.8685 90.9015 55.5749 92.0581 56.107 92.9529C56.4597 93.5456 57.0863 93.8746 57.729 93.8746C58.057 93.8746 58.3887 93.7891 58.6908 93.6094L68.2077 87.9484L93.2062 119.962C94.1045 121.113 95.4456 121.755 96.8595 121.755C97.1892 121.755 97.523 121.72 97.856 121.648C99.6162 121.27 100.974 119.948 101.401 118.198L106.416 97.6108C106.662 96.5994 106.042 95.5797 105.03 95.3332Z" fill="black"/>
|
||||
<path d="M126.484 72.7292C125.468 72.51 124.464 73.1573 124.244 74.1747C122.533 82.1121 115.391 87.873 107.26 87.873C97.6782 87.873 89.8825 80.0773 89.8825 70.495C89.8825 60.9128 97.6782 53.1171 107.26 53.1171C115.446 53.1171 122.599 58.9234 124.269 66.9232C124.482 67.9424 125.482 68.5969 126.5 68.3832C127.519 68.1703 128.173 67.1718 127.96 66.1526C125.927 56.4145 117.221 49.3467 107.261 49.3467C95.5995 49.3467 86.1125 58.8337 86.1125 70.4948C86.1125 82.1559 95.5995 91.6429 107.261 91.6429C112.123 91.6429 116.871 89.9511 120.63 86.8791C124.335 83.8517 126.927 79.6216 127.93 74.9685C128.149 73.9515 127.502 72.9484 126.484 72.7292Z" fill="black"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_6311_9539">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 101 KiB |
@@ -1 +0,0 @@
|
||||
<svg id="Capa_1" enable-background="new 0 0 512 512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><g><path d="m488.19 30.63h-48.55c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5h48.551c4.857 0 8.81 3.952 8.81 8.811v39.835h-482.001v-39.836c0-4.858 3.952-8.811 8.81-8.811h380.83c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-380.83c-13.129.001-23.81 10.683-23.81 23.811v403.12c0 13.129 10.681 23.811 23.81 23.811h69c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-69c-4.857 0-8.81-3.952-8.81-8.811v-348.285h482v348.285c0 4.858-3.952 8.811-8.81 8.811h-360.38c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5h360.38c13.129 0 23.81-10.682 23.81-23.811v-403.12c0-13.128-10.681-23.81-23.81-23.81z"/><path d="m185.41 134.28h-131.91c-7.444 0-13.5 6.056-13.5 13.5v66.13c0 7.444 6.056 13.5 13.5 13.5h405c7.444 0 13.5-6.056 13.5-13.5v-66.13c0-7.444-6.056-13.5-13.5-13.5h-238.09c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5h236.59v63.13h-321.142v-63.13h49.552c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5zm-64.552 78.13h-65.858v-63.13h65.858z"/><path d="m67.935 188.478 11.756 9.094c1.321 1.021 2.937 1.567 4.589 1.567.329 0 .66-.021.989-.065 1.986-.265 3.783-1.312 4.992-2.909l18.666-24.671c2.499-3.304 1.847-8.007-1.456-10.507-3.304-2.499-8.006-1.847-10.507 1.456l-14.092 18.626-5.76-4.456c-3.275-2.533-7.985-1.934-10.521 1.344-2.534 3.275-1.933 7.985 1.344 10.521z"/><path d="m153.684 180.845c0 4.143 3.357 7.5 7.5 7.5h72.66c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-72.66c-4.143 0-7.5 3.357-7.5 7.5z"/><path d="m431.671 188.345c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-162.823c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5z"/><path d="m53.504 441.366h404.992c7.444 0 13.5-6.056 13.5-13.5v-66.132c0-7.444-6.056-13.5-13.5-13.5h-404.992c-7.444 0-13.5 6.056-13.5 13.5v66.132c0 7.445 6.056 13.5 13.5 13.5zm403.492-15h-321.138v-63.132h321.138zm-401.992-63.132h65.854v63.132h-65.854z"/><path d="m98.342 394.8 6.604-6.604c2.929-2.93 2.929-7.678 0-10.607-2.93-2.928-7.678-2.928-10.607 0l-6.604 6.604-6.604-6.604c-2.93-2.928-7.678-2.928-10.607 0-2.929 2.93-2.929 7.678 0 10.607l6.604 6.604-6.604 6.604c-2.929 2.93-2.929 7.678 0 10.607 1.465 1.464 3.385 2.196 5.304 2.196s3.839-.732 5.304-2.196l6.604-6.604 6.604 6.604c1.465 1.464 3.385 2.196 5.304 2.196s3.839-.732 5.304-2.196c2.929-2.93 2.929-7.678 0-10.607z"/><path d="m161.184 402.3h72.66c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-72.66c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5z"/><path d="m268.848 402.3h162.823c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-162.823c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5z"/><path d="m458.496 241.257h-404.992c-7.444 0-13.5 6.056-13.5 13.5v66.132c0 7.444 6.056 13.5 13.5 13.5h404.992c7.444 0 13.5-6.056 13.5-13.5v-66.132c0-7.445-6.056-13.5-13.5-13.5zm-403.492 15h65.854v63.132h-65.854zm401.992 63.132h-321.138v-63.132h321.138z"/><path d="m107.471 269.506c-3.304-2.499-8.006-1.847-10.507 1.456l-14.092 18.626-5.76-4.456c-3.275-2.534-7.985-1.933-10.521 1.344-2.534 3.276-1.933 7.986 1.344 10.521l11.756 9.094c1.321 1.021 2.937 1.567 4.589 1.567.329 0 .66-.021.989-.065 1.986-.265 3.783-1.312 4.992-2.909l18.666-24.671c2.499-3.304 1.846-8.007-1.456-10.507z"/><path d="m359.011 295.322h72.66c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-72.66c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5z"/><path d="m161.184 295.322h162.823c4.143 0 7.5-3.357 7.5-7.5s-3.357-7.5-7.5-7.5h-162.823c-4.143 0-7.5 3.357-7.5 7.5s3.357 7.5 7.5 7.5z"/><g><circle cx="42.069" cy="69.954" r="7.5"/><circle cx="76.192" cy="69.954" r="7.5"/><circle cx="110.31" cy="69.954" r="7.5"/></g></g><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/><g/></svg>
|
||||
|
Before Width: | Height: | Size: 3.5 KiB |
@@ -1,12 +0,0 @@
|
||||
<svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_6311_9544)">
|
||||
<path d="M31.5182 96.3591C31.7232 97.3748 32.7129 98.0311 33.7269 97.8261C38.9609 96.7696 42.8322 94.7671 45.6829 92.5183C48.5337 94.7671 52.4049 96.7698 57.6389 97.8261C58.6529 98.0311 59.6429 97.3746 59.8477 96.3591C60.0524 95.3441 59.3957 94.3551 58.3807 94.1503C54.1179 93.2898 50.8949 91.7473 48.4574 89.9433C51.1487 87.0021 52.9734 83.4338 53.8114 79.8881H58.3314C59.3672 79.8881 60.2064 79.0486 60.2064 78.0131C60.2064 76.9776 59.3672 76.1381 58.3314 76.1381H47.5584V71.7363C47.5584 70.7008 46.7192 69.8613 45.6834 69.8613C44.6477 69.8613 43.8084 70.7008 43.8084 71.7363V76.1381H33.0344C31.9987 76.1381 31.1594 76.9776 31.1594 78.0131C31.1594 79.0486 31.9987 79.8881 33.0344 79.8881H37.5544C38.3907 83.4258 40.2092 86.9866 42.8907 89.9241C40.4537 91.7403 37.2347 93.2923 32.9852 94.1501C31.9699 94.3548 31.3132 95.3441 31.5182 96.3591ZM41.4162 79.8881H49.9329C49.3807 81.7618 48.1822 84.6693 45.6567 87.4271C43.1337 84.6718 41.9552 81.7671 41.4162 79.8881Z" fill="black"/>
|
||||
<path d="M82.3162 18.748C81.5372 18.748 80.839 19.23 80.5627 19.9585L71.3715 44.2103C71.0045 45.1785 71.492 46.261 72.4602 46.628C73.429 46.995 74.5112 46.5073 74.8782 45.5393L76.6965 40.7418C76.7585 40.748 76.8212 40.7513 76.885 40.7513H87.84C87.873 40.7513 87.905 40.748 87.9375 40.7463L89.754 45.539C90.1212 46.5075 91.2042 46.9945 92.172 46.6278C93.1402 46.2608 93.6277 45.1783 93.2607 44.21L84.0695 19.9583C83.7935 19.23 83.0955 18.748 82.3162 18.748ZM78.1142 37.0013L82.3162 25.9138L86.5182 37.0013H78.1142Z" fill="black"/>
|
||||
<path d="M11.7858 116.457H16.6226C18.1479 116.457 19.5237 117.42 20.0462 118.853L22.5182 125.628C23.0439 127.069 24.3747 128 25.9087 128C27.4427 128 28.7737 127.069 29.2997 125.628L31.7715 118.852C32.2943 117.42 33.67 116.457 35.195 116.457H53.6349C54.6707 116.457 55.5099 115.618 55.5099 114.582C55.5099 113.547 54.6707 112.707 53.6349 112.707H35.1953C32.1008 112.707 29.3092 114.66 28.2487 117.567L25.9092 123.98L23.5694 117.567C22.5089 114.66 19.7174 112.707 16.6229 112.707H11.7858C7.35481 112.707 3.75003 109.103 3.75003 104.672V62.0325C3.75003 57.6015 7.35481 53.9967 11.7858 53.9967H36.633V54.4249C36.633 60.9237 41.9201 66.2108 48.4189 66.2108H87.6172V104.672C87.6172 109.103 84.0122 112.708 79.5811 112.708H62.3852C61.3495 112.708 60.5102 113.547 60.5102 114.583C60.5102 115.618 61.3495 116.458 62.3852 116.458H79.5811C86.0799 116.458 91.3672 111.171 91.3672 104.672V66.2108H92.805C94.33 66.2108 95.706 67.1735 96.2285 68.606L98.7003 75.3813C99.2263 76.8226 100.558 77.7536 102.091 77.7536C103.626 77.7536 104.956 76.8221 105.482 75.3813L107.954 68.606C108.477 67.1735 109.852 66.2108 111.377 66.2108H116.214C122.713 66.2108 128 60.9237 128 54.4249V38.8768C128 37.8413 127.161 37.0018 126.125 37.0018C125.089 37.0018 124.25 37.8413 124.25 38.8768V54.4249C124.25 58.856 120.645 62.4607 116.214 62.4607H111.377C108.283 62.4607 105.491 64.4138 104.431 67.3205L102.091 73.7338L99.7515 67.3205C98.6908 64.4138 95.899 62.4607 92.805 62.4607C91.289 62.4607 50.0484 62.4607 48.4189 62.4607C43.9878 62.4607 40.3831 58.856 40.3831 54.4249C40.3831 52.6232 40.3831 14.9124 40.3831 11.7856C40.3831 7.35481 43.9878 3.75003 48.4186 3.75003H116.214C120.645 3.75003 124.25 7.35481 124.25 11.7858V30.1267C124.25 31.1622 125.089 32.0018 126.125 32.0018C127.161 32.0018 128 31.1622 128 30.1267V11.7858C128 5.28704 122.713 0 116.214 0H48.4186C41.9201 0 36.6328 5.28704 36.6328 11.7858V50.2466H11.7858C5.28729 50.2466 0 55.5337 0 62.0325V104.672C0 111.17 5.28729 116.457 11.7858 116.457Z" fill="black"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_6311_9544">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.7 KiB |
@@ -1 +0,0 @@
|
||||
<svg id="Capa_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g><g><path d="m291.532 66.273c4.142 0 7.5-3.357 7.5-7.5v-.057c0-4.143-3.358-7.472-7.5-7.472s-7.5 3.386-7.5 7.528 3.358 7.501 7.5 7.501z"/><path d="m254.455 66.273c4.142 0 7.5-3.357 7.5-7.5v-.057c0-4.143-3.358-7.472-7.5-7.472s-7.5 3.386-7.5 7.528 3.358 7.501 7.5 7.501z"/><path d="m217.378 66.273c4.142 0 7.5-3.357 7.5-7.5v-.057c0-4.143-3.358-7.472-7.5-7.472s-7.5 3.386-7.5 7.528 3.358 7.501 7.5 7.501z"/><path d="m123.925 51.273-76.763-.057c-.002 0-.003 0-.005 0-4.14 0-7.497 3.354-7.5 7.494-.003 4.143 3.353 7.503 7.495 7.506l76.763.057h.005c4.14 0 7.497-3.354 7.5-7.494.002-4.142-3.353-7.503-7.495-7.506z"/><path d="m287.507 124.863h-111.062c-6.933 0-12.574 5.641-12.574 12.574v33.479c0 6.948 5.641 12.602 12.574 12.602h111.062c6.933 0 12.574-5.653 12.574-12.602v-33.479c0-6.933-5.641-12.574-12.574-12.574zm-2.426 43.655h-106.209v-28.654h106.209z"/><path d="m292.581 210.217h-121.209c-4.142 0-7.5 3.357-7.5 7.5s3.358 7.5 7.5 7.5h121.209c4.142 0 7.5-3.357 7.5-7.5s-3.358-7.5-7.5-7.5z"/><path d="m189.882 245.736h-18.51c-4.142 0-7.5 3.357-7.5 7.5s3.358 7.5 7.5 7.5h18.51c4.142 0 7.5-3.357 7.5-7.5s-3.358-7.5-7.5-7.5z"/><path d="m292.581 245.736h-62.05c-4.142 0-7.5 3.357-7.5 7.5s3.358 7.5 7.5 7.5h62.05c4.142 0 7.5-3.357 7.5-7.5s-3.358-7.5-7.5-7.5z"/><path d="m444.802 450.744h-.255c-4.142 0-7.5 3.357-7.5 7.5s3.358 7.5 7.5 7.5h.255c4.142 0 7.5-3.357 7.5-7.5s-3.358-7.5-7.5-7.5z"/><path d="m490.667 301.75h-59.114v-129.049c0-11.669-9.494-21.163-21.163-21.163h-71.7v-114.592c0-11.404-9.278-20.682-20.682-20.682h-297.327c-11.404.001-20.681 9.278-20.681 20.682v241.718c0 11.419 9.277 20.709 20.681 20.709h33.801v97.131c0 11.669 9.494 21.163 21.163 21.163h104.223l-8.866 29.646h-14.994c-13.342 0-24.196 10.867-24.196 24.226v11.707c0 6.887 5.603 12.489 12.489 12.489h197.434c6.887 0 12.489-5.603 12.489-12.489v-11.707c0-13.358-10.867-24.226-24.225-24.226h-14.991l-8.847-29.646h71.443v56.735c0 11.763 9.557 21.333 21.305 21.333h91.758c11.763 0 21.333-9.57 21.333-21.333v-151.346c0-11.748-9.57-21.306-21.333-21.306zm-475.667-23.086v-177.438h137.039c4.142 0 7.5-3.357 7.5-7.5s-3.358-7.5-7.5-7.5h-137.039v-49.28c0-3.133 2.548-5.682 5.681-5.682h297.327c3.133 0 5.682 2.549 5.682 5.682v49.279h-137.011c-4.142 0-7.5 3.357-7.5 7.5s3.358 7.5 7.5 7.5h137.011v177.438c0 3.147-2.549 5.709-5.682 5.709h-297.327c-3.133.001-5.681-2.56-5.681-5.708zm303.008 20.709c11.404 0 20.682-9.29 20.682-20.709v-112.126h71.7c3.398 0 6.163 2.765 6.163 6.163v129.049h-17.644c-11.748 0-21.305 9.558-21.305 21.306v41.683h-308.122v-65.365h248.526zm21.215 172.166v9.196h-192.411v-9.196c0-5.087 4.125-9.226 9.196-9.226h173.991c5.086 0 9.224 4.139 9.224 9.226zm-79.014-68.872c-4.142 0-7.5 3.357-7.5 7.5s3.358 7.5 7.5 7.5h30.298l8.847 29.646h-112.696l8.866-29.646h30.188c4.142 0 7.5-3.357 7.5-7.5s-3.358-7.5-7.5-7.5h-150.067c-3.398 0-6.163-2.765-6.163-6.163v-16.766h308.123v22.929zm236.791 71.735c0 3.492-2.841 6.333-6.333 6.333h-91.758c-3.477 0-6.305-2.841-6.305-6.333v-151.346c0-3.477 2.828-6.306 6.305-6.306h91.758c3.492 0 6.333 2.829 6.333 6.306z"/><path d="m127.661 124.863h-76.451c-6.949 0-12.603 5.641-12.603 12.574v110.696c0 6.949 5.653 12.603 12.603 12.603h76.451c6.949 0 12.602-5.653 12.602-12.603v-110.695c0-6.934-5.653-12.575-12.602-12.575zm-2.398 120.873h-71.655v-105.873h71.655z"/></g></g></svg>
|
||||
|
Before Width: | Height: | Size: 3.3 KiB |
@@ -1,14 +1,10 @@
|
||||
(function (window) {
|
||||
|
||||
if (document.getElementById('activityChartContainer')) {
|
||||
let currentType = 'service';
|
||||
const tableContainer = document.getElementById('activityContainer');
|
||||
const currentUserName = tableContainer.getAttribute('data-currentUserName');
|
||||
const currentServiceId = tableContainer.getAttribute('data-currentServiceId');
|
||||
|
||||
const COLORS = {
|
||||
delivered: '#0076d6',
|
||||
failed: '#fa9441',
|
||||
pending: '#C7CACE',
|
||||
text: '#666'
|
||||
};
|
||||
|
||||
@@ -16,7 +12,7 @@
|
||||
const FONT_WEIGHT = 'bold';
|
||||
const MAX_Y = 120;
|
||||
|
||||
const createChart = function(containerId, labels, deliveredData, failedData, pendingData) {
|
||||
const createChart = function(containerId, labels, deliveredData, failedData) {
|
||||
const container = d3.select(containerId);
|
||||
container.selectAll('*').remove(); // Clear any existing content
|
||||
|
||||
@@ -30,60 +26,38 @@
|
||||
.append('g')
|
||||
.attr('transform', `translate(${margin.left},${margin.top})`);
|
||||
|
||||
let tooltip = d3.select('#tooltip');
|
||||
|
||||
if (tooltip.empty()) {
|
||||
tooltip = d3.select('body').append('div')
|
||||
.attr('id', 'tooltip')
|
||||
.style('display', 'none');
|
||||
}
|
||||
|
||||
// Calculate total messages
|
||||
const totalMessages = d3.sum(deliveredData) + d3.sum(failedData) + d3.sum(pendingData);
|
||||
|
||||
// Create legend only if there are messages
|
||||
// Create legend
|
||||
const legendContainer = d3.select('.chart-legend');
|
||||
legendContainer.selectAll('*').remove(); // Clear any existing legend
|
||||
|
||||
if (totalMessages > 0) {
|
||||
// Show legend if there are messages
|
||||
const legendData = [
|
||||
{ label: 'Delivered', color: COLORS.delivered },
|
||||
{ label: 'Failed', color: COLORS.failed },
|
||||
{ label: 'Pending', color: COLORS.pending }
|
||||
];
|
||||
const legendData = [
|
||||
{ label: 'Delivered', color: COLORS.delivered },
|
||||
{ label: 'Failed', color: COLORS.failed }
|
||||
];
|
||||
|
||||
const legendItem = legendContainer.selectAll('.legend-item')
|
||||
.data(legendData)
|
||||
.enter()
|
||||
.append('div')
|
||||
.attr('class', 'legend-item');
|
||||
const legendItem = legendContainer.selectAll('.legend-item')
|
||||
.data(legendData)
|
||||
.enter()
|
||||
.append('div')
|
||||
.attr('class', 'legend-item');
|
||||
|
||||
legendItem.append('div')
|
||||
.attr('class', 'legend-rect')
|
||||
.style('background-color', d => d.color)
|
||||
.style('display', 'inline-block')
|
||||
.style('margin-right', '5px');
|
||||
legendItem.append('div')
|
||||
.attr('class', 'legend-rect')
|
||||
.style('background-color', d => d.color)
|
||||
.style('display', 'inline-block')
|
||||
.style('margin-right', '5px');
|
||||
|
||||
legendItem.append('span')
|
||||
.attr('class', 'legend-label')
|
||||
.text(d => d.label);
|
||||
|
||||
// Ensure the legend is shown
|
||||
legendContainer.style('display', 'flex');
|
||||
} else {
|
||||
// Hide the legend if there are no messages
|
||||
legendContainer.style('display', 'none');
|
||||
}
|
||||
legendItem.append('span')
|
||||
.attr('class', 'legend-label')
|
||||
.text(d => d.label);
|
||||
|
||||
const x = d3.scaleBand()
|
||||
.domain(labels)
|
||||
.range([0, width])
|
||||
.padding(0.1);
|
||||
// Adjust the y-axis domain to add some space above the tallest bar
|
||||
const maxY = d3.max(deliveredData.map((d, i) => d + (failedData[i] || 0) + (pendingData[i] || 0)));
|
||||
|
||||
const y = d3.scaleSymlog()
|
||||
const maxY = d3.max(deliveredData.map((d, i) => d + (failedData[i] || 0)));
|
||||
const y = d3.scaleLinear()
|
||||
.domain([0, maxY + 2]) // Add 2 units of space at the top
|
||||
.nice()
|
||||
.range([height, 0]);
|
||||
@@ -95,7 +69,7 @@
|
||||
|
||||
// Generate the y-axis with whole numbers
|
||||
const yAxis = d3.axisLeft(y)
|
||||
.ticks(Math.min(maxY + 2, 3))
|
||||
.ticks(Math.min(maxY + 2, 10)) // Generate up to 10 ticks based on the data
|
||||
.tickFormat(d3.format('d')); // Ensure whole numbers on the y-axis
|
||||
|
||||
svg.append('g')
|
||||
@@ -106,13 +80,12 @@
|
||||
const stackData = labels.map((label, i) => ({
|
||||
label: label,
|
||||
delivered: deliveredData[i],
|
||||
failed: failedData[i] || 0,
|
||||
pending: pendingData[i] || 0
|
||||
failed: failedData[i] || 0 // Ensure there's a value for failed, even if it's 0
|
||||
}));
|
||||
|
||||
// Stack the data
|
||||
const stack = d3.stack()
|
||||
.keys(['delivered', 'failed', 'pending'])
|
||||
.keys(['delivered', 'failed'])
|
||||
.order(d3.stackOrderNone)
|
||||
.offset(d3.stackOffsetNone);
|
||||
|
||||
@@ -120,8 +93,12 @@
|
||||
|
||||
// Color scale
|
||||
const color = d3.scaleOrdinal()
|
||||
.domain(['delivered', 'failed', 'pending'])
|
||||
.range([COLORS.delivered, COLORS.failed, COLORS.pending]);
|
||||
.domain(['delivered', 'failed'])
|
||||
.range([COLORS.delivered, COLORS.failed]);
|
||||
// Create tooltip
|
||||
const tooltip = d3.select('body').append('div')
|
||||
.attr('id', 'tooltip')
|
||||
.style('display', 'none');
|
||||
|
||||
// Create bars with animation
|
||||
const barGroups = svg.selectAll('.bar-group')
|
||||
@@ -130,12 +107,11 @@
|
||||
.append('g')
|
||||
.attr('class', 'bar-group')
|
||||
.attr('fill', d => color(d.key));
|
||||
const minBarHeight = 5;
|
||||
|
||||
barGroups.selectAll('rect')
|
||||
.data(d => d)
|
||||
.enter()
|
||||
.append('rect')
|
||||
.filter(d => d[1] - d[0] > 0)
|
||||
.attr('x', d => x(d.data.label))
|
||||
.attr('y', height)
|
||||
.attr('height', 0)
|
||||
@@ -156,13 +132,11 @@
|
||||
.transition()
|
||||
.duration(1000)
|
||||
.attr('y', d => y(d[1]))
|
||||
.attr('height', d => {
|
||||
const calculatedHeight = y(d[0]) - y(d[1]);
|
||||
return calculatedHeight < minBarHeight ? minBarHeight : calculatedHeight;
|
||||
}); };
|
||||
.attr('height', d => y(d[0]) - y(d[1]));
|
||||
};
|
||||
|
||||
// Function to create an accessible table
|
||||
const createTable = function(tableId, chartType, labels, deliveredData, failedData, pendingData) {
|
||||
const createTable = function(tableId, chartType, labels, deliveredData, failedData) {
|
||||
const table = document.getElementById(tableId);
|
||||
table.innerHTML = ""; // Clear previous data
|
||||
|
||||
@@ -174,7 +148,7 @@
|
||||
|
||||
// Create table header
|
||||
const headerRow = document.createElement('tr');
|
||||
const headers = ['Day', 'Delivered', 'Failed', 'Pending'];
|
||||
const headers = ['Day', 'Delivered', 'Failed'];
|
||||
headers.forEach(headerText => {
|
||||
const th = document.createElement('th');
|
||||
th.textContent = headerText;
|
||||
@@ -197,10 +171,6 @@
|
||||
cellFailed.textContent = failedData[index];
|
||||
row.appendChild(cellFailed);
|
||||
|
||||
const cellPending = document.createElement('td');
|
||||
cellPending.textContent = pendingData[index];
|
||||
row.appendChild(cellPending);
|
||||
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
|
||||
@@ -210,149 +180,91 @@
|
||||
};
|
||||
|
||||
const fetchData = function(type) {
|
||||
|
||||
var ctx = document.getElementById('weeklyChart');
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
var userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
var socket = io("/services");
|
||||
var eventType = type === 'service' ? 'fetch_daily_stats' : 'fetch_daily_stats_by_user';
|
||||
var socketConnect = type === 'service' ? 'daily_stats_update' : 'daily_stats_by_user_update';
|
||||
|
||||
var url = type === 'service'
|
||||
? `/services/${currentServiceId}/daily-stats.json?timezone=${encodeURIComponent(userTimezone)}`
|
||||
: `/services/${currentServiceId}/daily-stats-by-user.json`;
|
||||
socket.on('connect', function () {
|
||||
socket.emit(eventType);
|
||||
});
|
||||
|
||||
socket.on('connect_error', function(error) {
|
||||
console.error('WebSocket connection error:', error);
|
||||
});
|
||||
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
labels = [];
|
||||
deliveredData = [];
|
||||
failedData = [];
|
||||
pendingData = [];
|
||||
let totalMessages = 0;
|
||||
socket.on(socketConnect, function(data) {
|
||||
|
||||
for (var dateString in data) {
|
||||
if (data.hasOwnProperty(dateString)) {
|
||||
const dateParts = dateString.split('-');
|
||||
const formattedDate = `${dateParts[1]}/${dateParts[2]}/${dateParts[0].slice(2)}`;
|
||||
var labels = [];
|
||||
var deliveredData = [];
|
||||
var failedData = [];
|
||||
|
||||
labels.push(formattedDate);
|
||||
deliveredData.push(data[dateString].sms.delivered);
|
||||
failedData.push(data[dateString].sms.failure);
|
||||
pendingData.push(data[dateString].sms.pending || 0);
|
||||
totalMessages += data[dateString].sms.delivered + data[dateString].sms.failure + data[dateString].sms.pending;
|
||||
}
|
||||
}
|
||||
for (var dateString in data) {
|
||||
// Parse the date string (assuming format YYYY-MM-DD)
|
||||
const dateParts = dateString.split('-');
|
||||
const formattedDate = `${dateParts[1]}/${dateParts[2]}/${dateParts[0].slice(2)}`; // Format to MM/DD/YY
|
||||
|
||||
// Check if there are no messages sent
|
||||
const subTitle = document.querySelector(`#activityChartContainer .chart-subtitle`);
|
||||
if (totalMessages === 0) {
|
||||
// Remove existing chart and render the alert message
|
||||
d3.select('#weeklyChart').selectAll('*').remove();
|
||||
d3.select('#weeklyChart')
|
||||
.append('div')
|
||||
.html(`
|
||||
<div class="usa-alert usa-alert--info usa-alert--slim">
|
||||
<div class="usa-alert__body">
|
||||
<p class="usa-alert__text">
|
||||
No messages sent in the last 7 days
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
// Hide the subtitle
|
||||
if (subTitle) {
|
||||
subTitle.style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
// If there are messages, create the chart and table
|
||||
createChart('#weeklyChart', labels, deliveredData, failedData, pendingData);
|
||||
createTable('weeklyTable', 'activityChart', labels, deliveredData, failedData, pendingData);
|
||||
}
|
||||
labels.push(formattedDate);
|
||||
deliveredData.push(data[dateString].sms.delivered);
|
||||
failedData.push(data[dateString].sms.failure);
|
||||
}
|
||||
|
||||
createChart('#weeklyChart', labels, deliveredData, failedData);
|
||||
createTable('weeklyTable', 'activityChart', labels, deliveredData, failedData);
|
||||
});
|
||||
|
||||
socket.on('error', function(data) {
|
||||
console.log('Error:', data);
|
||||
});
|
||||
};
|
||||
|
||||
return data;
|
||||
})
|
||||
.catch(error => console.error('Error fetching daily stats:', error));
|
||||
};
|
||||
setInterval(() => fetchData(currentType), 25000);
|
||||
const handleDropdownChange = function(event) {
|
||||
const selectedValue = event.target.value;
|
||||
currentType = selectedValue;
|
||||
const subTitle = document.querySelector(`#activityChartContainer .chart-subtitle`);
|
||||
const selectElement = document.getElementById('options');
|
||||
const selectedText = selectElement.options[selectElement.selectedIndex].text;
|
||||
|
||||
subTitle.textContent = `${selectedText} - last 7 days`;
|
||||
fetchData(selectedValue);
|
||||
|
||||
const liveRegion = document.getElementById('aria-live-account');
|
||||
liveRegion.textContent = `Data updated for ${selectedText} - last 7 days`;
|
||||
|
||||
const tableHeading = document.querySelector('#tableActivity h2');
|
||||
const senderColumns = document.querySelectorAll('.sender-column');
|
||||
const allRows = document.querySelectorAll('#activity-table tbody tr');
|
||||
const caption = document.querySelector('#activity-table caption');
|
||||
|
||||
if (selectedValue === 'individual') {
|
||||
|
||||
tableHeading.textContent = 'My activity';
|
||||
caption.textContent = `Table showing the sent jobs for ${currentUserName}`;
|
||||
|
||||
senderColumns.forEach(col => {
|
||||
col.style.display = 'none';
|
||||
});
|
||||
|
||||
allRows.forEach(row => row.style.display = 'none');
|
||||
|
||||
const userRows = Array.from(allRows).filter(row => {
|
||||
const senderCell = row.querySelector('.sender-column');
|
||||
const rowSender = senderCell ? senderCell.textContent.trim() : '';
|
||||
return rowSender === currentUserName;
|
||||
});
|
||||
|
||||
userRows.slice(0, 5).forEach(row => {
|
||||
row.style.display = '';
|
||||
});
|
||||
} else {
|
||||
|
||||
tableHeading.textContent = 'Service activity';
|
||||
caption.textContent = `Table showing the sent jobs for service`;
|
||||
|
||||
senderColumns.forEach(col => {
|
||||
col.style.display = '';
|
||||
});
|
||||
|
||||
allRows.forEach((row, index) => {
|
||||
row.style.display = (index < 5) ? '' : 'none';
|
||||
});
|
||||
if (selectedValue === "individual") {
|
||||
subTitle.textContent = selectedText + " - Last 7 Days";
|
||||
fetchData('individual');
|
||||
} else if (selectedValue === "service") {
|
||||
subTitle.textContent = selectedText + " - Last 7 Days";
|
||||
fetchData('service');
|
||||
}
|
||||
|
||||
// Update ARIA live region
|
||||
const liveRegion = document.getElementById('aria-live-account');
|
||||
liveRegion.textContent = `Data updated for ${selectedText} - Last 7 Days`;
|
||||
|
||||
// Switch tables based on dropdown selection
|
||||
const selectedTable = selectedValue === "individual" ? "table1" : "table2";
|
||||
const tables = document.querySelectorAll('.table-overflow-x-auto');
|
||||
tables.forEach(function(table) {
|
||||
table.classList.add('hidden'); // Hide all tables by adding the hidden class
|
||||
table.classList.remove('visible'); // Ensure they are not visible
|
||||
});
|
||||
const tableToShow = document.getElementById(selectedTable);
|
||||
tableToShow.classList.remove('hidden'); // Remove hidden class
|
||||
tableToShow.classList.add('visible'); // Add visible class
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Initialize activityChart chart and table with service data by default
|
||||
fetchData(currentType);
|
||||
|
||||
const allRows = Array.from(document.querySelectorAll('#activity-table tbody tr'));
|
||||
allRows.forEach((row, index) => {
|
||||
row.style.display = (index < 5) ? '' : 'none';
|
||||
});
|
||||
fetchData('service');
|
||||
|
||||
// Add event listener to the dropdown
|
||||
const dropdown = document.getElementById('options');
|
||||
dropdown.addEventListener('change', handleDropdownChange);
|
||||
});
|
||||
|
||||
// Resize chart on window resize
|
||||
window.addEventListener('resize', function() {
|
||||
if (labels.length > 0 && deliveredData.length > 0 && failedData.length > 0 && pendingData.length > 0) {
|
||||
createChart('#weeklyChart', labels, deliveredData, failedData, pendingData);
|
||||
createTable('weeklyTable', 'activityChart', labels, deliveredData, failedData, pendingData);
|
||||
}
|
||||
const selectedValue = document.getElementById('options').value;
|
||||
handleDropdownChange({ target: { value: selectedValue } });
|
||||
});
|
||||
|
||||
// Export functions for testing
|
||||
|
||||
70
app/assets/javascripts/sampleChartDashboard.js
Normal file
@@ -0,0 +1,70 @@
|
||||
(function (window) {
|
||||
|
||||
function initializeChartAndSocket() {
|
||||
var ctx = document.getElementById('myChart');
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
var myBarChart = new Chart(ctx.getContext('2d'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: [],
|
||||
datasets: [
|
||||
{
|
||||
label: 'Delivered',
|
||||
data: [],
|
||||
backgroundColor: '#0076d6',
|
||||
stack: 'Stack 0'
|
||||
},
|
||||
]
|
||||
},
|
||||
options: {
|
||||
animation: false,
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var socket = io();
|
||||
|
||||
socket.on('connect', function() {
|
||||
socket.emit('fetch_daily_stats_by_user');
|
||||
});
|
||||
|
||||
socket.on('daily_stats_by_user_update', function(data) {
|
||||
// console.log('Data received:', data);
|
||||
var labels = [];
|
||||
var deliveredData = [];
|
||||
var failedData = [];
|
||||
|
||||
for (var date in data) {
|
||||
labels.push(date);
|
||||
deliveredData.push(data[date].sms.delivered);
|
||||
|
||||
}
|
||||
|
||||
myBarChart.data.labels = labels;
|
||||
myBarChart.data.datasets[0].data = deliveredData;
|
||||
myBarChart.update();
|
||||
});
|
||||
|
||||
socket.on('error', function(data) {
|
||||
// console.log('Error:', data);
|
||||
});
|
||||
|
||||
var sevenDaysButton = document.getElementById('sevenDaysButton');
|
||||
if (sevenDaysButton) {
|
||||
sevenDaysButton.addEventListener('click', function() {
|
||||
socket.emit('fetch_daily_stats_by_user');
|
||||
// console.log('clicked');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initializeChartAndSocket);
|
||||
|
||||
})(window);
|
||||
@@ -1,57 +0,0 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const sidenavItems = document.querySelectorAll('.usa-sidenav__item > .parent-link');
|
||||
let lastPath = window.location.pathname;
|
||||
let debounceTimeout = null;
|
||||
|
||||
sidenavItems.forEach((link) => {
|
||||
const parentItem = link.parentElement;
|
||||
const sublist = parentItem.querySelector('.usa-sidenav__sublist');
|
||||
const targetHref = link.getAttribute('href');
|
||||
|
||||
// initialize the menu to open the correct submenu based on the current route
|
||||
if (window.location.pathname.startsWith(targetHref)) {
|
||||
parentItem.classList.add('open');
|
||||
link.setAttribute('aria-expanded', 'true');
|
||||
}
|
||||
|
||||
link.addEventListener('click', (event) => {
|
||||
const currentPath = window.location.pathname;
|
||||
|
||||
// prevent default behavior only if navigating to the same route
|
||||
if (currentPath === targetHref) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (sublist && !parentItem.classList.contains('open')) {
|
||||
// debounce the menu update to avoid flickering
|
||||
clearTimeout(debounceTimeout);
|
||||
debounceTimeout = setTimeout(() => {
|
||||
parentItem.classList.add('open');
|
||||
link.setAttribute('aria-expanded', 'true');
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// handle browser back/forward navigation
|
||||
window.addEventListener('popstate', () => {
|
||||
const currentPath = window.location.pathname;
|
||||
|
||||
// sync menu state
|
||||
sidenavItems.forEach((link) => {
|
||||
const parentItem = link.parentElement;
|
||||
const targetHref = link.getAttribute('href');
|
||||
|
||||
if (currentPath.startsWith(targetHref)) {
|
||||
parentItem.classList.add('open');
|
||||
link.setAttribute('aria-expanded', 'true');
|
||||
} else {
|
||||
parentItem.classList.remove('open');
|
||||
link.setAttribute('aria-expanded', 'false');
|
||||
}
|
||||
});
|
||||
|
||||
lastPath = currentPath;
|
||||
});
|
||||
});
|
||||
@@ -6,17 +6,17 @@
|
||||
var chartTitle = document.getElementById('chartTitle').textContent;
|
||||
|
||||
// Access data attributes from the HTML
|
||||
var messagesSent = parseInt(chartContainer.getAttribute('data-messages-sent'));
|
||||
var messagesRemaining = parseInt(chartContainer.getAttribute('data-messages-remaining'));
|
||||
var totalMessages = messagesSent + messagesRemaining;
|
||||
var sms_sent = parseInt(chartContainer.getAttribute('data-sms-sent'));
|
||||
var sms_remaining_messages = parseInt(chartContainer.getAttribute('data-sms-allowance-remaining'));
|
||||
var totalMessages = sms_sent + sms_remaining_messages;
|
||||
|
||||
// Update the message below the chart
|
||||
document.getElementById('message').innerText = `${messagesSent.toLocaleString()} sent / ${messagesRemaining.toLocaleString()} remaining`;
|
||||
document.getElementById('message').innerText = `${sms_sent.toLocaleString()} sent / ${sms_remaining_messages.toLocaleString()} remaining`;
|
||||
|
||||
// Calculate minimum width for "Messages Sent" as 1% of the total chart width
|
||||
var minSentPercentage = (messagesSent === 0) ? 0 : 0.02;
|
||||
var minSentPercentage = 0.02; // Minimum width as a percentage of total messages (1% in this case)
|
||||
var minSentValue = totalMessages * minSentPercentage;
|
||||
var displaySent = Math.max(messagesSent, minSentValue);
|
||||
var displaySent = Math.max(sms_sent, minSentValue);
|
||||
var displayRemaining = totalMessages - displaySent;
|
||||
|
||||
var svg = d3.select("#totalMessageChart");
|
||||
@@ -48,7 +48,7 @@
|
||||
.attr("width", 0) // Start with width 0 for animation
|
||||
.on('mouseover', function(event) {
|
||||
tooltip.style('display', 'block')
|
||||
.html(`Messages Sent: ${messagesSent.toLocaleString()}`);
|
||||
.html(`Messages Sent: ${sms_sent.toLocaleString()}`);
|
||||
})
|
||||
.on('mousemove', function(event) {
|
||||
tooltip.style('left', `${event.pageX + 10}px`)
|
||||
@@ -66,7 +66,7 @@
|
||||
.attr("width", 0) // Start with width 0 for animation
|
||||
.on('mouseover', function(event) {
|
||||
tooltip.style('display', 'block')
|
||||
.html(`Remaining: ${messagesRemaining.toLocaleString()}`);
|
||||
.html(`Remaining: ${sms_remaining_messages.toLocaleString()}`);
|
||||
})
|
||||
.on('mousemove', function(event) {
|
||||
tooltip.style('left', `${event.pageX + 10}px`)
|
||||
@@ -115,9 +115,9 @@
|
||||
var tbodyRow = document.createElement('tr');
|
||||
|
||||
var tdMessagesSent = document.createElement('td');
|
||||
tdMessagesSent.textContent = messagesSent.toLocaleString(); // Value for Messages Sent
|
||||
tdMessagesSent.textContent = sms_sent.toLocaleString(); // Value for Messages Sent
|
||||
var tdRemaining = document.createElement('td');
|
||||
tdRemaining.textContent = messagesRemaining.toLocaleString(); // Value for Remaining
|
||||
tdRemaining.textContent = sms_remaining_messages.toLocaleString(); // Value for Remaining
|
||||
|
||||
tbodyRow.appendChild(tdMessagesSent);
|
||||
tbodyRow.appendChild(tdRemaining);
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
function showError(input, errorElement, message) {
|
||||
errorElement.textContent = ""; // Clear existing message
|
||||
errorElement.style.display = "block";
|
||||
|
||||
// Small delay to ensure screen readers pick up the change
|
||||
setTimeout(() => {
|
||||
errorElement.textContent = message;
|
||||
}, 10);
|
||||
|
||||
input.classList.add("usa-input--error");
|
||||
input.setAttribute("aria-describedby", errorElement.id);
|
||||
}
|
||||
|
||||
function hideError(input, errorElement) {
|
||||
errorElement.style.display = "none";
|
||||
input.classList.remove("usa-input--error");
|
||||
input.removeAttribute("aria-describedby");
|
||||
}
|
||||
|
||||
function getFieldLabel(input) {
|
||||
const label = document.querySelector(`label[for="${input.id}"]`);
|
||||
return label ? label.textContent.trim() : "This field";
|
||||
}
|
||||
|
||||
// Attach validation logic to forms
|
||||
function attachValidation() {
|
||||
const forms = document.querySelectorAll("form.send-one-off-form");
|
||||
forms.forEach((form) => {
|
||||
const inputs = form.querySelectorAll("input, textarea, select");
|
||||
|
||||
form.addEventListener("submit", function (event) {
|
||||
let isValid = true;
|
||||
let firstInvalidInput = null;
|
||||
|
||||
inputs.forEach((input) => {
|
||||
const errorId = input.id ? `${input.id}-error` : `${input.name}-error`;
|
||||
let errorElement = document.getElementById(errorId);
|
||||
|
||||
if (!errorElement) {
|
||||
errorElement = document.createElement("span");
|
||||
errorElement.id = errorId;
|
||||
errorElement.classList.add("usa-error-message");
|
||||
errorElement.setAttribute("aria-live", "polite");
|
||||
input.insertAdjacentElement("afterend", errorElement);
|
||||
}
|
||||
|
||||
if (input.type === "radio") {
|
||||
// Find all radio buttons with the same name
|
||||
const radioGroup = document.querySelectorAll(`input[name="${input.name}"]`);
|
||||
const isChecked = Array.from(radioGroup).some(radio => radio.checked);
|
||||
|
||||
if (!isChecked) {
|
||||
showError(input, errorElement, `Error: ${getFieldLabel(input)} must be selected.`);
|
||||
isValid = false;
|
||||
if (!firstInvalidInput) {
|
||||
firstInvalidInput = input;
|
||||
}
|
||||
}
|
||||
} else if (input.value.trim() === "") {
|
||||
showError(input, errorElement, `Error: ${getFieldLabel(input)} is required.`);
|
||||
isValid = false;
|
||||
if (!firstInvalidInput) {
|
||||
firstInvalidInput = input;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!isValid) {
|
||||
event.preventDefault();
|
||||
if (firstInvalidInput) firstInvalidInput.focus();
|
||||
}
|
||||
});
|
||||
|
||||
inputs.forEach((input) => {
|
||||
input.addEventListener("input", function () {
|
||||
const errorElement = document.getElementById(`${input.id}-error`);
|
||||
if (input.value.trim() !== "" && errorElement) {
|
||||
hideError(input, errorElement);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Automatically attach validation only in the browser
|
||||
if (typeof window !== "undefined") {
|
||||
document.addEventListener("DOMContentLoaded", attachValidation);
|
||||
}
|
||||
|
||||
// ✅ Check if we're in a Node.js environment (for Jest) before using `module.exports`
|
||||
if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
|
||||
module.exports = { showError, hideError, getFieldLabel, attachValidation };
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
document.cookie = `timezone=${timeZone}; path=/`;
|
||||
})
|
||||
@@ -9,9 +9,6 @@ $failed: color('gray-cool-20');
|
||||
&.usage {
|
||||
height: units(4);
|
||||
}
|
||||
svg {
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
|
||||
#totalMessageChartContainer {
|
||||
@@ -60,6 +57,17 @@ $failed: color('gray-cool-20');
|
||||
}
|
||||
}
|
||||
|
||||
.usa-tooltip {
|
||||
line-height: 1;
|
||||
.usa-tooltip__body {
|
||||
width: units(mobile);
|
||||
font-size: size("body", 2);
|
||||
height: auto;
|
||||
white-space: wrap;
|
||||
line-height: units(1);
|
||||
}
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
width: 300px;
|
||||
height: 20px;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
width: 100%;
|
||||
max-width: 464px;
|
||||
box-sizing: border-box;
|
||||
padding: units(2);
|
||||
padding: units(1);
|
||||
background: color('gray-cool-10');
|
||||
border: 1px solid color('gray-cool-10');
|
||||
border-radius: 5px;
|
||||
|
||||
@@ -9,14 +9,9 @@ in the form $setting: value,
|
||||
|
||||
@use "uswds-core" with (
|
||||
$theme-font-type-sans: "public-sans",
|
||||
$theme-card-border-radius: 0,
|
||||
$theme-card-gap: 4,
|
||||
$theme-card-border-width: 2px,
|
||||
$theme-card-border-color: "ink",
|
||||
$theme-show-notifications: false,
|
||||
$theme-banner-max-width: "desktop-lg",
|
||||
$theme-grid-container-max-width: "desktop-lg",
|
||||
$theme-footer-max-width: "desktop-lg",
|
||||
$theme-header-max-width: "desktop-lg",
|
||||
$theme-identifier-max-width: "desktop-lg"
|
||||
$theme-header-max-width: "desktop-lg"
|
||||
);
|
||||
|
||||
@@ -34,11 +34,6 @@ $path: '/static/images/';
|
||||
// Dependencies from GOV.UK Frontend, packaged to be specific to this application
|
||||
@import './govuk-frontend/all';
|
||||
|
||||
// Custom overrides
|
||||
.govuk-link {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
// Specific to this application
|
||||
@import 'local/typography';
|
||||
@import 'grids';
|
||||
|
||||
@@ -8,7 +8,6 @@ from notifications_utils import DAILY_MESSAGE_LIMIT
|
||||
|
||||
|
||||
class Config(object):
|
||||
SIMULATED_SMS_NUMBERS = ("+14254147755", "+14254147167")
|
||||
NOTIFY_APP_NAME = "admin"
|
||||
NOTIFY_ENVIRONMENT = getenv("NOTIFY_ENVIRONMENT", "development")
|
||||
API_HOST_NAME = getenv("API_HOST_NAME", "localhost")
|
||||
@@ -88,8 +87,6 @@ class Config(object):
|
||||
],
|
||||
}
|
||||
|
||||
FEATURE_ABOUT_PAGE_ENABLED = getenv("FEATURE_ABOUT_PAGE_ENABLED", "false") == "true"
|
||||
|
||||
|
||||
def _s3_credentials_from_env(bucket_prefix):
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Explore Notify, add team members, and practice [sending messages to teammates](/using-notify/trial-mode).
|
||||
|
||||
2. ## Personalize content
|
||||
Learn how to [personalize messages](/using-notify/how-to) to increase response.
|
||||
Learn how to [personalize messages](/using-notify/guidance) to increase response.
|
||||
|
||||
3. ## Check delivery status
|
||||
[Analyze the delivery](/using-notify/delivery-status) of your messages and download reports
|
||||
@@ -14,7 +14,7 @@ Learn how to [personalize messages](/using-notify/how-to) to increase response.
|
||||
Learn about message _parts_ and [how limits are calculated](/using-notify/pricing).
|
||||
|
||||
5. ## Start sending messages
|
||||
To remove the restrictions of Trial Mode and begin sending messages to clients complete the <a class="usa-link usa-link--external" href="https://docs.google.com/forms/d/1fnaBtxuGf3q-OdGVyt2LqBKvp9_P21kmKJa0yIK8rWM/edit">Go-Live Form</a>.
|
||||
To remove the restrictions of Trial Mode and begin sending messages to clients complete the [Live Campaign Form](https://airtable.com/appe4n7jYOALPLcyU/shrIPWnLTw9U1fclL).
|
||||
We’ll respond within one business day.
|
||||
|
||||
### Questions?
|
||||
|
||||
@@ -41,8 +41,14 @@ class ValidGovEmail:
|
||||
if field.data == "":
|
||||
return
|
||||
|
||||
message = "Enter a public sector email address."
|
||||
from flask import url_for
|
||||
|
||||
message = """
|
||||
Enter a public sector email address or
|
||||
<a class="usa-link" href="{}">find out who can use Notify</a>
|
||||
""".format(
|
||||
url_for("main.features")
|
||||
)
|
||||
if not is_gov_user(field.data.lower()):
|
||||
raise ValidationError(message)
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ from app.utils.user import user_has_permissions
|
||||
|
||||
|
||||
@main.route("/activity/services/<uuid:service_id>")
|
||||
@user_has_permissions("view_activity")
|
||||
@user_has_permissions()
|
||||
def all_jobs_activity(service_id):
|
||||
service_data_retention_days = 7
|
||||
page = get_page_from_request()
|
||||
jobs = job_api_client.get_page_of_jobs(service_id, page=page)
|
||||
all_jobs_dict = generate_job_dict(jobs)
|
||||
prev_page, next_page, pagination = handle_pagination(jobs, service_id, page)
|
||||
message_type = ("sms",)
|
||||
|
||||
return render_template(
|
||||
"views/activity/all-activity.html",
|
||||
all_jobs_dict=all_jobs_dict,
|
||||
@@ -28,34 +28,6 @@ def all_jobs_activity(service_id):
|
||||
next_page=next_page,
|
||||
prev_page=prev_page,
|
||||
pagination=pagination,
|
||||
download_link_one_day=url_for(
|
||||
".download_notifications_csv",
|
||||
service_id=current_service.id,
|
||||
message_type=message_type,
|
||||
status=request.args.get("status"),
|
||||
number_of_days="one_day",
|
||||
),
|
||||
download_link_three_day=url_for(
|
||||
".download_notifications_csv",
|
||||
service_id=current_service.id,
|
||||
message_type=message_type,
|
||||
status=request.args.get("status"),
|
||||
number_of_days="three_day",
|
||||
),
|
||||
download_link_five_day=url_for(
|
||||
".download_notifications_csv",
|
||||
service_id=current_service.id,
|
||||
message_type=message_type,
|
||||
status=request.args.get("status"),
|
||||
number_of_days="five_day",
|
||||
),
|
||||
download_link_seven_day=url_for(
|
||||
".download_notifications_csv",
|
||||
service_id=current_service.id,
|
||||
message_type=message_type,
|
||||
status=request.args.get("status"),
|
||||
number_of_days="seven_day",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -103,22 +75,6 @@ def generate_job_dict(jobs):
|
||||
"processing_started": job["processing_started"],
|
||||
"created_by": job["created_by"],
|
||||
"template_name": job["template_name"],
|
||||
"delivered_count": next(
|
||||
(
|
||||
stat["count"]
|
||||
for stat in job.get("statistics", [])
|
||||
if stat["status"] == "delivered"
|
||||
),
|
||||
None,
|
||||
),
|
||||
"failed_count": next(
|
||||
(
|
||||
stat["count"]
|
||||
for stat in job.get("statistics", [])
|
||||
if stat["status"] == "failed"
|
||||
),
|
||||
None,
|
||||
),
|
||||
}
|
||||
for job in jobs["data"]
|
||||
]
|
||||
|
||||
@@ -1,25 +1,67 @@
|
||||
import calendar
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
from itertools import groupby
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from flask import abort, jsonify, render_template, request, session, url_for
|
||||
from flask import Response, abort, jsonify, render_template, request, session, url_for
|
||||
from flask_login import current_user
|
||||
from flask_socketio import emit
|
||||
from werkzeug.utils import redirect
|
||||
|
||||
from app import (
|
||||
billing_api_client,
|
||||
current_service,
|
||||
job_api_client,
|
||||
service_api_client,
|
||||
socketio,
|
||||
template_statistics_client,
|
||||
)
|
||||
from app.formatters import format_date_numeric, format_datetime_numeric, get_time_left
|
||||
from app.main import main
|
||||
from app.main.views.user_profile import set_timezone
|
||||
from app.statistics_utils import get_formatted_percentage
|
||||
from app.utils import DELIVERED_STATUSES, FAILURE_STATUSES, REQUESTED_STATUSES
|
||||
from app.utils import (
|
||||
DELIVERED_STATUSES,
|
||||
FAILURE_STATUSES,
|
||||
REQUESTED_STATUSES,
|
||||
service_has_permission,
|
||||
)
|
||||
from app.utils.csv import Spreadsheet
|
||||
from app.utils.pagination import generate_next_dict, generate_previous_dict
|
||||
from app.utils.time import get_current_financial_year
|
||||
from app.utils.user import user_has_permissions
|
||||
from notifications_utils.recipients import format_phone_number_human_readable
|
||||
|
||||
|
||||
@socketio.on("fetch_daily_stats", namespace="/services")
|
||||
def handle_fetch_daily_stats():
|
||||
service_id = session.get("service_id")
|
||||
if service_id:
|
||||
date_range = get_stats_date_range()
|
||||
daily_stats = service_api_client.get_service_notification_statistics_by_day(
|
||||
service_id, start_date=date_range["start_date"], days=date_range["days"]
|
||||
)
|
||||
emit("daily_stats_update", daily_stats)
|
||||
else:
|
||||
emit("error", {"error": "No service_id provided"})
|
||||
|
||||
|
||||
@socketio.on("fetch_daily_stats_by_user", namespace="/services")
|
||||
def handle_fetch_daily_stats_by_user():
|
||||
service_id = session.get("service_id")
|
||||
user_id = session.get("user_id")
|
||||
if service_id and user_id:
|
||||
date_range = get_stats_date_range()
|
||||
daily_stats_by_user = (
|
||||
service_api_client.get_user_service_notification_statistics_by_day(
|
||||
service_id,
|
||||
user_id,
|
||||
start_date=date_range["start_date"],
|
||||
days=date_range["days"],
|
||||
)
|
||||
)
|
||||
emit("daily_stats_by_user_update", daily_stats_by_user)
|
||||
else:
|
||||
emit("error", {"error": "No service_id or user_id provided"})
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/dashboard")
|
||||
@@ -31,7 +73,6 @@ def old_service_dashboard(service_id):
|
||||
@main.route("/services/<uuid:service_id>")
|
||||
@user_has_permissions()
|
||||
def service_dashboard(service_id):
|
||||
|
||||
if session.get("invited_user_id"):
|
||||
session.pop("invited_user_id", None)
|
||||
session["service_id"] = service_id
|
||||
@@ -39,106 +80,62 @@ def service_dashboard(service_id):
|
||||
if not current_user.has_permissions("view_activity"):
|
||||
return redirect(url_for("main.choose_template", service_id=service_id))
|
||||
|
||||
yearly_usage = billing_api_client.get_annual_usage_for_service(
|
||||
service_id,
|
||||
get_current_financial_year(),
|
||||
)
|
||||
free_sms_allowance = billing_api_client.get_free_sms_fragment_limit_for_year(
|
||||
current_service.id,
|
||||
)
|
||||
usage_data = get_annual_usage_breakdown(yearly_usage, free_sms_allowance)
|
||||
sms_sent = usage_data["sms_sent"]
|
||||
sms_allowance_remaining = usage_data["sms_allowance_remaining"]
|
||||
|
||||
job_response = job_api_client.get_jobs(service_id)["data"]
|
||||
service_data_retention_days = 7
|
||||
|
||||
active_jobs = [job for job in job_response if job["job_status"] != "cancelled"]
|
||||
sorted_jobs = sorted(active_jobs, key=lambda job: job["created_at"], reverse=True)
|
||||
job_lists = [
|
||||
{**job_dict, "finished_processing": job_is_finished(job_dict)}
|
||||
for job_dict in sorted_jobs
|
||||
jobs = [
|
||||
{
|
||||
"job_id": job["id"],
|
||||
"time_left": get_time_left(job["created_at"]),
|
||||
"download_link": url_for(
|
||||
".view_job_csv", service_id=current_service.id, job_id=job["id"]
|
||||
),
|
||||
"view_job_link": url_for(
|
||||
".view_job", service_id=current_service.id, job_id=job["id"]
|
||||
),
|
||||
"created_at": job["created_at"],
|
||||
"processing_finished": job.get("processing_finished"),
|
||||
"processing_started": job.get("processing_started"),
|
||||
"notification_count": job["notification_count"],
|
||||
"created_by": job["created_by"],
|
||||
"template_name": job["template_name"],
|
||||
"original_file_name": job["original_file_name"],
|
||||
}
|
||||
for job in job_response
|
||||
if job["job_status"] != "cancelled"
|
||||
]
|
||||
|
||||
total_messages = service_api_client.get_service_message_ratio(service_id)
|
||||
messages_remaining = total_messages.get("messages_remaining", 0)
|
||||
messages_sent = total_messages.get("messages_sent", 0)
|
||||
all_statistics = template_statistics_client.get_template_statistics_for_service(
|
||||
service_id, limit_days=7
|
||||
)
|
||||
template_statistics = aggregate_template_usage(all_statistics)
|
||||
return render_template(
|
||||
"views/dashboard/dashboard.html",
|
||||
jobs=job_lists,
|
||||
updates_url=url_for(".service_dashboard_updates", service_id=service_id),
|
||||
partials=get_dashboard_partials(service_id),
|
||||
jobs=jobs,
|
||||
service_data_retention_days=service_data_retention_days,
|
||||
messages_remaining=messages_remaining,
|
||||
messages_sent=messages_sent,
|
||||
template_statistics=template_statistics,
|
||||
most_used_template_count=max(
|
||||
[row["count"] for row in template_statistics] or [0]
|
||||
),
|
||||
sms_sent=sms_sent,
|
||||
sms_allowance_remaining=sms_allowance_remaining,
|
||||
)
|
||||
|
||||
|
||||
def job_is_finished(job_dict):
|
||||
done_statuses = DELIVERED_STATUSES + FAILURE_STATUSES + ["cancelled"]
|
||||
processed_count = sum(
|
||||
stat["count"]
|
||||
for stat in job_dict["statistics"]
|
||||
if stat["status"] in done_statuses
|
||||
)
|
||||
return job_dict["notification_count"] == processed_count
|
||||
@main.route("/services/<uuid:service_id>/dashboard.json")
|
||||
@user_has_permissions("view_activity")
|
||||
def service_dashboard_updates(service_id):
|
||||
return jsonify(**get_dashboard_partials(service_id))
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/daily-stats.json")
|
||||
@user_has_permissions()
|
||||
def get_daily_stats(service_id):
|
||||
date_range = get_stats_date_range()
|
||||
days = date_range["days"]
|
||||
user_timezone = request.args.get("timezone", "UTC")
|
||||
|
||||
stats_utc = service_api_client.get_service_notification_statistics_by_day(
|
||||
service_id,
|
||||
start_date=date_range["start_date"],
|
||||
days=days,
|
||||
)
|
||||
|
||||
local_stats = get_local_daily_stats_for_last_x_days(stats_utc, user_timezone, days)
|
||||
return jsonify(local_stats)
|
||||
|
||||
|
||||
def get_local_daily_stats_for_last_x_days(stats_utc, user_timezone, days):
|
||||
tz = ZoneInfo(user_timezone)
|
||||
today_local = datetime.now(tz).date()
|
||||
start_local = today_local - timedelta(days=days - 1)
|
||||
|
||||
# Generate exactly days local dates, each with zeroed stats
|
||||
days_list = [
|
||||
(start_local + timedelta(days=i)).strftime("%Y-%m-%d") for i in range(days)
|
||||
]
|
||||
aggregator = {
|
||||
d: {
|
||||
"sms": {"delivered": 0, "failure": 0, "pending": 0, "requested": 0},
|
||||
"email": {"delivered": 0, "failure": 0, "pending": 0, "requested": 0},
|
||||
}
|
||||
for d in days_list
|
||||
}
|
||||
|
||||
# Convert each UTC timestamp to local date and iterate
|
||||
for utc_ts, data in stats_utc.items():
|
||||
utc_dt = datetime.strptime(utc_ts, "%Y-%m-%dT%H:%M:%SZ").replace(
|
||||
tzinfo=ZoneInfo("UTC")
|
||||
)
|
||||
local_day = utc_dt.astimezone(tz).strftime("%Y-%m-%d")
|
||||
|
||||
if local_day in aggregator:
|
||||
for msg_type in ["sms", "email"]:
|
||||
for status in ["delivered", "failure", "pending", "requested"]:
|
||||
aggregator[local_day][msg_type][status] += data[msg_type][status]
|
||||
|
||||
return aggregator
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/daily-stats-by-user.json")
|
||||
@user_has_permissions()
|
||||
def get_daily_stats_by_user(service_id):
|
||||
date_range = get_stats_date_range()
|
||||
stats = service_api_client.get_user_service_notification_statistics_by_day(
|
||||
service_id,
|
||||
user_id=current_user.id,
|
||||
start_date=date_range["start_date"],
|
||||
days=date_range["days"],
|
||||
)
|
||||
return jsonify(stats)
|
||||
@main.route("/services/<uuid:service_id>/template-activity")
|
||||
@user_has_permissions("view_activity")
|
||||
def template_history(service_id):
|
||||
return redirect(url_for("main.template_usage", service_id=service_id), code=301)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/template-usage")
|
||||
@@ -226,6 +223,103 @@ def usage(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/monthly")
|
||||
@user_has_permissions("view_activity")
|
||||
def monthly(service_id):
|
||||
year, current_financial_year = requested_and_current_financial_year(request)
|
||||
return render_template(
|
||||
"views/dashboard/monthly.html",
|
||||
months=format_monthly_stats_to_list(
|
||||
service_api_client.get_monthly_notification_stats(service_id, year)["data"]
|
||||
),
|
||||
years=get_tuples_of_financial_years(
|
||||
partial_url=partial(url_for, ".monthly", service_id=service_id),
|
||||
start=current_financial_year - 2,
|
||||
end=current_financial_year,
|
||||
),
|
||||
selected_year=year,
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/inbox")
|
||||
@user_has_permissions("view_activity")
|
||||
@service_has_permission("inbound_sms")
|
||||
def inbox(service_id):
|
||||
return render_template(
|
||||
"views/dashboard/inbox.html",
|
||||
partials=get_inbox_partials(service_id),
|
||||
updates_url=url_for(
|
||||
".inbox_updates", service_id=service_id, page=request.args.get("page")
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/inbox.json")
|
||||
@user_has_permissions("view_activity")
|
||||
@service_has_permission("inbound_sms")
|
||||
def inbox_updates(service_id):
|
||||
return jsonify(get_inbox_partials(service_id))
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/inbox.csv")
|
||||
@user_has_permissions("view_activity")
|
||||
def inbox_download(service_id):
|
||||
return Response(
|
||||
Spreadsheet.from_rows(
|
||||
[
|
||||
[
|
||||
"Phone number",
|
||||
"Message",
|
||||
"Received",
|
||||
]
|
||||
]
|
||||
+ [
|
||||
[
|
||||
format_phone_number_human_readable(message["user_number"]),
|
||||
message["content"].lstrip(("=+-@")),
|
||||
format_datetime_numeric(message["created_at"]),
|
||||
]
|
||||
for message in service_api_client.get_inbound_sms(service_id)["data"]
|
||||
]
|
||||
).as_csv_data,
|
||||
mimetype="text/csv",
|
||||
headers={
|
||||
"Content-Disposition": 'inline; filename="Received text messages {}.csv"'.format(
|
||||
format_date_numeric(datetime.utcnow().isoformat())
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def get_inbox_partials(service_id):
|
||||
page = int(request.args.get("page", 1))
|
||||
inbound_messages_data = service_api_client.get_most_recent_inbound_sms(
|
||||
service_id, page=page
|
||||
)
|
||||
inbound_messages = inbound_messages_data["data"]
|
||||
if not inbound_messages:
|
||||
inbound_number = current_service.inbound_number
|
||||
else:
|
||||
inbound_number = None
|
||||
|
||||
prev_page = None
|
||||
if page > 1:
|
||||
prev_page = generate_previous_dict("main.inbox", service_id, page)
|
||||
next_page = None
|
||||
if inbound_messages_data["has_next"]:
|
||||
next_page = generate_next_dict("main.inbox", service_id, page)
|
||||
|
||||
return {
|
||||
"messages": render_template(
|
||||
"views/dashboard/_inbox_messages.html",
|
||||
messages=inbound_messages,
|
||||
inbound_number=inbound_number,
|
||||
prev_page=prev_page,
|
||||
next_page=next_page,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
def filter_out_cancelled_stats(template_statistics):
|
||||
return [s for s in template_statistics if s["status"] != "cancelled"]
|
||||
|
||||
@@ -238,33 +332,90 @@ def aggregate_template_usage(template_statistics, sort_key="count"):
|
||||
key=lambda x: x["template_id"],
|
||||
):
|
||||
template_stats = list(v)
|
||||
first_stat = template_stats[0] if template_stats else None
|
||||
|
||||
templates.append(
|
||||
{
|
||||
"template_id": k,
|
||||
"template_name": first_stat.get("template_name"),
|
||||
"template_type": first_stat.get("template_type"),
|
||||
"template_name": template_stats[0]["template_name"],
|
||||
"template_type": template_stats[0]["template_type"],
|
||||
"count": sum(s["count"] for s in template_stats),
|
||||
"created_by": first_stat.get("created_by"),
|
||||
"created_by_id": first_stat.get("created_by_id"),
|
||||
"last_used": first_stat.get("last_used"),
|
||||
"status": first_stat.get("status"),
|
||||
"template_folder": first_stat.get("template_folder"),
|
||||
"template_folder_id": first_stat.get("template_folder_id"),
|
||||
}
|
||||
)
|
||||
|
||||
return sorted(templates, key=lambda x: x[sort_key], reverse=True)
|
||||
|
||||
|
||||
def get_dashboard_totals(statistics):
|
||||
def aggregate_notifications_stats(template_statistics):
|
||||
template_statistics = filter_out_cancelled_stats(template_statistics)
|
||||
notifications = {
|
||||
template_type: {status: 0 for status in ("requested", "delivered", "failed")}
|
||||
for template_type in ["sms", "email"]
|
||||
}
|
||||
for stat in template_statistics:
|
||||
notifications[stat["template_type"]]["requested"] += stat["count"]
|
||||
if stat["status"] in DELIVERED_STATUSES:
|
||||
notifications[stat["template_type"]]["delivered"] += stat["count"]
|
||||
elif stat["status"] in FAILURE_STATUSES:
|
||||
notifications[stat["template_type"]]["failed"] += stat["count"]
|
||||
|
||||
return notifications
|
||||
|
||||
|
||||
def get_dashboard_partials(service_id):
|
||||
all_statistics = template_statistics_client.get_template_statistics_for_service(
|
||||
service_id, limit_days=7
|
||||
)
|
||||
template_statistics = aggregate_template_usage(all_statistics)
|
||||
stats = aggregate_notifications_stats(all_statistics)
|
||||
|
||||
dashboard_totals = (get_dashboard_totals(stats),)
|
||||
free_sms_allowance = billing_api_client.get_free_sms_fragment_limit_for_year(
|
||||
current_service.id,
|
||||
)
|
||||
# These 2 calls will update the dashboard sms allowance count while in trial mode.
|
||||
billing_api_client.get_monthly_usage_for_service(
|
||||
service_id, get_current_financial_year()
|
||||
)
|
||||
billing_api_client.create_or_update_free_sms_fragment_limit(
|
||||
service_id, free_sms_fragment_limit=free_sms_allowance
|
||||
)
|
||||
|
||||
yearly_usage = billing_api_client.get_annual_usage_for_service(
|
||||
service_id,
|
||||
get_current_financial_year(),
|
||||
)
|
||||
return {
|
||||
"upcoming": render_template(
|
||||
"views/dashboard/_upcoming.html",
|
||||
),
|
||||
"inbox": render_template(
|
||||
"views/dashboard/_inbox.html",
|
||||
),
|
||||
"totals": render_template(
|
||||
"views/dashboard/_totals.html",
|
||||
service_id=service_id,
|
||||
statistics=dashboard_totals[0],
|
||||
),
|
||||
"template-statistics": render_template(
|
||||
"views/dashboard/template-statistics.html",
|
||||
template_statistics=template_statistics,
|
||||
most_used_template_count=max(
|
||||
[row["count"] for row in template_statistics] or [0]
|
||||
),
|
||||
),
|
||||
"usage": render_template(
|
||||
"views/dashboard/_usage.html",
|
||||
**get_annual_usage_breakdown(yearly_usage, free_sms_allowance),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def get_dashboard_totals(statistics):
|
||||
for msg_type in statistics.values():
|
||||
msg_type["failed_percentage"] = get_formatted_percentage(
|
||||
msg_type["failed"], msg_type["requested"]
|
||||
)
|
||||
msg_type["show_warning"] = float(msg_type["failed_percentage"]) > 3
|
||||
|
||||
return statistics
|
||||
|
||||
|
||||
@@ -323,8 +474,6 @@ def get_months_for_financial_year(year, time_format="%B"):
|
||||
|
||||
|
||||
def get_current_month_for_financial_year(year):
|
||||
# Setting the timezone here because we need to set it somewhere.
|
||||
set_timezone()
|
||||
current_month = datetime.now().month
|
||||
return current_month
|
||||
|
||||
|
||||
@@ -1,50 +1,36 @@
|
||||
from flask import (
|
||||
abort,
|
||||
current_app,
|
||||
jsonify,
|
||||
redirect,
|
||||
render_template,
|
||||
request,
|
||||
url_for,
|
||||
)
|
||||
import os
|
||||
|
||||
from flask import abort, current_app, redirect, render_template, request, url_for
|
||||
from flask_login import current_user
|
||||
|
||||
from app import status_api_client
|
||||
from app.formatters import apply_html_class, convert_markdown_template
|
||||
from app.main import main
|
||||
from app.main.views.pricing import CURRENT_SMS_RATE
|
||||
from app.main.views.sub_navigation_dictionaries import (
|
||||
about_notify_nav,
|
||||
using_notify_nav,
|
||||
)
|
||||
from app.main.views.sub_navigation_dictionaries import features_nav, using_notify_nav
|
||||
from app.utils.user import user_is_logged_in
|
||||
|
||||
|
||||
# Hook to check for feature flags
|
||||
@main.before_request
|
||||
def check_feature_flags():
|
||||
if request.path.startswith("/about") and not current_app.config.get(
|
||||
"FEATURE_ABOUT_PAGE_ENABLED", False
|
||||
):
|
||||
abort(404)
|
||||
|
||||
|
||||
@main.route("/test/feature-flags")
|
||||
def test_feature_flags():
|
||||
return jsonify(
|
||||
{"FEATURE_ABOUT_PAGE_ENABLED": current_app.config["FEATURE_ABOUT_PAGE_ENABLED"]}
|
||||
)
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
|
||||
|
||||
@main.route("/")
|
||||
def index():
|
||||
if current_user and current_user.is_authenticated:
|
||||
return redirect(url_for("main.choose_account"))
|
||||
|
||||
token = generate_token(
|
||||
str(request.remote_addr),
|
||||
current_app.config["SECRET_KEY"],
|
||||
current_app.config["DANGEROUS_SALT"],
|
||||
)
|
||||
url = os.getenv("LOGIN_DOT_GOV_INITIAL_SIGNIN_URL")
|
||||
# handle unit tests
|
||||
if url is not None:
|
||||
url = url.replace("NONCE", token)
|
||||
url = url.replace("STATE", token)
|
||||
return render_template(
|
||||
"views/signedout.html",
|
||||
sms_rate=CURRENT_SMS_RATE,
|
||||
counts=status_api_client.get_count_of_live_services_and_organizations(),
|
||||
initial_signin_url=url,
|
||||
)
|
||||
|
||||
|
||||
@@ -100,6 +86,44 @@ def callbacks():
|
||||
return redirect(url_for("main.documentation"), 301)
|
||||
|
||||
|
||||
# --- Features page set --- #
|
||||
|
||||
|
||||
@main.route("/features")
|
||||
@user_is_logged_in
|
||||
def features():
|
||||
return render_template("views/features.html", navigation_links=features_nav())
|
||||
|
||||
|
||||
@main.route("/features/roadmap", endpoint="roadmap")
|
||||
@user_is_logged_in
|
||||
def roadmap():
|
||||
return render_template("views/roadmap.html", navigation_links=features_nav())
|
||||
|
||||
|
||||
@main.route("/features/sms")
|
||||
@user_is_logged_in
|
||||
def features_sms():
|
||||
return render_template(
|
||||
"views/features/text-messages.html", navigation_links=features_nav()
|
||||
)
|
||||
|
||||
|
||||
@main.route("/features/security", endpoint="security")
|
||||
@user_is_logged_in
|
||||
def security():
|
||||
return render_template("views/security.html", navigation_links=features_nav())
|
||||
|
||||
|
||||
@main.route("/features/using_notify")
|
||||
@user_is_logged_in
|
||||
def using_notify():
|
||||
return (
|
||||
render_template("views/using-notify.html", navigation_links=features_nav()),
|
||||
410,
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/delivery-status")
|
||||
@user_is_logged_in
|
||||
def message_status():
|
||||
@@ -154,168 +178,53 @@ def trial_mode_new():
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/best-practices")
|
||||
@main.route("/using-notify/guidance")
|
||||
@user_is_logged_in
|
||||
def best_practices():
|
||||
def guidance_index():
|
||||
return render_template(
|
||||
"views/guides/best-practices.html",
|
||||
"views/guidance/index.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/best-practices/clear-goals")
|
||||
@user_is_logged_in
|
||||
def clear_goals():
|
||||
return render_template(
|
||||
"views/guides/clear-goals.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/best-practices/rules-and-regulations")
|
||||
@user_is_logged_in
|
||||
def rules_and_regulations():
|
||||
return render_template(
|
||||
"views/guides/rules-and-regulations.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/best-practices/establish-trust")
|
||||
@user_is_logged_in
|
||||
def establish_trust():
|
||||
return render_template(
|
||||
"views/guides/establish-trust.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/best-practices/write-for-action")
|
||||
@user_is_logged_in
|
||||
def write_for_action():
|
||||
return render_template(
|
||||
"views/guides/write-for-action.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/best-practices/multiple-languages")
|
||||
@user_is_logged_in
|
||||
def multiple_languages():
|
||||
return render_template(
|
||||
"views/guides/multiple-languages.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/best-practices/benchmark-performance")
|
||||
@user_is_logged_in
|
||||
def benchmark_performance():
|
||||
return render_template(
|
||||
"views/guides/benchmark-performance.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/how-to")
|
||||
@user_is_logged_in
|
||||
def how_to():
|
||||
return render_template(
|
||||
"views/how-to/index.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/contact")
|
||||
def contact():
|
||||
return render_template(
|
||||
"views/contact.html",
|
||||
navigation_links=about_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/about")
|
||||
def about_notify():
|
||||
return render_template(
|
||||
"views/about/about.html",
|
||||
navigation_links=about_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/about/security")
|
||||
def about_security():
|
||||
return render_template(
|
||||
"views/about/security.html",
|
||||
navigation_links=about_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/about/why-text-messaging")
|
||||
def why_text_messaging():
|
||||
return render_template(
|
||||
"views/about/why-text-messaging.html",
|
||||
navigation_links=about_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/join-notify")
|
||||
def join_notify():
|
||||
return render_template(
|
||||
"views/join-notify.html",
|
||||
navigation_links=about_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/how-to/create-and-send-messages")
|
||||
@main.route("/using-notify/guidance/create-and-send-messages")
|
||||
@user_is_logged_in
|
||||
def create_and_send_messages():
|
||||
return render_template(
|
||||
"views/how-to/create-and-send-messages.html",
|
||||
"views/guidance/create-and-send-messages.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/how-to/edit-and-format-messages")
|
||||
@main.route("/using-notify/guidance/edit-and-format-messages")
|
||||
@user_is_logged_in
|
||||
def edit_and_format_messages():
|
||||
return render_template(
|
||||
"views/how-to/edit-and-format-messages.html",
|
||||
"views/guidance/edit-and-format-messages.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/using-notify/how-to/send-files-by-email")
|
||||
@main.route("/using-notify/guidance/send-files-by-email")
|
||||
@user_is_logged_in
|
||||
def send_files_by_email():
|
||||
return render_template(
|
||||
"views/how-to/send-files-by-email.html",
|
||||
"views/guidance/send-files-by-email.html",
|
||||
navigation_links=using_notify_nav(),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/studio")
|
||||
def studio():
|
||||
return render_template(
|
||||
"views/studio.html",
|
||||
)
|
||||
|
||||
|
||||
@main.route("/acceptable-use-policy")
|
||||
def acceptable_use_policy():
|
||||
return render_template(
|
||||
"views/acceptable-use-policy.html",
|
||||
)
|
||||
|
||||
|
||||
# --- Redirects --- #
|
||||
|
||||
|
||||
@main.route("/roadmap", endpoint="old_roadmap")
|
||||
@main.route("/information-security", endpoint="information_security")
|
||||
@main.route("/using_notify", endpoint="old_using_notify")
|
||||
@main.route("/information-risk-management", endpoint="information_risk_management")
|
||||
@main.route("/integration_testing", endpoint="old_integration_testing")
|
||||
def old_page_redirects():
|
||||
redirects = {
|
||||
"main.old_roadmap": "main.roadmap",
|
||||
"main.information_security": "main.using_notify",
|
||||
"main.old_using_notify": "main.using_notify",
|
||||
"main.information_risk_management": "main.security",
|
||||
|
||||
@@ -17,12 +17,14 @@ def accept_invite(token):
|
||||
and current_user.email_address.lower() != invited_user.email_address.lower()
|
||||
):
|
||||
message = Markup(
|
||||
f"""
|
||||
You’re signed in as {current_user.email_address}.
|
||||
This invite is for another email address.
|
||||
<a href={url_for("main.sign_out")} class="usa-link">Sign out</a>
|
||||
and click the link again to accept this invite.
|
||||
"""
|
||||
You’re signed in as {}.
|
||||
This invite is for another email address.
|
||||
<a href={} class="usa-link">Sign out</a>
|
||||
and click the link again to accept this invite.
|
||||
""".format(
|
||||
current_user.email_address, url_for("main.sign_out")
|
||||
)
|
||||
)
|
||||
|
||||
flash(message=message)
|
||||
|
||||
@@ -57,6 +57,7 @@ def view_job(service_id, job_id):
|
||||
|
||||
filter_args = parse_filter_args(request.args)
|
||||
filter_args["status"] = set_status_filters(filter_args)
|
||||
|
||||
return render_template(
|
||||
"views/jobs/job.html",
|
||||
job=job,
|
||||
@@ -401,9 +402,7 @@ def get_job_partials(job):
|
||||
)
|
||||
|
||||
if request.referrer is not None:
|
||||
session["arrived_from_preview_page"] = ("check" in request.referrer) or (
|
||||
"help=0" in request.referrer
|
||||
)
|
||||
session["arrived_from_preview_page"] = "check" in request.referrer
|
||||
else:
|
||||
session["arrived_from_preview_page"] = False
|
||||
|
||||
|
||||
@@ -77,11 +77,6 @@ def invite_user(service_id, user_id=None):
|
||||
form.login_authentication.data = "sms_auth"
|
||||
|
||||
if form.validate_on_submit():
|
||||
if not form.permissions or len(form.permissions) == 0:
|
||||
return render_template(
|
||||
"views/user-has-no-permissions.html",
|
||||
user_to_invite=user_to_invite,
|
||||
)
|
||||
email_address = form.email_address.data
|
||||
invited_user = InvitedUser.create(
|
||||
current_user.id,
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
import csv
|
||||
import itertools
|
||||
import json
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
from io import StringIO
|
||||
|
||||
from flask import (
|
||||
Response,
|
||||
abort,
|
||||
current_app,
|
||||
flash,
|
||||
render_template,
|
||||
request,
|
||||
session,
|
||||
url_for,
|
||||
)
|
||||
from flask import abort, flash, render_template, request, url_for
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app import (
|
||||
@@ -34,7 +23,6 @@ from app.main.forms import (
|
||||
DateFilterForm,
|
||||
RequiredDateFilterForm,
|
||||
)
|
||||
from app.main.views.send import _send_notification
|
||||
from app.statistics_utils import (
|
||||
get_formatted_percentage,
|
||||
get_formatted_percentage_two_dp,
|
||||
@@ -82,104 +70,6 @@ def platform_admin():
|
||||
)
|
||||
|
||||
|
||||
@main.route("/platform-admin/download-all-users")
|
||||
@user_is_platform_admin
|
||||
def download_all_users():
|
||||
|
||||
# Create a CSV string from the user data
|
||||
users = user_api_client.get_all_users_detailed()
|
||||
|
||||
if len(users) == 0:
|
||||
return "No data to download."
|
||||
|
||||
output = StringIO()
|
||||
header = ["Name", "Email Address", "Phone Number", "Service"]
|
||||
fieldnames = ["name", "email_address", "mobile_number", "service"]
|
||||
writer = csv.DictWriter(
|
||||
output,
|
||||
fieldnames=fieldnames,
|
||||
delimiter=",",
|
||||
)
|
||||
# Write custom header
|
||||
writer.writerow(dict(zip(fieldnames, header)))
|
||||
for user in users:
|
||||
user_no_commas = {key: value.replace(",", "") for key, value in user.items()}
|
||||
if user_no_commas["name"].startswith("e2e"):
|
||||
continue
|
||||
writer.writerow(user_no_commas)
|
||||
csv_data = output.getvalue()
|
||||
|
||||
# Create a direct download response with the CSV data and appropriate headers
|
||||
response = Response(csv_data, content_type="text/csv; charset=utf-8")
|
||||
response.headers["Content-Disposition"] = "attachment; filename=users.csv"
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@main.route("/platform-admin/get-redis-report")
|
||||
@user_is_platform_admin
|
||||
def get_redis_report():
|
||||
|
||||
memory_info = redis_client.info("memory")
|
||||
memory_used = memory_info.get("used_memory_human", "N/A")
|
||||
max_memory = memory_info.get("maxmemory_human", "N/A")
|
||||
if max_memory == "0B":
|
||||
max_memory = "No set limit"
|
||||
mem_fragmentation = memory_info.get("mem_fragmentation_ratio", "N/A")
|
||||
frag_quality = "Swapping (bad)"
|
||||
if mem_fragmentation >= 1.0:
|
||||
frag_quality = "Healthy"
|
||||
if mem_fragmentation > 1.5:
|
||||
frag_quality = "Problematic"
|
||||
if mem_fragmentation > 2.0:
|
||||
frag_quality = "Severe fragmentation"
|
||||
|
||||
frag_note = ""
|
||||
if mem_fragmentation > 2.0:
|
||||
frag_note = "Use MEMORY PURGE.\nReplace multiple small keys with hashes.\nAvoid long keys.\nSet max_memory."
|
||||
elif mem_fragmentation < 1.0:
|
||||
frag_note = "Allocate more RAM.\nSet max_memory."
|
||||
|
||||
keys = redis_client.keys("*")
|
||||
key_details = []
|
||||
|
||||
for key in keys:
|
||||
key_type = redis_client.type(key).decode("utf-8")
|
||||
ttl = redis_client.ttl(key)
|
||||
ttl_str = "No Expiry" if ttl == -1 else f"{ttl} seconds"
|
||||
key_details.append(
|
||||
{"Key": key.decode("utf-8"), "Type": key_type, "TTL": ttl_str}
|
||||
)
|
||||
output = StringIO()
|
||||
writer = csv.writer(
|
||||
output,
|
||||
)
|
||||
writer.writerow(["Redis Report"])
|
||||
writer.writerow([])
|
||||
|
||||
writer.writerow(["Memory"])
|
||||
writer.writerow(["", "Memory Used", memory_used])
|
||||
writer.writerow(["", "Max Memory", max_memory])
|
||||
writer.writerow(["", "Memory Fragmentation Ratio", mem_fragmentation])
|
||||
writer.writerow(["", "Memory Fragmentation Quality", frag_quality, frag_note])
|
||||
writer.writerow([])
|
||||
|
||||
writer.writerow(["Keys Overview"])
|
||||
writer.writerow(["", "TTL", "Type", "Key"])
|
||||
for key_detail in key_details:
|
||||
writer.writerow(
|
||||
["", key_detail["TTL"], key_detail["Type"], key_detail["Key"][0:50]]
|
||||
)
|
||||
|
||||
csv_data = output.getvalue()
|
||||
|
||||
# Create a direct download response with the CSV data and appropriate headers
|
||||
response = Response(csv_data, content_type="text/csv; charset=utf-8")
|
||||
response.headers["Content-Disposition"] = "attachment; filename=redis.csv"
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def is_over_threshold(number, total, threshold):
|
||||
percentage = number / total * 100 if total else 0
|
||||
return percentage > threshold
|
||||
@@ -845,80 +735,3 @@ def _get_user_row(r):
|
||||
row.append(r["password_changed_at"])
|
||||
row.append(r["state"])
|
||||
return row
|
||||
|
||||
|
||||
@main.route(
|
||||
"/platform-admin/load-test",
|
||||
methods=["POST", "GET"],
|
||||
)
|
||||
@user_is_platform_admin
|
||||
def load_test():
|
||||
"""
|
||||
The load test assumes that a service called 'Test service' exists. It will make
|
||||
the platform admin a member of this service if the platform is not already. All
|
||||
messagese will be sent in this service.
|
||||
"""
|
||||
service = _find_load_test_service()
|
||||
_prepare_load_test_service(service)
|
||||
example_template = _find_example_template(service)
|
||||
|
||||
# Simulated success
|
||||
for _ in range(0, 250):
|
||||
session["recipient"] = current_app.config["SIMULATED_SMS_NUMBERS"][0]
|
||||
session["placeholders"] = {
|
||||
"day of week": "Monday",
|
||||
"color": "blue",
|
||||
"phone number": current_app.config["SIMULATED_SMS_NUMBERS"][0],
|
||||
}
|
||||
_send_notification(service["id"], example_template["id"])
|
||||
# Simulated failure
|
||||
for _ in range(0, 250):
|
||||
session["recipient"] = current_app.config["SIMULATED_SMS_NUMBERS"][1]
|
||||
session["placeholders"] = {
|
||||
"day of week": "Wednesday",
|
||||
"color": "orange",
|
||||
"phone number": current_app.config["SIMULATED_SMS_NUMBERS"][1],
|
||||
}
|
||||
_send_notification(service["id"], example_template["id"])
|
||||
|
||||
# For now, just redirect to the splash page so we know it's done
|
||||
return render_template(
|
||||
"views/platform-admin/splash-page.html",
|
||||
)
|
||||
|
||||
|
||||
def _find_example_template(service):
|
||||
templates = service_api_client.get_service_templates(service["id"])
|
||||
templates = templates["data"]
|
||||
for template in templates:
|
||||
# template = json.loads(template)
|
||||
if template["name"] == "Example text message template":
|
||||
return template
|
||||
|
||||
raise Exception("Could not find example template for load test")
|
||||
|
||||
|
||||
def _find_load_test_service():
|
||||
services = service_api_client.find_services_by_name("Test service")
|
||||
services = services["data"]
|
||||
|
||||
for service in services:
|
||||
if service["name"] == "Test service":
|
||||
return service
|
||||
|
||||
raise Exception("Could not find 'Test service' for load test")
|
||||
|
||||
|
||||
def _prepare_load_test_service(service):
|
||||
users = user_api_client.get_all_users()
|
||||
for user in users:
|
||||
if user["platform_admin"] == "t":
|
||||
try:
|
||||
user_api_client.add_user_to_service(
|
||||
service["id"], user["id"], ["send messages"]
|
||||
)
|
||||
except Exception:
|
||||
current_app.logger.exception(
|
||||
"Couldnt add user, may already be part of service"
|
||||
)
|
||||
pass
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import base64
|
||||
import json
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
from urllib.parse import unquote
|
||||
|
||||
from flask import (
|
||||
abort,
|
||||
@@ -161,29 +161,17 @@ def set_up_your_profile():
|
||||
debug_msg(f"Enter set_up_your_profile with request.args {request.args}")
|
||||
code = request.args.get("code")
|
||||
state = request.args.get("state")
|
||||
|
||||
state_key = f"login-state-{unquote(state)}"
|
||||
stored_state = unquote(redis_client.get(state_key).decode("utf8"))
|
||||
if state != stored_state:
|
||||
current_app.logger.error(f"State Error: {state} != {stored_state}")
|
||||
abort(403)
|
||||
|
||||
login_gov_error = request.args.get("error")
|
||||
|
||||
user_email = redis_client.get(f"user_email-{state}")
|
||||
user_uuid = redis_client.get(f"user_uuid-{state}")
|
||||
|
||||
new_user = user_email is None or user_uuid is None
|
||||
|
||||
if new_user: # invite path
|
||||
access_token = sign_in._get_access_token(code)
|
||||
|
||||
if redis_client.get(f"invitedata-{state}") is None:
|
||||
access_token = sign_in._get_access_token(code, state)
|
||||
debug_msg("Got the access token for login.gov")
|
||||
user_email, user_uuid = sign_in._get_user_email_and_uuid(access_token)
|
||||
debug_msg(
|
||||
f"Got the user_email {user_email} and user_uuid {user_uuid} from login.gov"
|
||||
)
|
||||
invite_data = redis_client.get(f"invitedata-{state}")
|
||||
invite_data = state.encode("utf8")
|
||||
invite_data = base64.b64decode(invite_data)
|
||||
invite_data = json.loads(invite_data)
|
||||
debug_msg(f"final state {invite_data}")
|
||||
invited_user_id = invite_data["invited_user_id"]
|
||||
@@ -205,7 +193,10 @@ def set_up_your_profile():
|
||||
|
||||
form = SetupUserProfileForm()
|
||||
|
||||
if form.validate_on_submit() and not new_user:
|
||||
if (
|
||||
form.validate_on_submit()
|
||||
and redis_client.get(f"invitedata-{state}") is not None
|
||||
):
|
||||
invite_data, user_email, user_uuid, invited_user_email_address = (
|
||||
get_invite_data_from_redis(state)
|
||||
)
|
||||
@@ -230,7 +221,6 @@ def set_up_your_profile():
|
||||
activate_user(user["id"])
|
||||
debug_msg("activated user")
|
||||
usr = User.from_id(user["id"])
|
||||
|
||||
usr.add_to_service(
|
||||
invite_data["service_id"],
|
||||
invite_data["permissions"],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from flask import send_from_directory
|
||||
from flask import redirect
|
||||
|
||||
from app.main import main
|
||||
|
||||
@@ -6,4 +6,6 @@ from app.main import main
|
||||
@main.route("/.well-known/security.txt", methods=["GET"])
|
||||
@main.route("/security.txt", methods=["GET"])
|
||||
def security_policy():
|
||||
return send_from_directory(".well-known", "security.txt")
|
||||
# See GDS Way security policy which this implements
|
||||
# https://gds-way.cloudapps.digital/standards/vulnerability-disclosure.html#vulnerability-disclosure-and-security-txt
|
||||
return redirect("https://vdp.cabinetoffice.gov.uk/.well-known/security.txt")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
import time
|
||||
import uuid
|
||||
from string import ascii_uppercase
|
||||
@@ -34,7 +33,6 @@ from app.main.forms import (
|
||||
SetSenderForm,
|
||||
get_placeholder_form_instance,
|
||||
)
|
||||
from app.main.views.user_profile import set_timezone
|
||||
from app.models.user import Users
|
||||
from app.s3_client.s3_csv_client import (
|
||||
get_csv_metadata,
|
||||
@@ -167,7 +165,7 @@ def send_messages(service_id, template_id):
|
||||
# just show the first error, as we don't expect the form to have more
|
||||
# than one, since it only has one field
|
||||
first_field_errors = list(form.errors.values())[0]
|
||||
error_message = '<span class="error-message usa-error-message">'
|
||||
error_message = '<span class="usa-error-message">'
|
||||
error_message = f"{error_message}{first_field_errors[0]}"
|
||||
error_message = f"{error_message}</span>"
|
||||
error_message = Markup(error_message)
|
||||
@@ -483,7 +481,6 @@ def send_one_off_step(service_id, template_id, step_index):
|
||||
link_to_upload=(
|
||||
request.endpoint == "main.send_one_off_step" and step_index == 0
|
||||
),
|
||||
errors=form.errors if form.errors else None,
|
||||
)
|
||||
|
||||
|
||||
@@ -740,7 +737,7 @@ def all_placeholders_in_session(placeholders):
|
||||
|
||||
def get_send_test_page_title(template_type, entering_recipient, name=None):
|
||||
if entering_recipient:
|
||||
return "Select recipients"
|
||||
return "Send ‘{}’".format(name)
|
||||
return "Personalize this message"
|
||||
|
||||
|
||||
@@ -803,15 +800,9 @@ def get_skip_link(step_index, template):
|
||||
)
|
||||
@user_has_permissions("send_messages", restrict_admin_usage=True)
|
||||
def send_one_off_to_myself(service_id, template_id):
|
||||
current_app.logger.info("Send one off to myself")
|
||||
try:
|
||||
db_template = current_service.get_template_with_user_permission_or_403(
|
||||
template_id, current_user
|
||||
)
|
||||
except Exception:
|
||||
current_app.logger.exception("Couldnt get template for one off")
|
||||
# Use 406 just because we're limited to certain codes here and it will point us back to a problem here
|
||||
abort(406)
|
||||
db_template = current_service.get_template_with_user_permission_or_403(
|
||||
template_id, current_user
|
||||
)
|
||||
|
||||
if db_template["template_type"] not in ("sms", "email"):
|
||||
abort(404)
|
||||
@@ -950,8 +941,8 @@ def preview_notification(service_id, template_id):
|
||||
)
|
||||
@user_has_permissions("send_messages", restrict_admin_usage=True)
|
||||
def send_notification(service_id, template_id):
|
||||
scheduled_for = session.pop("scheduled_for", "")
|
||||
recipient = get_recipient()
|
||||
|
||||
if not recipient:
|
||||
return redirect(
|
||||
url_for(
|
||||
@@ -960,10 +951,53 @@ def send_notification(service_id, template_id):
|
||||
template_id=template_id,
|
||||
)
|
||||
)
|
||||
upload_id = _send_notification(service_id, template_id)
|
||||
|
||||
session.pop("recipient", "")
|
||||
session.pop("placeholders", "")
|
||||
keys = []
|
||||
values = []
|
||||
for k, v in session["placeholders"].items():
|
||||
keys.append(k)
|
||||
values.append(v)
|
||||
|
||||
data = ",".join(keys)
|
||||
vals = ",".join(values)
|
||||
data = f"{data}\r\n{vals}"
|
||||
|
||||
filename = (
|
||||
f"one-off-{uuid.uuid4()}.csv" # {current_user.name} removed from filename
|
||||
)
|
||||
my_data = {"filename": filename, "template_id": template_id, "data": data}
|
||||
upload_id = s3upload(service_id, my_data)
|
||||
|
||||
# To debug messages that the user reports have not been sent, we log
|
||||
# the csv filename and the job id. The user will give us the file name,
|
||||
# so we can search on that to obtain the job id, which we can use elsewhere
|
||||
# on the API side to find out what happens to the message.
|
||||
current_app.logger.info(
|
||||
hilite(
|
||||
f"One-off file: {filename} job_id: {upload_id} s3 location: service-{service_id}-notify/{upload_id}.csv"
|
||||
)
|
||||
)
|
||||
|
||||
form = CsvUploadForm()
|
||||
form.file.data = my_data
|
||||
form.file.name = filename
|
||||
|
||||
check_message_output = check_messages(service_id, template_id, upload_id, 2)
|
||||
if "You cannot send to" in check_message_output:
|
||||
return check_messages(service_id, template_id, upload_id, 2)
|
||||
|
||||
job_api_client.create_job(
|
||||
upload_id,
|
||||
service_id,
|
||||
scheduled_for=scheduled_for,
|
||||
template_id=template_id,
|
||||
original_file_name=filename,
|
||||
notification_count=1,
|
||||
valid="True",
|
||||
)
|
||||
|
||||
session.pop("recipient")
|
||||
session.pop("placeholders")
|
||||
|
||||
# We have to wait for the job to run and create the notification in the database
|
||||
time.sleep(0.1)
|
||||
@@ -1011,63 +1045,6 @@ def send_notification(service_id, template_id):
|
||||
)
|
||||
|
||||
|
||||
def _send_notification(service_id, template_id):
|
||||
scheduled_for = session.pop("scheduled_for", "")
|
||||
|
||||
keys = []
|
||||
values = []
|
||||
# Guarantee that the real phone number comes last, because some
|
||||
# users will have placeholders like "add your second phone number"
|
||||
# or something like as custom placeholders.
|
||||
for k, v in session["placeholders"].items():
|
||||
if k != "phone number":
|
||||
keys.append(k)
|
||||
values.append(v)
|
||||
if "phone number" in session["placeholders"].keys():
|
||||
keys.append("phone number")
|
||||
values.append(session["placeholders"]["phone number"])
|
||||
|
||||
data = ",".join(keys)
|
||||
vals = ",".join(values)
|
||||
data = f"{data}\r\n{vals}"
|
||||
filename = (
|
||||
f"one-off-{uuid.uuid4()}.csv" # {current_user.name} removed from filename
|
||||
)
|
||||
my_data = {"filename": filename, "template_id": template_id, "data": data}
|
||||
upload_id = s3upload(service_id, my_data)
|
||||
# To debug messages that the user reports have not been sent, we log
|
||||
# the csv filename and the job id. The user will give us the file name,
|
||||
# so we can search on that to obtain the job id, which we can use elsewhere
|
||||
# on the API side to find out what happens to the message.
|
||||
current_app.logger.info(
|
||||
hilite(
|
||||
f"One-off file: {filename} job_id: {upload_id} s3 location: {service_id}-service-notify/{upload_id}.csv"
|
||||
)
|
||||
)
|
||||
|
||||
# For load testing we want to skip these checks. They are doing some fine-grained
|
||||
# comparison about what is in the preview, but the load test just blast messages
|
||||
# and doesn't care about the preview.
|
||||
if os.getenv("NOTIFY_ENVIRONMENT") not in ("development", "staging", "demo"):
|
||||
form = CsvUploadForm()
|
||||
form.file.data = my_data
|
||||
form.file.name = filename
|
||||
check_message_output = check_messages(service_id, template_id, upload_id, 2)
|
||||
if "You cannot send to" in check_message_output:
|
||||
return check_messages(service_id, template_id, upload_id, 2)
|
||||
|
||||
job_api_client.create_job(
|
||||
upload_id,
|
||||
service_id,
|
||||
scheduled_for=scheduled_for,
|
||||
template_id=template_id,
|
||||
original_file_name=filename,
|
||||
notification_count=1,
|
||||
valid="True",
|
||||
)
|
||||
return upload_id
|
||||
|
||||
|
||||
def get_email_reply_to_address_from_session():
|
||||
if session.get("sender_id"):
|
||||
return current_service.get_email_reply_to_address(session["sender_id"])[
|
||||
@@ -1098,7 +1075,6 @@ def get_spreadsheet_column_headings_from_template(template):
|
||||
|
||||
|
||||
def get_recipient():
|
||||
set_timezone()
|
||||
if {"recipient", "placeholders"} - set(session.keys()):
|
||||
return None
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import os
|
||||
import secrets
|
||||
import time
|
||||
import uuid
|
||||
from urllib.parse import unquote
|
||||
|
||||
import jwt
|
||||
import requests
|
||||
@@ -18,20 +16,19 @@ from flask import (
|
||||
)
|
||||
from flask_login import current_user
|
||||
|
||||
from app import login_manager, redis_client, user_api_client
|
||||
from app import login_manager, user_api_client
|
||||
from app.main import main
|
||||
from app.main.views.index import error
|
||||
from app.main.views.verify import activate_user
|
||||
from app.models.user import User
|
||||
from app.utils import hide_from_search_engines
|
||||
from app.utils.login import get_id_token, is_safe_redirect_url
|
||||
|
||||
# from app.utils.time import is_less_than_days_ago
|
||||
from app.utils.login import is_safe_redirect_url
|
||||
from app.utils.time import is_less_than_days_ago
|
||||
from app.utils.user import is_gov_user
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
|
||||
|
||||
def _reformat_keystring(orig): # pragma: no cover
|
||||
def _reformat_keystring(orig):
|
||||
arr = orig.split("-----")
|
||||
begin = arr[1]
|
||||
end = arr[3]
|
||||
@@ -40,7 +37,7 @@ def _reformat_keystring(orig): # pragma: no cover
|
||||
return new_keystring
|
||||
|
||||
|
||||
def _get_access_token(code): # pragma: no cover
|
||||
def _get_access_token(code, state):
|
||||
client_id = os.getenv("LOGIN_DOT_GOV_CLIENT_ID")
|
||||
access_token_url = os.getenv("LOGIN_DOT_GOV_ACCESS_TOKEN_URL")
|
||||
keystring = os.getenv("LOGIN_PEM")
|
||||
@@ -63,29 +60,17 @@ def _get_access_token(code): # pragma: no cover
|
||||
url = f"{base_url}{cli_assert}&{cli_assert_type}&{code_param}&grant_type=authorization_code"
|
||||
headers = {"Authorization": "Bearer %s" % token}
|
||||
response = requests.post(url, headers=headers)
|
||||
|
||||
response_json = response.json()
|
||||
id_token = get_id_token(response_json)
|
||||
nonce = id_token["nonce"]
|
||||
nonce_key = f"login-nonce-{unquote(nonce)}"
|
||||
if not os.getenv("NOTIFY_ENVIRONMENT") == "development":
|
||||
stored_nonce = redis_client.get(nonce_key).decode("utf8")
|
||||
|
||||
if nonce != stored_nonce:
|
||||
current_app.logger.error(f"Nonce Error: {nonce} != {stored_nonce}")
|
||||
abort(403)
|
||||
|
||||
try:
|
||||
access_token = response_json["access_token"]
|
||||
except KeyError as e:
|
||||
current_app.logger.exception(
|
||||
if response.json().get("access_token") is None:
|
||||
# Capture the response json here so it hopefully shows up in error reports
|
||||
current_app.logger.error(
|
||||
f"Error when getting access token {response.json()} #notify-admin-1505"
|
||||
)
|
||||
raise KeyError(f"'access_token' {response.json()}") from e
|
||||
raise KeyError(f"'access_token' {response.json()}")
|
||||
access_token = response.json()["access_token"]
|
||||
return access_token
|
||||
|
||||
|
||||
def _get_user_email_and_uuid(access_token): # pragma: no cover
|
||||
def _get_user_email_and_uuid(access_token):
|
||||
headers = {"Authorization": "Bearer %s" % access_token}
|
||||
user_info_url = os.getenv("LOGIN_DOT_GOV_USER_INFO_URL")
|
||||
user_attributes = requests.get(
|
||||
@@ -97,11 +82,10 @@ def _get_user_email_and_uuid(access_token): # pragma: no cover
|
||||
return user_email, user_uuid
|
||||
|
||||
|
||||
def _do_login_dot_gov(): # $ pragma: no cover
|
||||
def _do_login_dot_gov():
|
||||
# start login.gov
|
||||
code = request.args.get("code")
|
||||
state = request.args.get("state")
|
||||
|
||||
login_gov_error = request.args.get("error")
|
||||
|
||||
if login_gov_error:
|
||||
@@ -110,19 +94,10 @@ def _do_login_dot_gov(): # $ pragma: no cover
|
||||
)
|
||||
raise Exception(f"Could not login with login.gov {login_gov_error}")
|
||||
elif code and state:
|
||||
verify_key = f"login-verify_email-{unquote(state)}"
|
||||
verify_path = bool(redis_client.get(verify_key))
|
||||
|
||||
if not verify_path and not os.getenv("NOTIFY_ENVIRONMENT") == "development":
|
||||
state_key = f"login-state-{unquote(state)}"
|
||||
stored_state = unquote(redis_client.get(state_key).decode("utf8"))
|
||||
if state != stored_state:
|
||||
current_app.logger.error(f"State Error: {state} != {stored_state}")
|
||||
abort(403)
|
||||
|
||||
# activate the user
|
||||
try:
|
||||
access_token = _get_access_token(code)
|
||||
access_token = _get_access_token(code, state)
|
||||
user_email, user_uuid = _get_user_email_and_uuid(access_token)
|
||||
if not is_gov_user(user_email):
|
||||
current_app.logger.error(
|
||||
@@ -136,17 +111,12 @@ def _do_login_dot_gov(): # $ pragma: no cover
|
||||
f"Retrieved user {user['id']} from db #notify-admin-1505"
|
||||
)
|
||||
|
||||
# Temporary disabling of this until we figure out what is happening.
|
||||
# # Check if the email needs to be revalidated
|
||||
# is_fresh_email = is_less_than_days_ago(
|
||||
# user["email_access_validated_at"], 90
|
||||
# )
|
||||
# if not is_fresh_email:
|
||||
# # send email verify
|
||||
# ttl = 24 * 60 * 60
|
||||
# verify_key = f"login-verify_email-{unquote(state)}"
|
||||
# redis_client.set(verify_key, state, ex=ttl)
|
||||
# return verify_email(user, redirect_url)
|
||||
# Check if the email needs to be revalidated
|
||||
is_fresh_email = is_less_than_days_ago(
|
||||
user["email_access_validated_at"], 90
|
||||
)
|
||||
if not is_fresh_email:
|
||||
return verify_email(user, redirect_url)
|
||||
|
||||
usr = User.from_email_address(user["email_address"])
|
||||
current_app.logger.info(f"activating user {usr.id} #notify-admin-1505")
|
||||
@@ -154,13 +124,12 @@ def _do_login_dot_gov(): # $ pragma: no cover
|
||||
except BaseException as be: # noqa B036
|
||||
current_app.logger.error(f"Error signing in: {be} #notify-admin-1505 ")
|
||||
error(401)
|
||||
|
||||
return redirect(url_for("main.show_accounts_or_dashboard", next=redirect_url))
|
||||
|
||||
# end login.gov
|
||||
|
||||
|
||||
def verify_email(user, redirect_url): # pragma: no cover
|
||||
def verify_email(user, redirect_url):
|
||||
user_api_client.send_verify_code(user["id"], "email", None, redirect_url)
|
||||
title = "Email resent" if request.args.get("email_resent") else "Check your email"
|
||||
redirect_url = request.args.get("next")
|
||||
@@ -169,41 +138,19 @@ def verify_email(user, redirect_url): # pragma: no cover
|
||||
)
|
||||
|
||||
|
||||
def _handle_e2e_tests(redirect_url): # pragma: no cover
|
||||
try:
|
||||
current_app.logger.warning("E2E TESTS ARE ENABLED.")
|
||||
current_app.logger.warning(
|
||||
"If you are getting a 404 on signin, comment out E2E vars in .env file!"
|
||||
)
|
||||
user = user_api_client.get_user_by_email(os.getenv("NOTIFY_E2E_TEST_EMAIL"))
|
||||
activate_user(user["id"])
|
||||
|
||||
# Check if the redirect URL is present and safe before proceeding further
|
||||
if redirect_url and is_safe_redirect_url(redirect_url):
|
||||
return redirect(redirect_url)
|
||||
|
||||
return redirect(
|
||||
url_for(
|
||||
"main.show_accounts_or_dashboard",
|
||||
next="EMAIL_IS_OK",
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
stre = str(e)
|
||||
stre = stre.replace(" ", "_")
|
||||
# Trying to get a message back to playwright somehow since we can't raise an error
|
||||
return redirect(url_for(f"https://{stre}"))
|
||||
def _handle_e2e_tests(redirect_url):
|
||||
current_app.logger.warning("E2E TESTS ARE ENABLED.")
|
||||
current_app.logger.warning(
|
||||
"If you are getting a 404 on signin, comment out E2E vars in .env file!"
|
||||
)
|
||||
user = user_api_client.get_user_by_email(os.getenv("NOTIFY_E2E_TEST_EMAIL"))
|
||||
activate_user(user["id"])
|
||||
return redirect(url_for("main.show_accounts_or_dashboard", next=redirect_url))
|
||||
|
||||
|
||||
@main.route("/sign-in", methods=(["GET", "POST"]))
|
||||
@hide_from_search_engines
|
||||
def sign_in(): # pragma: no cover
|
||||
redirect_url = request.args.get("next")
|
||||
|
||||
if os.getenv("NOTIFY_E2E_TEST_EMAIL"):
|
||||
return _handle_e2e_tests(redirect_url)
|
||||
|
||||
def sign_in():
|
||||
# If we have to revalidated the email, send the message
|
||||
# via email and redirect to the "verify your email page"
|
||||
# and don't proceed further with login
|
||||
@@ -215,31 +162,26 @@ def sign_in(): # pragma: no cover
|
||||
):
|
||||
return email_verify_template
|
||||
|
||||
redirect_url = request.args.get("next")
|
||||
|
||||
if os.getenv("NOTIFY_E2E_TEST_EMAIL"):
|
||||
return _handle_e2e_tests(redirect_url)
|
||||
|
||||
if current_user and current_user.is_authenticated:
|
||||
if redirect_url and is_safe_redirect_url(redirect_url):
|
||||
return redirect(redirect_url)
|
||||
return redirect(url_for("main.show_accounts_or_dashboard"))
|
||||
|
||||
ttl = 24 * 60 * 60
|
||||
|
||||
state = generate_token(
|
||||
token = generate_token(
|
||||
str(request.remote_addr),
|
||||
current_app.config["SECRET_KEY"],
|
||||
current_app.config["DANGEROUS_SALT"],
|
||||
)
|
||||
state_key = f"login-state-{unquote(state)}"
|
||||
redis_client.set(state_key, state, ex=ttl)
|
||||
|
||||
nonce = secrets.token_urlsafe()
|
||||
nonce_key = f"login-nonce-{unquote(nonce)}"
|
||||
redis_client.set(nonce_key, nonce, ex=ttl)
|
||||
|
||||
url = os.getenv("LOGIN_DOT_GOV_INITIAL_SIGNIN_URL")
|
||||
# handle unit tests
|
||||
if url is not None:
|
||||
url = url.replace("NONCE", nonce)
|
||||
url = url.replace("STATE", state)
|
||||
|
||||
url = url.replace("NONCE", token)
|
||||
url = url.replace("STATE", token)
|
||||
return render_template(
|
||||
"views/signin.html",
|
||||
again=bool(redirect_url),
|
||||
@@ -248,5 +190,5 @@ def sign_in(): # pragma: no cover
|
||||
|
||||
|
||||
@login_manager.unauthorized_handler
|
||||
def sign_in_again(): # pragma: no cover
|
||||
def sign_in_again():
|
||||
return redirect(url_for("main.sign_in", next=request.path))
|
||||
|
||||
@@ -1,67 +1,60 @@
|
||||
def using_notify_nav():
|
||||
nav_items = [
|
||||
{"name": "Get started", "link": "main.get_started"},
|
||||
{
|
||||
"name": "Best practices",
|
||||
"link": "main.best_practices",
|
||||
"sub_navigation_items": [
|
||||
{
|
||||
"name": "Clear goals",
|
||||
"link": "main.clear_goals",
|
||||
},
|
||||
{
|
||||
"name": "Rules and regulations",
|
||||
"link": "main.rules_and_regulations",
|
||||
},
|
||||
{
|
||||
"name": "Establish trust",
|
||||
"link": "main.establish_trust",
|
||||
},
|
||||
{
|
||||
"name": "Write for action",
|
||||
"link": "main.write_for_action",
|
||||
},
|
||||
{
|
||||
"name": "Multiple languages",
|
||||
"link": "main.multiple_languages",
|
||||
},
|
||||
{
|
||||
"name": "Benchmark performance",
|
||||
"link": "main.benchmark_performance",
|
||||
},
|
||||
],
|
||||
},
|
||||
{"name": "Trial mode", "link": "main.trial_mode_new"},
|
||||
{"name": "Tracking usage", "link": "main.pricing"},
|
||||
{"name": "Delivery status", "link": "main.message_status"},
|
||||
{"name": "How to", "link": "main.how_to"},
|
||||
]
|
||||
|
||||
return nav_items
|
||||
|
||||
|
||||
def about_notify_nav():
|
||||
def features_nav():
|
||||
return [
|
||||
{
|
||||
"name": "About Notify",
|
||||
"link": "main.about_notify",
|
||||
"name": "Features",
|
||||
"link": "main.features",
|
||||
"sub_navigation_items": [
|
||||
{
|
||||
"name": "Why text messaging",
|
||||
"link": "main.why_text_messaging",
|
||||
},
|
||||
{
|
||||
"name": "Security",
|
||||
"link": "main.about_security",
|
||||
},
|
||||
# {
|
||||
# "name": "Text messages",
|
||||
# "link": "main.features_sms",
|
||||
# },
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Join Notify",
|
||||
"link": "main.join_notify",
|
||||
"name": "Roadmap",
|
||||
"link": "main.roadmap",
|
||||
},
|
||||
{
|
||||
"name": "Contact us",
|
||||
"link": "main.contact",
|
||||
"name": "Security",
|
||||
"link": "main.security",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def using_notify_nav():
|
||||
return [
|
||||
{
|
||||
"name": "Get started",
|
||||
"link": "main.get_started",
|
||||
},
|
||||
{
|
||||
"name": "Trial mode",
|
||||
"link": "main.trial_mode_new",
|
||||
},
|
||||
{
|
||||
"name": "Tracking usage",
|
||||
"link": "main.pricing",
|
||||
},
|
||||
{
|
||||
"name": "Delivery status",
|
||||
"link": "main.message_status",
|
||||
},
|
||||
{
|
||||
"name": "Guidance",
|
||||
"link": "main.guidance_index",
|
||||
# "sub_navigation_items": [
|
||||
# {
|
||||
# "name": "Formatting",
|
||||
# "link": "main.edit_and_format_messages",
|
||||
# },
|
||||
# {
|
||||
# "name": "Send files by email",
|
||||
# "link": "main.send_files_by_email",
|
||||
# },
|
||||
# ]
|
||||
# {
|
||||
# "name": "API documentation",
|
||||
# "link": "main.documentation",
|
||||
# },
|
||||
},
|
||||
]
|
||||
|
||||
@@ -29,7 +29,6 @@ from app.main.forms import (
|
||||
TwoFactorForm,
|
||||
)
|
||||
from app.models.user import User
|
||||
from app.utils import hilite
|
||||
from app.utils.user import user_is_gov_user, user_is_logged_in
|
||||
from notifications_utils.url_safe_token import check_token
|
||||
|
||||
@@ -190,19 +189,32 @@ def user_profile_mobile_number_delete():
|
||||
@main.route("/user-profile/mobile-number/authenticate", methods=["GET", "POST"])
|
||||
@user_is_logged_in
|
||||
def user_profile_mobile_number_authenticate():
|
||||
# Validate password for form
|
||||
def _check_password(pwd):
|
||||
return user_api_client.verify_password(current_user.id, pwd)
|
||||
|
||||
form = ConfirmPasswordForm(_check_password)
|
||||
|
||||
if NEW_MOBILE not in session:
|
||||
return redirect(url_for(".user_profile_mobile_number"))
|
||||
|
||||
session[NEW_MOBILE_PASSWORD_CONFIRMED] = True
|
||||
current_user.send_verify_code(to=session[NEW_MOBILE])
|
||||
create_mobile_number_change_event(
|
||||
user_id=current_user.id,
|
||||
updated_by_id=current_user.id,
|
||||
original_mobile_number=current_user.mobile_number,
|
||||
new_mobile_number=session[NEW_MOBILE],
|
||||
if form.validate_on_submit():
|
||||
session[NEW_MOBILE_PASSWORD_CONFIRMED] = True
|
||||
current_user.send_verify_code(to=session[NEW_MOBILE])
|
||||
create_mobile_number_change_event(
|
||||
user_id=current_user.id,
|
||||
updated_by_id=current_user.id,
|
||||
original_mobile_number=current_user.mobile_number,
|
||||
new_mobile_number=session[NEW_MOBILE],
|
||||
)
|
||||
return redirect(url_for(".user_profile_mobile_number_confirm"))
|
||||
|
||||
return render_template(
|
||||
"views/user-profile/authenticate.html",
|
||||
thing="mobile number",
|
||||
form=form,
|
||||
back_link=url_for(".user_profile_mobile_number_confirm"),
|
||||
)
|
||||
return redirect(url_for(".user_profile_mobile_number_confirm"))
|
||||
|
||||
|
||||
@main.route("/user-profile/mobile-number/confirm", methods=["GET", "POST"])
|
||||
@@ -276,15 +288,3 @@ def user_profile_disable_platform_admin_view():
|
||||
return render_template(
|
||||
"views/user-profile/disable-platform-admin-view.html", form=form
|
||||
)
|
||||
|
||||
|
||||
def set_timezone():
|
||||
# Cookie is set in dashboard.html on page load
|
||||
try:
|
||||
timezone = request.cookies.get("timezone", "US/Eastern")
|
||||
current_app.logger.debug(hilite(f"User's timezone is {timezone}"))
|
||||
serialized_user = current_user.serialize()
|
||||
if serialized_user["preferred_timezone"] is not timezone:
|
||||
current_user.update(preferred_timezone=timezone)
|
||||
except Exception:
|
||||
current_app.logger.exception(hilite("Can't get timezone"))
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from flask import abort, current_app, request, session
|
||||
@@ -59,7 +58,6 @@ class User(JSONModel, UserMixin):
|
||||
super().__init__(_dict)
|
||||
self.permissions = _dict.get("permissions", {})
|
||||
self._platform_admin = _dict["platform_admin"]
|
||||
self.preferred_timezone = _dict.get("preferred_timezone", "America/New_York")
|
||||
|
||||
@classmethod
|
||||
def from_id(cls, user_id):
|
||||
@@ -201,7 +199,7 @@ class User(JSONModel, UserMixin):
|
||||
@property
|
||||
def is_gov_user(self):
|
||||
is_gov = is_gov_user(self.email_address)
|
||||
# current_app.logger.info(f"User {self.id} is_gov_user: {is_gov}")
|
||||
current_app.logger.info(f"User {self.id} is_gov_user: {is_gov}")
|
||||
return is_gov
|
||||
|
||||
@property
|
||||
@@ -210,9 +208,9 @@ class User(JSONModel, UserMixin):
|
||||
|
||||
@property
|
||||
def platform_admin(self):
|
||||
# current_app.logger.warning(
|
||||
# f"Checking User {self.id} for platform admin: {self._platform_admin}"
|
||||
# )
|
||||
current_app.logger.warn(
|
||||
f"Checking User {self.id} for platform admin: {self._platform_admin}"
|
||||
)
|
||||
return self._platform_admin and not session.get(
|
||||
"disable_platform_admin_view", False
|
||||
)
|
||||
@@ -220,14 +218,6 @@ class User(JSONModel, UserMixin):
|
||||
def has_permissions(
|
||||
self, *permissions, restrict_admin_usage=False, allow_org_user=False
|
||||
):
|
||||
# TODO need this for load test, but breaks unit tests
|
||||
if self.platform_admin and os.getenv("NOTIFY_ENVIRONMENT") in (
|
||||
"development",
|
||||
"staging",
|
||||
"demo",
|
||||
):
|
||||
return True
|
||||
|
||||
unknown_permissions = set(permissions) - all_ui_permissions
|
||||
if unknown_permissions:
|
||||
raise TypeError(
|
||||
@@ -242,31 +232,26 @@ class User(JSONModel, UserMixin):
|
||||
# we shouldn't have any pages that require permissions, but don't specify a service or organization.
|
||||
# use @user_is_platform_admin for platform admin only pages
|
||||
# raise NotImplementedError
|
||||
# current_app.logger.warning(f"VIEW ARGS ARE {request.view_args}")
|
||||
current_app.logger.warn(f"VIEW ARGS ARE {request.view_args}")
|
||||
pass
|
||||
|
||||
log_msg = f"has_permissions user: {self.id} service: {service_id}"
|
||||
# platform admins should be able to do most things (except eg send messages, or create api keys)
|
||||
if self.platform_admin and not restrict_admin_usage:
|
||||
current_app.logger.debug(
|
||||
"has_permissions is true because user is platform_admin"
|
||||
)
|
||||
current_app.logger.warn(f"{log_msg} true because user is platform_admin")
|
||||
return True
|
||||
|
||||
if org_id:
|
||||
value = self.belongs_to_organization(org_id)
|
||||
current_app.logger.debug(
|
||||
f"has_permissions returns org: {org_id} returning {value}"
|
||||
)
|
||||
current_app.logger.warn(f"{log_msg} org: {org_id} returning {value}")
|
||||
return value
|
||||
|
||||
if not permissions and self.belongs_to_service(service_id):
|
||||
current_app.logger.debug("has_permissions True because belongs_to_service")
|
||||
current_app.logger.warn(f"{log_msg} True because belongs_to_service")
|
||||
return True
|
||||
|
||||
if any(self.permissions_for_service(service_id) & set(permissions)):
|
||||
current_app.logger.debug(
|
||||
"has_permissions returns True because permissions valid"
|
||||
)
|
||||
current_app.logger.warn(f"{log_msg} permissions valid")
|
||||
return True
|
||||
|
||||
from app.models.service import Service
|
||||
@@ -274,7 +259,7 @@ class User(JSONModel, UserMixin):
|
||||
org_value = allow_org_user and self.belongs_to_organization(
|
||||
Service.from_id(service_id).organization_id
|
||||
)
|
||||
current_app.logger.debug(f"has_permissions returning {org_value}")
|
||||
current_app.logger.warn(f"{log_msg} returning {org_value}")
|
||||
return org_value
|
||||
|
||||
def permissions_for_service(self, service_id):
|
||||
@@ -282,7 +267,7 @@ class User(JSONModel, UserMixin):
|
||||
|
||||
def has_permission_for_service(self, service_id, permission):
|
||||
has_permission = permission in self.permissions_for_service(service_id)
|
||||
current_app.logger.debug(
|
||||
current_app.logger.warn(
|
||||
f"has_permission_for_service user: {self.id} service: {service_id} "
|
||||
f"permission: {permission} retuning {has_permission}"
|
||||
)
|
||||
@@ -563,17 +548,17 @@ class InvitedUser(JSONModel):
|
||||
return cls.by_id(invited_user_id) if invited_user_id else None
|
||||
|
||||
def has_permissions(self, *permissions):
|
||||
# current_app.logger.warning(
|
||||
# f"Checking invited user {self.id} for permissions: {permissions}"
|
||||
# )
|
||||
current_app.logger.warn(
|
||||
f"Checking invited user {self.id} for permissions: {permissions}"
|
||||
)
|
||||
if self.status == "cancelled":
|
||||
return False
|
||||
return set(self.permissions) > set(permissions)
|
||||
|
||||
def has_permission_for_service(self, service_id, permission):
|
||||
# current_app.logger.warn(
|
||||
# f"Checking invited user {self.id} for permission: {permission} on service {service_id}"
|
||||
# )
|
||||
current_app.logger.warn(
|
||||
f"Checking invited user {self.id} for permission: {permission} on service {service_id}"
|
||||
)
|
||||
if self.status == "cancelled":
|
||||
return False
|
||||
return self.service == service_id and permission in self.permissions
|
||||
|
||||
@@ -40,24 +40,24 @@ class HeaderNavigation(Navigation):
|
||||
"support": {
|
||||
"support",
|
||||
},
|
||||
"best_practices": {
|
||||
"best_practices",
|
||||
"clear_goals",
|
||||
"rules_and_regulations",
|
||||
"establish_trust",
|
||||
"write_for_action",
|
||||
"multiple_languages",
|
||||
"benchmark_performance",
|
||||
"features": {
|
||||
"features",
|
||||
"features_sms",
|
||||
"roadmap",
|
||||
"security",
|
||||
},
|
||||
"using_notify": {
|
||||
"get_started",
|
||||
"using_notify",
|
||||
"pricing",
|
||||
"trial_mode_new",
|
||||
"message_status",
|
||||
"how_to",
|
||||
"guidance_index",
|
||||
},
|
||||
"accounts-or-dashboard": {
|
||||
"conversation",
|
||||
"inbox",
|
||||
"monthly",
|
||||
"service_dashboard",
|
||||
"template_usage",
|
||||
"view_notification",
|
||||
@@ -123,7 +123,6 @@ class HeaderNavigation(Navigation):
|
||||
"get_billing_report",
|
||||
"get_users_report",
|
||||
"get_daily_volumes",
|
||||
"download_all_users",
|
||||
"get_daily_sms_provider_volumes",
|
||||
"get_volumes_by_service",
|
||||
"organizations",
|
||||
@@ -159,6 +158,8 @@ class MainNavigation(Navigation):
|
||||
},
|
||||
"dashboard": {
|
||||
"conversation",
|
||||
"inbox",
|
||||
"monthly",
|
||||
"service_dashboard",
|
||||
"template_usage",
|
||||
"view_notification",
|
||||
|
||||
@@ -1,55 +1,24 @@
|
||||
import json
|
||||
|
||||
from app.extensions import redis_client
|
||||
from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
class BillingAPIClient(NotifyAdminAPIClient):
|
||||
def get_monthly_usage_for_service(self, service_id, year):
|
||||
monthly_usage = redis_client.get(f"monthly-usage-summary-{service_id}-{year}")
|
||||
if monthly_usage is not None:
|
||||
return json.loads(monthly_usage.decode("utf-8"))
|
||||
result = self.get(
|
||||
return self.get(
|
||||
"/service/{0}/billing/monthly-usage".format(service_id),
|
||||
params=dict(year=year),
|
||||
)
|
||||
redis_client.set(
|
||||
f"monthly-usage-summary-{service_id}-{year}",
|
||||
json.dumps(result),
|
||||
ex=30,
|
||||
)
|
||||
return result
|
||||
|
||||
def get_annual_usage_for_service(self, service_id, year=None):
|
||||
annual_usage = redis_client.get(f"yearly-usage-summary-{service_id}-{year}")
|
||||
if annual_usage is not None:
|
||||
return json.loads(annual_usage.decode("utf-8"))
|
||||
result = self.get(
|
||||
return self.get(
|
||||
"/service/{0}/billing/yearly-usage-summary".format(service_id),
|
||||
params=dict(year=year),
|
||||
)
|
||||
|
||||
redis_client.set(
|
||||
f"yearly-usage-summary-{service_id}-{year}",
|
||||
json.dumps(result),
|
||||
ex=30,
|
||||
)
|
||||
return result
|
||||
|
||||
def get_free_sms_fragment_limit_for_year(self, service_id, year=None):
|
||||
frag_limit = redis_client.get(f"free-sms-fragment-limit-{service_id}-{year}")
|
||||
if frag_limit is not None:
|
||||
return json.loads(frag_limit.decode("utf-8"))
|
||||
result = self.get(
|
||||
"/service/{0}/billing/free-sms-fragment-limit".format(service_id),
|
||||
params=dict(financial_year_start=year),
|
||||
)
|
||||
|
||||
redis_client.set(
|
||||
f"free-sms-fragment-limit-{service_id}-{year}",
|
||||
json.dumps(result["free_sms_fragment_limit"]),
|
||||
ex=30,
|
||||
)
|
||||
return result["free_sms_fragment_limit"]
|
||||
|
||||
def create_or_update_free_sms_fragment_limit(
|
||||
@@ -67,28 +36,13 @@ class BillingAPIClient(NotifyAdminAPIClient):
|
||||
)
|
||||
|
||||
def get_data_for_billing_report(self, start_date, end_date):
|
||||
x_start_date = str(start_date)
|
||||
x_start_date = x_start_date.replace(" ", "_")
|
||||
x_end_date = str(end_date)
|
||||
x_end_date = x_end_date.replace(" ", "_")
|
||||
billing_data = redis_client.get(
|
||||
f"get-data-for-billing-report-{x_start_date}-{x_end_date}"
|
||||
)
|
||||
if billing_data is not None:
|
||||
return json.loads(billing_data.decode("utf-8"))
|
||||
result = self.get(
|
||||
return self.get(
|
||||
url="/platform-stats/data-for-billing-report",
|
||||
params={
|
||||
"start_date": str(start_date),
|
||||
"end_date": str(end_date),
|
||||
},
|
||||
)
|
||||
redis_client.set(
|
||||
f"get-data-for-billing-report-{x_start_date}-{x_end_date}",
|
||||
json.dumps(result),
|
||||
ex=30,
|
||||
)
|
||||
return result
|
||||
|
||||
def get_data_for_volumes_by_service_report(self, start_date, end_date):
|
||||
return self.get(
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
import json
|
||||
import secrets
|
||||
from urllib.parse import unquote
|
||||
|
||||
from flask import current_app, request
|
||||
|
||||
from app import redis_client
|
||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
from app.utils.user_permissions import (
|
||||
all_ui_permissions,
|
||||
translate_permissions_from_ui_to_db,
|
||||
)
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
|
||||
|
||||
class InviteApiClient(NotifyAdminAPIClient):
|
||||
@@ -40,35 +32,8 @@ class InviteApiClient(NotifyAdminAPIClient):
|
||||
"folder_permissions": folder_permissions,
|
||||
}
|
||||
data = _attach_current_user(data)
|
||||
|
||||
ttl = 24 * 60 * 60
|
||||
|
||||
# make and store the state
|
||||
state = generate_token(
|
||||
str(request.remote_addr),
|
||||
current_app.config["SECRET_KEY"],
|
||||
current_app.config["DANGEROUS_SALT"],
|
||||
)
|
||||
state_key = f"login-state-{unquote(state)}"
|
||||
redis_client.set(state_key, state, ex=ttl)
|
||||
|
||||
# make and store the nonce
|
||||
nonce = secrets.token_urlsafe()
|
||||
nonce_key = f"login-nonce-{unquote(nonce)}"
|
||||
redis_client.set(nonce_key, nonce, ex=ttl) # save the nonce to redis.
|
||||
|
||||
data["nonce"] = nonce # This is passed to api for the invite url.
|
||||
data["state"] = state # This is passed to api for the invite url.
|
||||
|
||||
resp = self.post(url=f"/service/{service_id}/invite", data=data)
|
||||
|
||||
resp_data = resp["data"]
|
||||
invite_data_key = f"invitedata-{unquote(state)}"
|
||||
redis_invite_data = resp["invite"]
|
||||
redis_invite_data = json.dumps(redis_invite_data)
|
||||
redis_client.set(invite_data_key, redis_invite_data, ex=ttl)
|
||||
|
||||
return resp_data
|
||||
return resp["data"]
|
||||
|
||||
def get_invites_for_service(self, service_id):
|
||||
return self.get(f"/service/{service_id}/invite")["data"]
|
||||
@@ -99,34 +64,7 @@ class InviteApiClient(NotifyAdminAPIClient):
|
||||
self.post(url=f"/service/{service_id}/invite/{invited_user_id}", data=data)
|
||||
|
||||
def resend_invite(self, service_id, invited_user_id):
|
||||
ttl = 24 * 60 * 60
|
||||
|
||||
# make and store the state
|
||||
state = generate_token(
|
||||
str(request.remote_addr),
|
||||
current_app.config["SECRET_KEY"],
|
||||
current_app.config["DANGEROUS_SALT"],
|
||||
)
|
||||
state_key = f"login-state-{unquote(state)}"
|
||||
redis_client.set(state_key, state, ex=ttl)
|
||||
|
||||
# make and store the nonce
|
||||
nonce = secrets.token_urlsafe()
|
||||
nonce_key = f"login-nonce-{unquote(nonce)}"
|
||||
redis_client.set(nonce_key, nonce, ex=ttl)
|
||||
|
||||
data = {
|
||||
"nonce": nonce,
|
||||
"state": state,
|
||||
}
|
||||
resp = self.post(
|
||||
url=f"/service/{service_id}/invite/{invited_user_id}/resend", data=data
|
||||
)
|
||||
|
||||
invite_data_key = f"invitedata-{unquote(state)}"
|
||||
redis_invite_data = resp["invite"]
|
||||
redis_invite_data = json.dumps(redis_invite_data)
|
||||
redis_client.set(invite_data_key, redis_invite_data, ex=ttl)
|
||||
self.post(url=f"/service/{service_id}/invite/{invited_user_id}/resend", data={})
|
||||
|
||||
@cache.delete("service-{service_id}")
|
||||
@cache.delete("user-{invited_user_id}")
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import json
|
||||
|
||||
from app.extensions import redis_client
|
||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
||||
|
||||
|
||||
@@ -44,7 +41,7 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
if job_id:
|
||||
return method(
|
||||
url="/service/{}/job/{}/notifications".format(service_id, job_id),
|
||||
**kwargs,
|
||||
**kwargs
|
||||
)
|
||||
else:
|
||||
if limit_days is not None:
|
||||
@@ -99,20 +96,9 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
)
|
||||
|
||||
def get_notification_count_for_job_id(self, *, service_id, job_id):
|
||||
counts = redis_client.get(
|
||||
f"notification-count-for-job-id-{service_id}-{job_id}"
|
||||
)
|
||||
if counts is not None:
|
||||
return json.loads(counts.decode("utf-8"))
|
||||
result = self.get(
|
||||
return self.get(
|
||||
url="/service/{}/job/{}/notification_count".format(service_id, job_id)
|
||||
)
|
||||
redis_client.set(
|
||||
f"notification-count-for-job-id-{service_id}-{job_id}",
|
||||
json.dumps(result["count"]),
|
||||
ex=30,
|
||||
)
|
||||
return result["count"]
|
||||
)["count"]
|
||||
|
||||
|
||||
notification_api_client = NotificationApiClient()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from app.extensions import redis_client
|
||||
@@ -518,18 +517,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
return int(count)
|
||||
|
||||
def get_global_notification_count(self, service_id):
|
||||
notification_count = redis_client.get(f"notification-count-{service_id}")
|
||||
if notification_count is not None:
|
||||
return json.loads(notification_count.decode("utf-8"))
|
||||
|
||||
notification_count = self.get(
|
||||
"/service/{}/notification-count".format(service_id)
|
||||
)
|
||||
redis_client.set(
|
||||
f"notification-count-{service_id}", json.dumps(notification_count), ex=30
|
||||
)
|
||||
|
||||
return notification_count
|
||||
return self.get("/service/{}/notification-count".format(service_id))
|
||||
|
||||
def get_service_invite_data(self, redis_key):
|
||||
"""
|
||||
@@ -537,11 +525,6 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
"""
|
||||
return self.get("/service/invite/redis/{0}".format(redis_key))
|
||||
|
||||
def get_service_message_ratio(self, service_id):
|
||||
return self.get(
|
||||
url="service/get-service-message-ratio?service_id={0}".format(service_id),
|
||||
)
|
||||
|
||||
|
||||
service_api_client = ServiceAPIClient()
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ from flask import current_app
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.notify_client import NotifyAdminAPIClient, cache
|
||||
from app.utils import hilite
|
||||
from app.utils.user_permissions import translate_permissions_from_ui_to_db
|
||||
|
||||
ALLOWED_ATTRIBUTES = {
|
||||
@@ -110,14 +109,13 @@ class UserApiClient(NotifyAdminAPIClient):
|
||||
raise
|
||||
|
||||
def send_verify_code(self, user_id, code_type, to, next_string=None):
|
||||
|
||||
data = {"to": to}
|
||||
if next_string:
|
||||
data["next"] = next_string
|
||||
if code_type == "email":
|
||||
data["email_auth_link_host"] = self.admin_url
|
||||
endpoint = f"/user/{user_id}/{code_type}-code"
|
||||
current_app.logger.warn(hilite(f"Sending verify_code {code_type} to {user_id}"))
|
||||
endpoint = "/user/{0}/{1}-code".format(user_id, code_type)
|
||||
current_app.logger.warn(f"Sending verify_code {code_type} to {user_id}")
|
||||
self.post(endpoint, data=data)
|
||||
|
||||
def send_verify_email(self, user_id, to):
|
||||
@@ -159,16 +157,12 @@ class UserApiClient(NotifyAdminAPIClient):
|
||||
endpoint = "/user"
|
||||
return self.get(endpoint)["data"]
|
||||
|
||||
def get_all_users_detailed(self):
|
||||
endpoint = "/user/report-all-users"
|
||||
return self.get(endpoint)["data"]
|
||||
|
||||
@cache.delete("service-{service_id}")
|
||||
@cache.delete("service-{service_id}-template-folders")
|
||||
@cache.delete("user-{user_id}")
|
||||
def add_user_to_service(self, service_id, user_id, permissions, folder_permissions):
|
||||
# permissions passed in are the combined UI permissions, not DB permissions
|
||||
endpoint = f"/service/{service_id}/users/{user_id}"
|
||||
endpoint = "/service/{}/users/{}".format(service_id, user_id)
|
||||
data = {
|
||||
"permissions": [
|
||||
{"permission": x}
|
||||
|
||||
@@ -29,10 +29,7 @@ def get_s3_object(
|
||||
aws_secret_access_key=secret_key,
|
||||
region_name=region,
|
||||
)
|
||||
s3 = session.resource(
|
||||
"s3",
|
||||
config=AWS_CLIENT_CONFIG,
|
||||
)
|
||||
s3 = session.resource("s3", config=AWS_CLIENT_CONFIG)
|
||||
obj = s3.Object(bucket_name, filename)
|
||||
# This 'proves' that use of moto in the relevant tests in test_send.py
|
||||
# mocks everything related to S3. What you will see in the logs is:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from flask import current_app
|
||||
@@ -11,13 +10,13 @@ from app.s3_client import (
|
||||
)
|
||||
from notifications_utils.s3 import s3upload as utils_s3upload
|
||||
|
||||
NEW_FILE_LOCATION_STRUCTURE = "{}-service-notify/{}.csv"
|
||||
FILE_LOCATION_STRUCTURE = "service-{}-notify/{}.csv"
|
||||
|
||||
|
||||
def get_csv_location(service_id, upload_id):
|
||||
return (
|
||||
current_app.config["CSV_UPLOAD_BUCKET"]["bucket"],
|
||||
NEW_FILE_LOCATION_STRUCTURE.format(service_id, upload_id),
|
||||
FILE_LOCATION_STRUCTURE.format(service_id, upload_id),
|
||||
current_app.config["CSV_UPLOAD_BUCKET"]["access_key_id"],
|
||||
current_app.config["CSV_UPLOAD_BUCKET"]["secret_access_key"],
|
||||
current_app.config["CSV_UPLOAD_BUCKET"]["region"],
|
||||
@@ -34,14 +33,6 @@ def s3upload(service_id, filedata):
|
||||
bucket_name, file_location, access_key, secret_key, region = get_csv_location(
|
||||
service_id, upload_id
|
||||
)
|
||||
if bucket_name == "":
|
||||
exp_bucket = current_app.config["CSV_UPLOAD_BUCKET"]["bucket"]
|
||||
exp_region = current_app.config["CSV_UPLOAD_BUCKET"]["region"]
|
||||
tier = os.getenv("NOTIFY_ENVIRONMENT")
|
||||
raise Exception(
|
||||
f"NO BUCKET NAME SHOULD BE: {exp_bucket} WITH REGION {exp_region} TIER {tier}"
|
||||
)
|
||||
|
||||
utils_s3upload(
|
||||
filedata=filedata["data"],
|
||||
region=region,
|
||||
|
||||
@@ -6,16 +6,20 @@
|
||||
<html lang="{{ htmlLang | default('en') }}" class="{{ htmlClasses }}">
|
||||
<head>
|
||||
<title>
|
||||
{% block pageTitle %}{% block per_page_title %}{% endblock %} – Notify.gov{% endblock %}
|
||||
{% block pageTitle %}
|
||||
{% block per_page_title %}{% endblock %} – Notify.gov
|
||||
{% endblock %}
|
||||
</title>
|
||||
{% include "components/head.html" %}
|
||||
{% include "new/components/head.html" %}
|
||||
</head>
|
||||
<body class="usa-template__body {{ bodyClasses }}">
|
||||
<script nonce="{{ csp_nonce() }}">document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>
|
||||
{% block bodyStart %}
|
||||
{% block extra_javascripts_before_body %}
|
||||
<!-- Google Tag Manager (noscript) -->
|
||||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WX5NGWF"
|
||||
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||||
<!-- End Google Tag Manager (noscript) -->
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -28,8 +32,8 @@
|
||||
|
||||
|
||||
{% block header %}
|
||||
{% include 'components/usa_banner.html' %}
|
||||
{% include 'components/header.html' %}
|
||||
{% include 'new/components/usa_banner.html' %}
|
||||
{% include 'new/components/header.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
@@ -43,42 +47,15 @@
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% block flash_messages %}
|
||||
{% include 'components/flash_messages.html' %}
|
||||
{% include 'new/components/flash_messages.html' %}
|
||||
{% endblock %}
|
||||
{% block maincolumn_content %}
|
||||
<div class="grid-row">
|
||||
{% if navigation_links %}
|
||||
<div class="tablet:grid-col-2 margin-bottom-4">
|
||||
<nav class="nav">
|
||||
<ul class="usa-sidenav">
|
||||
{% for item in navigation_links %}
|
||||
<li class="usa-sidenav__item">
|
||||
<a href="{{ url_for(item.link) }}"
|
||||
class="parent-link {% if request.endpoint.startswith(item['link']) or item.sub_navigation_items | selectattr('link', 'equalto', request.endpoint) | list | length > 0 %} usa-current {% endif %}"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="{{ 'true' if request.endpoint.startswith(item['link']) else 'false' }}">
|
||||
{{ item.name }}
|
||||
</a>
|
||||
{% if item.sub_navigation_items %}
|
||||
<ul class="usa-sidenav__sublist" role="menu">
|
||||
{% for sub_item in item.sub_navigation_items %}
|
||||
<li role="menuitem">
|
||||
<a href="{{ url_for(sub_item.link.split('#')[0]) }}#{{ sub_item.link.split('#')[1] }}"
|
||||
class="{% if request.endpoint == sub_item['link'] %}usa-current bold{% endif %}">
|
||||
{{ sub_item.name }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
{{ sub_navigation(navigation_links) }}
|
||||
</div>
|
||||
<div class="tablet:grid-col-10 tablet:padding-left-4 usa-prose site-prose">
|
||||
<div class="tablet:grid-col-10 padding-left-4 usa-prose site-prose">
|
||||
{% else %}
|
||||
<div class="tablet:grid-col-10">
|
||||
{% endif %}
|
||||
@@ -101,11 +78,11 @@
|
||||
{% set meta_suffix = "Built by the " + long_link + commit_hash %}
|
||||
{% endif %}
|
||||
|
||||
{% include "components/footer.html" %}
|
||||
{% include "new/components/footer.html" %}
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
{% block sessionUserWarning %}
|
||||
<dialog class="usa-modal" id="sessionTimer" aria-labelledby="sessionTimerHeading" aria-describedby="timeLeft">
|
||||
<dialog class="usa-modal" id="sessionTimer" aria-labelledby="sessionTimerHeading" aria-describedby="timerWarning">
|
||||
<div class="usa-modal__content">
|
||||
<div class="usa-modal__main">
|
||||
<h2 class="usa-modal__heading" id="sessionTimerHeading">
|
||||
@@ -143,8 +120,10 @@
|
||||
{% block bodyEnd %}
|
||||
{% block extra_javascripts %}
|
||||
{% endblock %}
|
||||
<!--[if gt IE 8]><!-->
|
||||
<script type="text/javascript" src="{{ asset_url('javascripts/all.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ asset_url('js/uswds.min.js') }}"></script>
|
||||
<!--<![endif]-->
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
<nav class="usa-breadcrumb" aria-label="Breadcrumb">
|
||||
<a href="{{ params.href.url or params.href or '#' }}" class="usa-link usa-back-link display-inline-flex {{ params.classes or '' }}"
|
||||
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}" {% endfor %}>{{ params.html | safe or params.href.text or 'Back' }}</a>
|
||||
</nav>
|
||||
<a href="{%- if params.href %}{{ params.href }}{% else %}#{% endif -%}" class="usa-link usa-back-link display-inline-flex margin-bottom-3 {%- if params.classes %} {{ params.classes }}{% endif -%}"
|
||||
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>{{ (params.html | safe if params.html else (params.text if params.text else 'Back')) }}</a>
|
||||
|
||||
15
app/templates/components/components/footer/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Footer
|
||||
|
||||
## Installation
|
||||
|
||||
See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component.
|
||||
|
||||
## Guidance and Examples
|
||||
|
||||
Find out when to use the footer component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/footer).
|
||||
|
||||
## Component options
|
||||
|
||||
Use options to customize the appearance, content and behavior of a component when using a macro, for example, changing the text.
|
||||
|
||||
See [options table](https://design-system.service.gov.uk/components/footer/#options-example-default) for details.
|
||||
115
app/templates/components/components/footer/macro-options.json
Normal file
@@ -0,0 +1,115 @@
|
||||
[
|
||||
{
|
||||
"name": "meta",
|
||||
"type": "object",
|
||||
"required": false,
|
||||
"description": "Object containing options for the meta navigation.",
|
||||
"params": [
|
||||
{
|
||||
"name": "visuallyHiddenTitle",
|
||||
"type": "string",
|
||||
"description": "Title for a meta item section, which defaults to Support links"
|
||||
},
|
||||
{
|
||||
"name": "html",
|
||||
"type": "string",
|
||||
"description": "HTML to add to the meta section of the footer, which will appear below any links specified using meta.items."
|
||||
},
|
||||
{
|
||||
"name": "text",
|
||||
"type": "string",
|
||||
"description": "Text to add to the meta section of the footer, which will appear below any links specified using meta.items. If meta.html is specified, this option is ignored."
|
||||
},
|
||||
{
|
||||
"name": "items",
|
||||
"type": "array",
|
||||
"required": false,
|
||||
"description": "Array of items for use in the meta section of the footer.",
|
||||
"params": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "List item text in the meta section of the footer."
|
||||
},
|
||||
{
|
||||
"name": "href",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "List item href attribute in the meta section of the footer."
|
||||
},
|
||||
{
|
||||
"name": "attributes",
|
||||
"type": "object",
|
||||
"required": false,
|
||||
"description": "HTML attributes (for example data attributes) to add to the anchor in the footer meta section."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "navigation",
|
||||
"type": "array",
|
||||
"required": false,
|
||||
"description": "Array of items for use in the navigation section of the footer.",
|
||||
"params": [
|
||||
{
|
||||
"name": "title",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Title for a section"
|
||||
},
|
||||
{
|
||||
"name": "columns",
|
||||
"type": "integer",
|
||||
"required": false,
|
||||
"description": "Amount of columns to display items in navigation section of the footer."
|
||||
},
|
||||
{
|
||||
"name": "items",
|
||||
"type": "array",
|
||||
"required": false,
|
||||
"description": "Array of items to display in the list in navigation section of the footer.",
|
||||
"params": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "List item text in the navigation section of the footer."
|
||||
},
|
||||
{
|
||||
"name": "href",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "List item href attribute in the navigation section of the footer. Both `text` and `href` attributes need to be present to create a link."
|
||||
},
|
||||
{
|
||||
"name": "attributes",
|
||||
"type": "object",
|
||||
"required": false,
|
||||
"description": "HTML attributes (for example data attributes) to add to the anchor in the footer navigation section."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "containerClasses",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Classes that can be added to the inner container, useful if you want to make the footer full width."
|
||||
},
|
||||
{
|
||||
"name": "classes",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Classes to add to the footer component container."
|
||||
},
|
||||
{
|
||||
"name": "attributes",
|
||||
"type": "object",
|
||||
"required": false,
|
||||
"description": "HTML attributes (for example data attributes) to add to the footer component container."
|
||||
}
|
||||
]
|
||||
3
app/templates/components/components/footer/macro.njk
Normal file
@@ -0,0 +1,3 @@
|
||||
{% macro usaFooter(params) %}
|
||||
{%- include "./template.njk" -%}
|
||||
{% endmacro %}
|
||||
85
app/templates/components/components/footer/template.njk
Normal file
@@ -0,0 +1,85 @@
|
||||
<footer class="usa-footer usa-footer--big">
|
||||
{# <div class="grid-container usa-footer__return-to-top">
|
||||
<a href="#">Return to top</a>
|
||||
</div> #}
|
||||
<div class="usa-footer__primary-section">
|
||||
<div class="grid-container">
|
||||
<div class="padding-y-1">
|
||||
{% if params.meta %}
|
||||
<h2 class="usa-sr-only">{{ params.meta.visuallyHiddenTitle | default("Support links") }}</h2>
|
||||
{% if params.meta.items %}
|
||||
{% for item in params.meta.items %}
|
||||
<a class="usa-footer__link" href="{{ item.href }}" {% for attribute, value in item.attributes %}
|
||||
{{attribute}}="{{value}}" {% endfor %}>
|
||||
{{ item.text }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if params.meta.text or params.meta.html %}
|
||||
<div>
|
||||
{{ params.meta.html | safe if params.meta.html else params.meta.text }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<div class="usa-identifier site-identifier">
|
||||
<section class="usa-identifier__section usa-identifier__section--masthead" aria-label="Agency identifier,,,,,,">
|
||||
<div class="usa-identifier__container">
|
||||
<div class="usa-identifier__logos"><a href="javascript:void(0);" class="usa-identifier__logo">
|
||||
<img class="usa-identifier__logo-img" src="{{ params.assetsPath | default('/static/images') }}/gsa-logo.svg" alt="GSA Logo" role="img" width="48"
|
||||
height="48">
|
||||
</a></div>
|
||||
<section class="usa-identifier__identity" aria-label="Agency description">
|
||||
<p class="usa-identifier__identity-domain">beta.notify.gov</p>
|
||||
<p class="usa-identifier__identity-disclaimer">An official website of the <a href="https://gsa.gov">General
|
||||
Services Administration</a></p>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
<nav class="usa-identifier__section usa-identifier__section--required-links" aria-label="Important links">
|
||||
<div class="usa-identifier__container">
|
||||
<ul class="usa-identifier__required-links-list">
|
||||
<li class="usa-identifier__required-links-item">
|
||||
<a href="https://www.gsa.gov/about-us" class="usa-identifier__required-link">About GSA</a>
|
||||
</li>
|
||||
<li class="usa-identifier__required-links-item">
|
||||
<a href="https://www.gsa.gov/website-information/accessibility-aids"
|
||||
class="usa-identifier__required-link">Accessibility support</a>
|
||||
</li>
|
||||
<li class="usa-identifier__required-links-item">
|
||||
<a href="https://www.gsa.gov/reference/freedom-of-information-act-foia"
|
||||
class="usa-identifier__required-link">FOIA requests</a>
|
||||
</li>
|
||||
<li class="usa-identifier__required-links-item">
|
||||
<a href="https://www.gsa.gov/reference/civil-rights-programs/notification-and-federal-employee-antidiscrimination-and-retaliation-act-of-2002"
|
||||
class="usa-identifier__required-link">No FEAR Act data</a>
|
||||
</li>
|
||||
<li class="usa-identifier__required-links-item">
|
||||
<a href="https://www.gsaig.gov/" class="usa-identifier__required-link">Office of the Inspector General</a>
|
||||
</li>
|
||||
<li class="usa-identifier__required-links-item">
|
||||
<a href="https://www.gsa.gov/reference/reports/budget-performance"
|
||||
class="usa-identifier__required-link">Performance reports</a>
|
||||
</li>
|
||||
<li class="usa-identifier__required-links-item">
|
||||
<a href="https://www.gsa.gov/website-information/website-policies"
|
||||
class="usa-identifier__required-link">Privacy policy</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<section class="usa-identifier__section usa-identifier__section--usagov"
|
||||
aria-label="Government information and services">
|
||||
<div class="usa-identifier__container">
|
||||
<div class="usa-identifier__usagov-description">
|
||||
Looking for U.S. government information and services?
|
||||
</div>
|
||||
<a href="https://www.usa.gov/" class="usa-link">Visit USA.gov</a>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
15
app/templates/components/components/header/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Header
|
||||
|
||||
## Installation
|
||||
|
||||
See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component.
|
||||
|
||||
## Guidance and Examples
|
||||
|
||||
Find out when to use the header component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/header).
|
||||
|
||||
## Component options
|
||||
|
||||
Use options to customize the appearance, content and behavior of a component when using a macro, for example, changing the text.
|
||||
|
||||
See [options table](https://design-system.service.gov.uk/components/header/#options-example-default) for details.
|
||||
@@ -0,0 +1,88 @@
|
||||
[
|
||||
{
|
||||
"name": "homepageUrl",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "The url of the homepage. Defaults to /"
|
||||
},
|
||||
{
|
||||
"name": "assetsPath",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "The public path for the assets folder. If not provided it defaults to /assets/images"
|
||||
},
|
||||
{
|
||||
"name": "productName",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Header title that is placed next to GOV.UK. Used for product names (i.e. Pay, Verify)"
|
||||
},
|
||||
{
|
||||
"name": "serviceName",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Header title that is placed next to GOV.UK. Used for product names (i.e. Pay, Verify)"
|
||||
},
|
||||
{
|
||||
"name": "serviceUrl",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Url for the service name anchor."
|
||||
},
|
||||
{
|
||||
"name": "navigation",
|
||||
"type": "array",
|
||||
"required": false,
|
||||
"description": "An array of navigation item objects.",
|
||||
"params": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Text of the navigation item."
|
||||
},
|
||||
{
|
||||
"name": "href",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Url of the navigation item anchor. Both `href` and `text` attributes for navigation items need to be provided to create an item."
|
||||
},
|
||||
{
|
||||
"name": "active",
|
||||
"type": "boolean",
|
||||
"required": false,
|
||||
"description": "Flag to mark the navigation item as active or not."
|
||||
},
|
||||
{
|
||||
"name": "attributes",
|
||||
"type": "object",
|
||||
"required": false,
|
||||
"description": "HTML attributes (for example data attributes) to add to the navigation item anchor."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "navigationClasses",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Classes for the navigation section of the header."
|
||||
},
|
||||
{
|
||||
"name": "containerClasses",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Classes for the container, useful if you want to make the header fixed width."
|
||||
},
|
||||
{
|
||||
"name": "classes",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Classes to add to the header container."
|
||||
},
|
||||
{
|
||||
"name": "attributes",
|
||||
"type": "object",
|
||||
"required": false,
|
||||
"description": "HTML attributes (for example data attributes) to add to the header container."
|
||||
}
|
||||
]
|
||||
3
app/templates/components/components/header/macro.njk
Normal file
@@ -0,0 +1,3 @@
|
||||
{% macro usaHeader(params) %}
|
||||
{%- include "./template.njk" -%}
|
||||
{% endmacro %}
|
||||
105
app/templates/components/components/header/template.njk
Normal file
@@ -0,0 +1,105 @@
|
||||
<!-- usa banner -->
|
||||
<section class="usa-banner site-banner" aria-label="Official website of the United States government,,,,,,">
|
||||
<div class="usa-accordion">
|
||||
<header class="usa-banner__header">
|
||||
<div class="usa-banner__inner">
|
||||
<div class="grid-col-auto">
|
||||
<img aria-hidden="true" class="usa-banner__header-flag" src="/static/img/us_flag_small.png" alt="" />
|
||||
</div>
|
||||
<div class="grid-col-fill tablet:grid-col-auto" aria-hidden="true">
|
||||
<p class="usa-banner__header-text">An official website of the United States government</p>
|
||||
<p class="usa-banner__header-action">Here’s how you know</p>
|
||||
</div>
|
||||
<button type="button" class="usa-accordion__button usa-banner__button" aria-expanded="false" aria-controls="gov-banner">
|
||||
<span class="usa-banner__button-text">Here’s how you know</span>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="usa-banner__content usa-accordion__content" id="gov-banner" hidden="">
|
||||
<div class="grid-row grid-gap-lg">
|
||||
<div class="usa-banner__guidance tablet:grid-col-6">
|
||||
<img class="usa-banner__icon usa-media-block__img" src="/static/img/icon-dot-gov.svg" role="img" alt="" aria-hidden="true">
|
||||
<div class="usa-media-block__body">
|
||||
<p>
|
||||
<strong>Official websites use .gov</strong>
|
||||
<br>
|
||||
A <strong>.gov</strong> website belongs to an official government organization in the United States.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="usa-banner__guidance tablet:grid-col-6">
|
||||
<img class="usa-banner__icon usa-media-block__img" src="/static/img/icon-https.svg" role="img" alt="" aria-hidden="true">
|
||||
<div class="usa-media-block__body">
|
||||
<p>
|
||||
<strong>Secure .gov websites use HTTPS</strong>
|
||||
<br>
|
||||
A <strong>lock</strong> ( <span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" width="52" height="64" viewBox="0 0 52 64" class="usa-banner__lock-image" role="img" aria-labelledby="banner-lock-description" focusable="false"><title id="banner-lock-title">Lock</title><desc id="banner-lock-description">Locked padlock</desc><path fill="#000000" fill-rule="evenodd" d="M26 0c10.493 0 19 8.507 19 19v9h3a4 4 0 0 1 4 4v28a4 4 0 0 1-4 4H4a4 4 0 0 1-4-4V32a4 4 0 0 1 4-4h3v-9C7 8.507 15.507 0 26 0zm0 8c-5.979 0-10.843 4.77-10.996 10.712L15 19v9h22v-9c0-6.075-4.925-11-11-11z"></path></svg></span> ) or <strong>https://</strong> means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- usa header -->
|
||||
<header class="usa-header usa-header--extended">
|
||||
<div class="usa-nav-container">
|
||||
<div class="usa-navbar">
|
||||
<div class="usa-logo display-flex flex-align-center flex-justify" id="-logo">
|
||||
<div class="logo-img display-flex">
|
||||
<a href="/">
|
||||
<span class="usa-sr-only">Notify.gov logo</span>
|
||||
<image src="{{ params.assetsPath | default('/static/images') }}/notify-logo.png" alt="Notify.gov logo" xlink:href=""
|
||||
class="usa-flag-logo margin-right-1"></image>
|
||||
</a>
|
||||
</div>
|
||||
{% if params.navigation %}
|
||||
<button type="button" class="usa-menu-btn">Menu</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<nav aria-label="Primary navigation" class="usa-nav">
|
||||
<div class="usa-nav__inner">
|
||||
<button type="button" class="usa-nav__close">
|
||||
<img src="/static/images/usa-icons/close.svg" role="img" alt="Close" />
|
||||
</button>
|
||||
<ul class="usa-nav__primary usa-accordion margin-right-1">
|
||||
{% for item in params.navigation %}
|
||||
{% if item.href and item.text %}
|
||||
<li class="usa-nav__primary-item{{ ' is-current' if item.active }}">
|
||||
<a class="usa-nav__link {{ ' usa-current' if item.active }}" href="{{ item.href }}" {% for attribute, value in
|
||||
item.attributes %} {{attribute}}="{{value}}" {% endfor %}>
|
||||
<span>{{ item.text }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="usa-nav__secondary margin-bottom-6">
|
||||
<ul class="usa-nav__secondary-links">
|
||||
{% for item in params.secondaryNavigation %}
|
||||
{% if item.href and item.text %}
|
||||
<li class="usa-nav__secondary-item{{ ' is-current' if item.active }}">
|
||||
<a class="usa-nav__link {{ ' usa-current' if item.active }}" href="{{ item.href }}" {% for attribute, value in
|
||||
item.attributes %} {{attribute}}="{{value}}" {% endfor %}>
|
||||
<span>{{ item.text }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<!-- <section aria-label="Search component">
|
||||
<form class="usa-search usa-search--small margin-bottom-2" role="search">
|
||||
<label class="usa-sr-only" for="search-field">Search</label>
|
||||
<input class="usa-input" id="search-field" type="search" name="search" />
|
||||
<button class="usa-button" type="submit">
|
||||
<img src="/static/images/usa-icons-bg/search--white.svg" class="usa-search__submit-icon" alt="Search" />
|
||||
</button>
|
||||
</form>
|
||||
</section> -->
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
@@ -12,7 +12,7 @@
|
||||
classes: params.label.classes,
|
||||
isPageHeading: params.label.isPageHeading,
|
||||
attributes: params.label.attributes,
|
||||
for: params.text
|
||||
for: params.id
|
||||
}) | indent(2) | trim }}
|
||||
{% if params.hint %}
|
||||
{% set hintId = params.id + '-hint' %}
|
||||
@@ -26,7 +26,7 @@
|
||||
}) | indent(2) | trim }}
|
||||
{% endif %}
|
||||
{% if params.errorMessage %}
|
||||
{% set errorId = params.label.text + '-error' %}
|
||||
{% set errorId = params.id + '-error' %}
|
||||
{% set describedBy = describedBy + ' ' + errorId if describedBy else errorId %}
|
||||
{{ usaErrorMessage({
|
||||
id: errorId,
|
||||
@@ -34,19 +34,13 @@
|
||||
attributes: params.errorMessage.attributes,
|
||||
html: params.errorMessage.html,
|
||||
text: params.errorMessage.text,
|
||||
visuallyHiddenText: params.errorMessage.visuallyHiddenText,
|
||||
visuallyHiddenText: params.errorMessage.visuallyHiddenText
|
||||
}) | indent(2) | trim }}
|
||||
{% endif %}
|
||||
<input
|
||||
class="usa-input {%- if params.classes %} {{ params.classes }}{% endif %} {%- if params.errorMessage %} usa-input--error{% endif %}"
|
||||
id="{{ params.label.text | default('unknown') | slugify }}"
|
||||
name="{{ params.name }}"
|
||||
type="{{ params.type | default('text') }}"
|
||||
{%- if params.value %} value="{{ params.value }}"{% endif %}
|
||||
{%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
|
||||
{%- if params.autocomplete %} autocomplete="{{ params.autocomplete }}"{% endif %}
|
||||
{%- if params.pattern %} pattern="{{ params.pattern }}"{% endif %}
|
||||
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}
|
||||
{%- if params.required %} required{% endif %}
|
||||
/>
|
||||
<input class="usa-input {%- if params.classes %} {{ params.classes }}{% endif %} {%- if params.errorMessage %} usa-input--error{% endif %}" id="{{ params.id }}" name="{{ params.name }}" type="{{ params.type | default('text') }}"
|
||||
{%- if params.value %} value="{{ params.value}}"{% endif %}
|
||||
{%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
|
||||
{%- if params.autocomplete %} autocomplete="{{ params.autocomplete}}"{% endif %}
|
||||
{%- if params.pattern %} pattern="{{ params.pattern }}"{% endif %}
|
||||
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% set labelHtml %}
|
||||
<label class="usa-label{%- if params.classes %} {{ params.classes }}{% endif %}"
|
||||
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}
|
||||
{%- if params.text %} for="{{ params.text | slugify }}"{% endif %}>
|
||||
{%- if params.for %} for="{{ params.for }}"{% endif %}>
|
||||
{{ params.html | safe if params.html else params.text }}
|
||||
</label>
|
||||
{% endset %}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<a href="{{ params.href | default('#content') }}" class="usa-skipnav{%- if params.classes %} {{ params.classes }}{% endif -%}"{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
||||
{{- params.html | safe if params.html else params.text -}}
|
||||
</a>
|
||||
|
||||
<a class="usa-skipnav " href="#main-content">
|
||||
Skip to main content
|
||||
</a>
|
||||
@@ -20,7 +20,7 @@
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if field.errors and show_errors %}
|
||||
<span class="error-message usa-error-message">
|
||||
<span class="error-message">
|
||||
{{ field.errors[0] }}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
template_type,
|
||||
current_user,
|
||||
link_current_item=False,
|
||||
root_element='nav'
|
||||
root_element='h1'
|
||||
) %}
|
||||
<{{ root_element }} id="breadcrumb-template-folders" class="navigation-service usa-breadcrumb padding-top-0 padding-bottom-05" aria-label="Template folder path">
|
||||
<{{ root_element }} class="font-body-lg folder-heading margin-bottom-0"{% if root_element == 'h1' %} id="page-header"{% endif %}>
|
||||
{% for folder in folders %}
|
||||
{% if loop.last and not link_current_item %}
|
||||
{% if folder.template_type or not folder.id %}
|
||||
@@ -22,10 +22,7 @@
|
||||
<span class="folder-heading-folder">{{ folder.name }}</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a href="{{ url_for('.choose_template', service_id=service_id, template_type=template_type) }}" class="usa-link {% if loop.length > 2 %}folder-heading-folder-root-truncated{% endif %}">
|
||||
<span class="usa-sr-only">Return to all</span>
|
||||
Templates
|
||||
</a>
|
||||
<a href="{{ url_for('.choose_template', service_id=service_id, template_type=template_type) }}" title="Templates" class="usa-link {% if loop.length > 2 %}folder-heading-folder-root-truncated{% endif %}">Templates</a>
|
||||
{% endif %}
|
||||
{% if not loop.last %}{{ folder_path_separator() }}{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<ul class="usa-card-group grid-row flex-row">
|
||||
{% for item in card_contents %}
|
||||
<li class="usa-card grid-col mobile-lg:grid-col-12 tablet:grid-col-6 desktop:grid-col-4 {% if item.link %}linked-card linked-content{% endif %}">
|
||||
{% if item.link %}
|
||||
<a href="{{ item.link }}">
|
||||
{% endif %}
|
||||
<div class="usa-card__container">
|
||||
{% if item.card_heading %}
|
||||
<div class="usa-card__header">
|
||||
<h3
|
||||
class="usa-card__heading {% if text_align != 'left' or text_align is not defined %}text-center{% else %}text-left{% endif %} {% if item.link %}linked-card{% endif %}">
|
||||
{{ item.card_heading }}
|
||||
</h3>
|
||||
{% if item.link %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if item.svg_src or item.image_src%}
|
||||
<div class="usa-card__media usa-card__media--inset">
|
||||
{% if item.svg_src %}
|
||||
<svg aria-hidden="true" focusable="false" role="img" class="best-practices_card_img">
|
||||
<use xlink:href="{{asset_url('images/best-practices-card-sprite.svg')}}#{{item.svg_src}}"></use>
|
||||
</svg>
|
||||
{% endif %}
|
||||
{% if item.image_src %}
|
||||
<img class="best-practices_card_img" src="{{item.image_src}}" alt="{{ item.alt_text }}" />
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if item.p_text %}
|
||||
<div class="usa-card__body">
|
||||
<p
|
||||
class="{% if text_align != 'left' or text_align is not defined %}text-center{% else %}text-left{% endif %} {% if item.link %}linked-card{% endif %}">
|
||||
{{item.p_text|safe}}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if item.link %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@@ -1,9 +0,0 @@
|
||||
{% macro circle_number(number) %}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="svg-circle-icon" width="24" height="24" viewBox="0 0 100 100">
|
||||
<circle cx="50" cy="50" r="37" stroke="#005ea2" stroke-width="7" fill="none" />
|
||||
<text x="50%" y="50%" text-anchor="middle" font-size="40" font-weight="bolder" fill="#005ea2" font-family="Arial"
|
||||
dy=".35em">
|
||||
{{ number }}
|
||||
</text>
|
||||
</svg>
|
||||
{% endmacro %}
|
||||