-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial TemplateCategory client (#1884)
* Initial TemplateCategory client * Hook the api client up to the admin front end - Implemented add and update a category - Tweaks to the api client - Added tests for the API client - Renamed desc_en/desc_fr to description_en/fr for consistency * Address PR comments - Fixed desc_en/desc_fr -> description_en/description_fr typos - Delete the template_categories key when updating a category - Updated tests to check we are properly deleting Redis cache keys when updating a template * Delete template_categories cache when creating a new cat * Map old process_types to new ones for the UI - Fix tests * Update desc_col naming * Fix letter tests * Fix a number of failing tests - Added mock to get all template categories - Added template_category_json() - Updated template_json() with a template_category param - Sorted config keys under config.py * Fix a good chunk of tests * chore: fix failing tests * chore: remove duplicate param; remove unused imports * chore: fix import --------- Co-authored-by: Andrew Leith <[email protected]>
- Loading branch information
1 parent
9bdf63c
commit c878f83
Showing
13 changed files
with
386 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,39 +21,38 @@ | |
|
||
|
||
class Config(object): | ||
# for waffles: pull out the routes into a flat list of the form ['/home', '/accueil', '/why-gc-notify', ...] | ||
EXTRA_ROUTES = [item for sublist in map(lambda x: x.values(), GC_ARTICLES_ROUTES.values()) for item in sublist] | ||
|
||
ACTIVITY_STATS_LIMIT_DAYS = 7 | ||
if os.environ.get("HEROKU_APP_NAME", "") != "": | ||
ADMIN_BASE_URL = "https://" + os.environ.get("HEROKU_APP_NAME", "") + ".herokuapp.com" | ||
else: | ||
ADMIN_BASE_URL = os.environ.get("ADMIN_BASE_URL", "http://localhost:6012") | ||
ADMIN_CLIENT_USER_NAME = "notify-admin" | ||
ADMIN_CLIENT_SECRET = os.environ.get("ADMIN_CLIENT_SECRET") | ||
ANTIVIRUS_API_HOST = os.environ.get("ANTIVIRUS_API_HOST") | ||
ANTIVIRUS_API_KEY = os.environ.get("ANTIVIRUS_API_KEY") | ||
ALLOW_DEBUG_ROUTE = env.bool("ALLOW_DEBUG_ROUTE", False) | ||
|
||
# List of allowed service IDs that are allowed to send HTML through their templates. | ||
ALLOW_HTML_SERVICE_IDS: List[str] = [id.strip() for id in os.getenv("ALLOW_HTML_SERVICE_IDS", "").split(",")] | ||
|
||
ADMIN_BASE_URL = ( | ||
"https://" + os.environ.get("HEROKU_APP_NAME", "") + ".herokuapp.com" | ||
if os.environ.get("HEROKU_APP_NAME", "") != "" | ||
else os.environ.get("ADMIN_BASE_URL", "http://localhost:6012") | ||
) | ||
ADMIN_CLIENT_SECRET = os.environ.get("ADMIN_CLIENT_SECRET") | ||
ADMIN_CLIENT_USER_NAME = "notify-admin" | ||
ANTIVIRUS_API_HOST = os.environ.get("ANTIVIRUS_API_HOST") | ||
ANTIVIRUS_API_KEY = os.environ.get("ANTIVIRUS_API_KEY") | ||
API_HOST_NAME = os.environ.get("API_HOST_NAME") | ||
ASSET_DOMAIN = os.getenv("ASSET_DOMAIN", "assets.notification.canada.ca") | ||
ASSET_PATH = "/static/" | ||
ASSETS_DEBUG = False | ||
AWS_REGION = os.environ.get("AWS_REGION", "us-east-1") | ||
|
||
# Bounce Rate parameters | ||
BR_DISPLAY_VOLUME_MINIMUM = 1000 | ||
|
||
BULK_SEND_AWS_BUCKET = os.getenv("BULK_SEND_AWS_BUCKET") | ||
BULK_SEND_TEST_SERVICE_ID = os.getenv("BULK_SEND_TEST_SERVICE_ID") | ||
|
||
CHECK_PROXY_HEADER = False | ||
CONTACT_EMAIL = os.environ.get("CONTACT_EMAIL", "[email protected]") | ||
CRM_GITHUB_PERSONAL_ACCESS_TOKEN = os.getenv("CRM_GITHUB_PERSONAL_ACCESS_TOKEN") | ||
CRM_ORG_LIST_URL = os.getenv("CRM_ORG_LIST_URL") | ||
CSV_MAX_ROWS = env.int("CSV_MAX_ROWS", 50_000) | ||
CSV_MAX_ROWS_BULK_SEND = env.int("CSV_MAX_ROWS_BULK_SEND", 100_000) | ||
CSV_UPLOAD_BUCKET_NAME = os.getenv("CSV_UPLOAD_BUCKET_NAME", "notification-alpha-canada-ca-csv-upload") | ||
CRM_GITHUB_PERSONAL_ACCESS_TOKEN = os.getenv("CRM_GITHUB_PERSONAL_ACCESS_TOKEN") | ||
CRM_ORG_LIST_URL = os.getenv("CRM_ORG_LIST_URL") | ||
DANGEROUS_SALT = os.environ.get("DANGEROUS_SALT") | ||
DEBUG = False | ||
DEBUG_KEY = os.environ.get("DEBUG_KEY", "") | ||
|
@@ -74,8 +73,21 @@ class Config(object): | |
DOCUMENTATION_DOMAIN = os.getenv("DOCUMENTATION_DOMAIN", "documentation.notification.canada.ca") | ||
EMAIL_2FA_EXPIRY_SECONDS = 1_800 # 30 Minutes | ||
EMAIL_EXPIRY_SECONDS = 3600 # 1 hour | ||
FREE_YEARLY_SMS_LIMIT = env.int("FREE_YEARLY_SMS_LIMIT", 25_000) | ||
|
||
# for waffles: pull out the routes into a flat list of the form ['/home', '/accueil', '/why-gc-notify', ...] | ||
EXTRA_ROUTES = [item for sublist in map(lambda x: x.values(), GC_ARTICLES_ROUTES.values()) for item in sublist] | ||
|
||
# FEATURE FLAGS | ||
FF_NEW_BRANDING = env.bool("FF_NEW_BRANDING", False) | ||
FF_SALESFORCE_CONTACT = env.bool("FF_SALESFORCE_CONTACT", True) | ||
FF_TEMPLATE_CATEGORY = env.bool("FF_TEMPLATE_CATEGORY", False) | ||
FF_TOU = env.bool("FF_TOU", False) | ||
|
||
FREE_YEARLY_EMAIL_LIMIT = env.int("FREE_YEARLY_EMAIL_LIMIT", 10_000_000) | ||
FREE_YEARLY_SMS_LIMIT = env.int("FREE_YEARLY_SMS_LIMIT", 25_000) | ||
GC_ARTICLES_API = os.environ.get("GC_ARTICLES_API", "articles.alpha.canada.ca/notification-gc-notify") | ||
GC_ARTICLES_API_AUTH_PASSWORD = os.environ.get("GC_ARTICLES_API_AUTH_PASSWORD") | ||
GC_ARTICLES_API_AUTH_USERNAME = os.environ.get("GC_ARTICLES_API_AUTH_USERNAME") | ||
GOOGLE_ANALYTICS_ID = os.getenv("GOOGLE_ANALYTICS_ID", "UA-102484926-14") | ||
GOOGLE_TAG_MANAGER_ID = os.getenv("GOOGLE_TAG_MANAGER_ID", "GTM-KRKRZQV") | ||
HC_EN_SERVICE_ID = os.getenv("HC_EN_SERVICE_ID") | ||
|
@@ -84,40 +96,38 @@ class Config(object): | |
HTTP_PROTOCOL = "http" | ||
INVITATION_EXPIRY_SECONDS = 3_600 * 24 * 2 # 2 days - also set on api | ||
IP_GEOLOCATE_SERVICE = os.environ.get("IP_GEOLOCATE_SERVICE", "").rstrip("/") | ||
GC_ARTICLES_API = os.environ.get("GC_ARTICLES_API", "articles.alpha.canada.ca/notification-gc-notify") | ||
GC_ARTICLES_API_AUTH_USERNAME = os.environ.get("GC_ARTICLES_API_AUTH_USERNAME") | ||
GC_ARTICLES_API_AUTH_PASSWORD = os.environ.get("GC_ARTICLES_API_AUTH_PASSWORD") | ||
|
||
LANGUAGES = ["en", "fr"] | ||
LOGO_UPLOAD_BUCKET_NAME = os.getenv("ASSET_UPLOAD_BUCKET_NAME", "notification-alpha-canada-ca-asset-upload") | ||
MAX_FAILED_LOGIN_COUNT = 10 | ||
MOU_BUCKET_NAME = os.getenv("MOU_BUCKET_NAME", "") | ||
|
||
NOTIFY_APP_NAME = "admin" | ||
NOTIFY_BAD_FILLER_UUID = "00000000-0000-0000-0000-000000000000" | ||
NOTIFY_ENVIRONMENT = "development" | ||
NOTIFY_LOG_LEVEL = "DEBUG" | ||
NOTIFY_LOG_PATH = os.getenv("NOTIFY_LOG_PATH", "") | ||
NOTIFY_SERVICE_ID = "d6aa2c68-a2d9-4437-ab19-3ae8eb202553" | ||
|
||
NOTIFY_TEMPLATE_PREFILL_SERVICE_ID = "93305b36-b0a0-4a34-9ab2-c1b7bb5ca489" | ||
NOTIFY_USER_ID = "6af522d0-2915-4e52-83a3-3690455a5fe6" | ||
PERMANENT_SESSION_LIFETIME = 8 * 60 * 60 # 8 hours | ||
|
||
REDIS_URL = os.environ.get("REDIS_URL") | ||
PERMANENT_SESSION_LIFETIME = 8 * 60 * 60 # 8 hours | ||
REDIS_ENABLED = env.bool("REDIS_ENABLED", False) | ||
|
||
REDIS_URL = os.environ.get("REDIS_URL") | ||
ROUTE_SECRET_KEY_1 = os.environ.get("ROUTE_SECRET_KEY_1", "") | ||
ROUTE_SECRET_KEY_2 = os.environ.get("ROUTE_SECRET_KEY_2", "") | ||
WAF_SECRET = os.environ.get("WAF_SECRET", "waf-secret") | ||
|
||
# Scan files integration | ||
SCANFILES_AUTH_TOKEN = os.environ.get("SCANFILES_AUTH_TOKEN", "") | ||
SCANFILES_URL = os.environ.get("SCANFILES_URL", "") | ||
|
||
SECRET_KEY = env.list("SECRET_KEY", []) | ||
SECURITY_EMAIL = os.environ.get("SECURITY_EMAIL", "[email protected]") | ||
SEND_FILE_MAX_AGE_DEFAULT = 365 * 24 * 60 * 60 # 1 year | ||
SENDING_DOMAIN = os.environ.get("SENDING_DOMAIN", "notification.alpha.canada.ca") | ||
SENSITIVE_SERVICES = os.environ.get("SENSITIVE_SERVICES", "") | ||
SESSION_COOKIE_HTTPONLY = True | ||
SESSION_COOKIE_NAME = "notify_admin_session" | ||
SESSION_COOKIE_SAMESITE = "Lax" | ||
SESSION_COOKIE_SECURE = True | ||
SESSION_REFRESH_EACH_REQUEST = True | ||
SESSION_COOKIE_SAMESITE = "Lax" | ||
SENSITIVE_SERVICES = os.environ.get("SENSITIVE_SERVICES", "") | ||
SHOW_STYLEGUIDE = env.bool("SHOW_STYLEGUIDE", True) | ||
|
||
# Hosted graphite statsd prefix | ||
|
@@ -128,24 +138,16 @@ class Config(object): | |
|
||
TEMPLATE_PREVIEW_API_HOST = os.environ.get("TEMPLATE_PREVIEW_API_HOST", "http://localhost:6013") | ||
TEMPLATE_PREVIEW_API_KEY = os.environ.get("TEMPLATE_PREVIEW_API_KEY", "my-secret-key") | ||
|
||
WAF_SECRET = os.environ.get("WAF_SECRET", "waf-secret") | ||
WTF_CSRF_ENABLED = True | ||
WTF_CSRF_TIME_LIMIT = None | ||
|
||
ZENDESK_API_KEY = os.environ.get("ZENDESK_API_KEY") | ||
|
||
# Bounce Rate parameters | ||
BR_DISPLAY_VOLUME_MINIMUM = 1000 | ||
|
||
# Scan files integration | ||
SCANFILES_URL = os.environ.get("SCANFILES_URL", "") | ||
SCANFILES_AUTH_TOKEN = os.environ.get("SCANFILES_AUTH_TOKEN", "") | ||
# Various IDs | ||
BULK_SEND_TEST_SERVICE_ID = os.getenv("BULK_SEND_TEST_SERVICE_ID") | ||
|
||
# FEATURE FLAGS | ||
FF_SALESFORCE_CONTACT = env.bool("FF_SALESFORCE_CONTACT", True) | ||
FF_NEW_BRANDING = env.bool("FF_NEW_BRANDING", False) | ||
FF_TEMPLATE_CATEGORY = env.bool("FF_TEMPLATE_CATEGORY", False) | ||
FF_TOU = env.bool("FF_TOU", False) | ||
NOTIFY_USER_ID = "6af522d0-2915-4e52-83a3-3690455a5fe6" | ||
NOTIFY_SERVICE_ID = "d6aa2c68-a2d9-4437-ab19-3ae8eb202553" | ||
NO_BRANDING_ID = os.environ.get("NO_BRANDING_ID", "0af93cf1-2c49-485f-878f-f3e662e651ef") | ||
|
||
@classmethod | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.