Skip to content

Commit

Permalink
DESENG-493: CRON config alignment and engagement metadata dependency …
Browse files Browse the repository at this point in the history
…removal (#2375)

* Updating cron config and sample env
  • Loading branch information
VineetBala-AOT authored Feb 6, 2024
1 parent c16efb8 commit 16d4f32
Show file tree
Hide file tree
Showing 13 changed files with 343 additions and 207 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## February 06, 2024
- **Task** Streamline CRON jobs [DESENG-493](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-493)
- Aligned the CRON configuration and sample environment files with the structure used in the Met API.
- Eliminated the reliance on engagement metadata within CRON jobs.
- Implemented necessary code adjustments to seamlessly integrate with the updated CRON configuration.

## February 05, 2024
- **Task** Change "Superuser" to "Administrator" [DESENG-476](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-476)

Expand Down
2 changes: 1 addition & 1 deletion met-api/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ACCESS_REQUEST_EMAIL_SUBJECT=
ACCESS_REQUEST_EMAIL_ADDRESS="accessRequestHandler.fakeName@gov.bc.ca"

# Site paths for creating emails from templates
SITE_URL=localhost:3000
SITE_URL=http://localhost:3000
SURVEY_PATH=/surveys/submit/{survey_id}/{token}
USER_MANAGEMENT_PATH=/usermanagement
SUBMISSION_PATH=/engagements/{engagement_id}/edit/{token}
Expand Down
2 changes: 1 addition & 1 deletion met-api/src/met_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def SQLALCHEMY_DATABASE_URI(self) -> str:
'CLOSEOUT': {
'ID': os.getenv('CLOSEOUT_EMAIL_TEMPLATE_ID'),
'SUBJECT': os.getenv('CLOSEOUT_EMAIL_SUBJECT',
'MET - Engagement Closed'),
'The public commenting period for {engagement_name} is now closed.'),
},
'ACCESS_REQUEST': {
'ID': os.getenv('ACCESS_REQUEST_EMAIL_TEMPLATE_ID'),
Expand Down
2 changes: 1 addition & 1 deletion met-api/src/met_api/services/engagement_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _render_email_template(engagement: EngagementModel):
engagement_url = notification.get_tenant_site_url(engagement.tenant_id, dashboard_path)
templates = current_app.config['EMAIL_TEMPLATES']
subject = templates['CLOSEOUT']['SUBJECT'].format(engagement_name=engagement.name)
email_environment = templates['ENVIROMENT']
email_environment = templates['ENVIRONMENT']
tenant_name = EngagementService._get_tenant_name(
engagement.tenant_id)
args = {
Expand Down
5 changes: 3 additions & 2 deletions met-api/src/met_api/utils/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
def get_tenant_site_url(tenant_id, path=''):
"""Get the tenant specific site url (domain / tenant / path)."""
is_single_tenant_environment = current_app.config.get('IS_SINGLE_TENANT_ENVIRONMENT', False)
site_url = current_app.config.get('SITE_URL', '')
paths = current_app.config['PATH_CONFIG']
site_url = paths.get('SITE', '')
if not is_single_tenant_environment:
if tenant_id is None:
raise ValueError('Missing tenant id.')
tenant: Tenant = Tenant.find_by_id(tenant_id)
return site_url + f'/{tenant.short_name}' + path
return site_url + f'/{tenant.short_name.lower()}' + path
else:
return site_url + path

Expand Down
3 changes: 2 additions & 1 deletion met-api/src/met_api/utils/user_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def __init__(self):
self._last_name: str = token_info.get('lastname', None)
self._tenant_id: str = token_info.get(TENANT_ID_JWT_CLAIM, None)
self._bearer_token: str = _get_token()
self._roles: list = current_app.config['JWT_ROLE_CALLBACK'](token_info)
self._roles: list = current_app.config['JWT_ROLE_CALLBACK'](token_info) if 'client_roles' in token_info \
else []
self._sub: str = token_info.get('sub', None)
self._name: str = f"{token_info.get('firstname', None)} {token_info.get('lastname', None)}"

Expand Down
Loading

0 comments on commit 16d4f32

Please sign in to comment.