Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limits for go-live form step 2 #1984

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
02fd2d4
Limits for go-live form step 2
amazingphilippe Oct 31, 2024
5b4c3bc
format
amazingphilippe Oct 31, 2024
f19859d
Merge branch 'main' into feat/golive-form-updates
amazingphilippe Oct 31, 2024
16c37ab
simplify h2s
amazingphilippe Nov 4, 2024
1ccb87b
format
amazingphilippe Nov 4, 2024
206f52f
validation and tests
amazingphilippe Nov 4, 2024
0480c2b
Merge branch 'main' into feat/golive-form-updates
amazingphilippe Nov 4, 2024
903e809
Add tests and fix bugs
amazingphilippe Nov 5, 2024
ff66f8f
Merge remote-tracking branch 'refs/remotes/origin/feat/golive-form-up…
amazingphilippe Nov 5, 2024
0fdb551
validator config
amazingphilippe Nov 5, 2024
3cd7691
Merge branch 'main' into feat/golive-form-updates
amazingphilippe Nov 5, 2024
53b9e48
Merge branch 'main' into feat/golive-form-updates
amazingphilippe Nov 5, 2024
3f69a95
Merge branch 'main' into feat/golive-form-updates
amazingphilippe Nov 18, 2024
8e5fc8f
de duplicate limit forms, got limits for annual limits
amazingphilippe Nov 20, 2024
fc3ce4f
Merge remote-tracking branch 'refs/remotes/origin/feat/golive-form-up…
amazingphilippe Nov 20, 2024
dda5083
format
amazingphilippe Nov 20, 2024
89d1eb6
Merge branch 'main' into feat/golive-form-updates
amazingphilippe Nov 21, 2024
da088c2
make tests more solid. Fix bug with residual custom limit
amazingphilippe Nov 22, 2024
e40f905
Merge branch 'main' into feat/golive-form-updates
amazingphilippe Nov 22, 2024
8a5f20d
reformat options for consistency
amazingphilippe Nov 22, 2024
4846698
Merge remote-tracking branch 'refs/remotes/origin/feat/golive-form-up…
amazingphilippe Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,14 @@ def format_thousands(value):
return value


def format_thousands_localized(value):
if isinstance(value, Number):
return "{:,}".format(int(value)).replace(",", "\u2009" if get_current_locale(current_app) == "fr" else ",")
if value is None:
return ""
return value


def valid_phone_number(phone_number):
try:
validate_phone_number(phone_number)
Expand Down
60 changes: 20 additions & 40 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class Config(object):
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(",")]
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", "") != ""
Expand All @@ -48,15 +47,12 @@ class Config(object):
BULK_SEND_AWS_BUCKET = os.getenv("BULK_SEND_AWS_BUCKET")

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")
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")
CSV_UPLOAD_BUCKET_NAME = os.getenv("CSV_UPLOAD_BUCKET_NAME", "notification-alpha-canada-ca-csv-upload")
DANGEROUS_SALT = os.environ.get("DANGEROUS_SALT")
DEBUG = False
DEBUG_KEY = os.environ.get("DEBUG_KEY", "")
Expand All @@ -71,18 +67,15 @@ class Config(object):
"other": 25_000,
}
DEFAULT_LIVE_SERVICE_LIMIT = env.int("DEFAULT_LIVE_SERVICE_LIMIT", 10_000)
DEFAULT_LIVE_SMS_DAILY_LIMIT = env.int(
"DEFAULT_LIVE_SMS_DAILY_LIMIT", 1000)
DEFAULT_LIVE_SMS_DAILY_LIMIT = env.int("DEFAULT_LIVE_SMS_DAILY_LIMIT", 1000)
DEFAULT_SERVICE_LIMIT = env.int("DEFAULT_SERVICE_LIMIT", 50)
DEFAULT_SMS_DAILY_LIMIT = env.int("DEFAULT_SMS_DAILY_LIMIT", 50)
DOCUMENTATION_DOMAIN = os.getenv(
"DOCUMENTATION_DOMAIN", "documentation.notification.canada.ca")
DOCUMENTATION_DOMAIN = os.getenv("DOCUMENTATION_DOMAIN", "documentation.notification.canada.ca")
EMAIL_2FA_EXPIRY_SECONDS = 1_800 # 30 Minutes
EMAIL_EXPIRY_SECONDS = 3600 # 1 hour

# 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]
EXTRA_ROUTES = [item for sublist in map(lambda x: x.values(), GC_ARTICLES_ROUTES.values()) for item in sublist]

# FEATURE FLAGS
FF_SALESFORCE_CONTACT = env.bool("FF_SALESFORCE_CONTACT", True)
Expand All @@ -91,24 +84,19 @@ class Config(object):

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")
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")
HC_FR_SERVICE_ID = os.getenv("HC_FR_SERVICE_ID")
HIPB_ENABLED = True
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("/")
IP_GEOLOCATE_SERVICE = os.environ.get("IP_GEOLOCATE_SERVICE", "").rstrip("/")
LANGUAGES = ["en", "fr"]
LOGO_UPLOAD_BUCKET_NAME = os.getenv(
"ASSET_UPLOAD_BUCKET_NAME", "notification-alpha-canada-ca-asset-upload")
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", "")

Expand All @@ -131,10 +119,8 @@ class Config(object):
SCANFILES_URL = os.environ.get("SCANFILES_URL", "")

SECRET_KEY = env.list("SECRET_KEY", [])
SECURITY_EMAIL = os.environ.get(
"SECURITY_EMAIL", "[email protected]")
SENDING_DOMAIN = os.environ.get(
"SENDING_DOMAIN", "notification.alpha.canada.ca")
SECURITY_EMAIL = os.environ.get("SECURITY_EMAIL", "[email protected]")
SENDING_DOMAIN = os.environ.get("SENDING_DOMAIN", "notification.alpha.canada.ca")
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_NAME = "notify_admin_session"
SESSION_COOKIE_SAMESITE = "Lax"
Expand All @@ -148,10 +134,8 @@ class Config(object):
STATSD_PORT = 8_125
STATSD_PREFIX = os.getenv("STATSD_PREFIX")

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")
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
Expand All @@ -162,8 +146,7 @@ class Config(object):

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")
NO_BRANDING_ID = os.environ.get("NO_BRANDING_ID", "0af93cf1-2c49-485f-878f-f3e662e651ef")

@classmethod
def get_sensitive_config(cls) -> list[str]:
Expand Down Expand Up @@ -191,8 +174,7 @@ def get_safe_config(cls) -> dict[str, Any]:


class Development(Config):
ADMIN_CLIENT_SECRET = os.environ.get(
"ADMIN_CLIENT_SECRET", "dev-notify-secret-key")
ADMIN_CLIENT_SECRET = os.environ.get("ADMIN_CLIENT_SECRET", "dev-notify-secret-key")
ANTIVIRUS_API_HOST = "http://localhost:6016"
ANTIVIRUS_API_KEY = "test-key"
API_HOST_NAME = os.environ.get("API_HOST_NAME", "http://localhost:6011")
Expand All @@ -210,8 +192,7 @@ class Development(Config):


class Test(Development):
ADMIN_CLIENT_SECRET = os.environ.get(
"ADMIN_CLIENT_SECRET", "dev-notify-secret-key")
ADMIN_CLIENT_SECRET = os.environ.get("ADMIN_CLIENT_SECRET", "dev-notify-secret-key")
ANTIVIRUS_API_HOST = "https://test-antivirus"
ANTIVIRUS_API_KEY = "test-antivirus-secret"
API_HOST_NAME = os.environ.get("API_HOST_NAME", "http://localhost:6011")
Expand All @@ -238,8 +219,7 @@ class Test(Development):


class ProductionFF(Config):
ADMIN_CLIENT_SECRET = os.environ.get(
"ADMIN_CLIENT_SECRET", "dev-notify-secret-key")
ADMIN_CLIENT_SECRET = os.environ.get("ADMIN_CLIENT_SECRET", "dev-notify-secret-key")
ANTIVIRUS_API_HOST = "https://test-antivirus"
ANTIVIRUS_API_KEY = "test-antivirus-secret"
API_HOST_NAME = os.environ.get("API_HOST_NAME", "http://localhost:6011")
Expand Down
Loading
Loading