Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 3 deletions app/src/utils/domain/dref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ export const nsActionsOrder: Record<NsActions['title'], number> = {
other: 18,
};

export type DrefSheetName = 'Operation Overview' | 'Event Detail' | 'Actions Needs' | 'Operation' | 'Timeframes and Contacts';
export type DrefSheetName = 'Operation Overview' | 'Event Detail' | 'Actions Needs' | 'Operation' | 'Scenario Analysis' | 'Plan' | 'Timeframes and Contacts';
export const SHEET_OPERATION_OVERVIEW = 'Operation Overview' satisfies DrefSheetName;
export const SHEET_EVENT_DETAIL = 'Event Detail' satisfies DrefSheetName;
export const SHEET_ACTIONS_NEEDS = 'Actions Needs' satisfies DrefSheetName;
export const SHEET_OPERATION = 'Operation' satisfies DrefSheetName;
export const SHEET_SCENARIO_ANALYSIS = 'Scenario Analysis' satisfies DrefSheetName;
export const SHEET_PLAN = 'Plan' satisfies DrefSheetName;
export const SHEET_TIMEFRAMES_AND_CONTACTS = 'Timeframes and Contacts' satisfies DrefSheetName;

export const DREF_OPTIONS_SHEET_NAME = 'options';
Expand All @@ -81,8 +83,8 @@ export function getDrefSheetNames(typeOfDref: TypeOfDrefEnum): DrefSheetName[] {
if (typeOfDref === DREF_TYPE_IMMINENT) {
return [
SHEET_OPERATION_OVERVIEW,
SHEET_EVENT_DETAIL,
SHEET_OPERATION,
SHEET_SCENARIO_ANALYSIS,
SHEET_PLAN,
SHEET_TIMEFRAMES_AND_CONTACTS,
];
}
Expand Down
10 changes: 9 additions & 1 deletion app/src/utils/importTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface BaseField {
label: string | Segment[];
description?: string | Segment[];
headingBefore?: string;
defaultValue?: string | number | boolean;
}

interface InputField<
Expand Down Expand Up @@ -134,6 +135,7 @@ type InputTemplateField = {
description?: string | CellRichTextValue;
headingBefore?: string;
context: { field: string, key: string }[],
defaultValue?: string | number | boolean;
} & ({
dataValidation: 'list';
optionsKey: ObjectKey;
Expand Down Expand Up @@ -288,6 +290,7 @@ export function createImportTemplate<
: undefined,
outlineLevel,
context,
defaultValue: schema.defaultValue,
} satisfies InputTemplateField;

fields.push(field);
Expand All @@ -304,6 +307,7 @@ export function createImportTemplate<
dataValidation: 'list',
optionsKey: schema.optionsKey,
context,
defaultValue: schema.defaultValue,
} satisfies InputTemplateField;

fields.push(field);
Expand Down Expand Up @@ -420,8 +424,12 @@ export function getValueFromImportTemplate<
const updatedValue = value.replace(/(^|\n)\s*\*/g, '$1•');
return updatedValue;
}
const isTextField = schema.validation === 'string'
|| schema.validation === 'textArea'
|| schema.validation === 'date';

// TODO: add validation from schema.validation
return value;
return isTextField ? value?.toString() : value;
}

if (schema.type === 'select') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,21 @@
"immDisasterTypeLabel": "Type of disaster",
"immDisasterTypeDesc": "Select the relevant type of disaster from the drop-down list.",
"immTypeOfOnsetLabel": "Type of Onset",
"immTypeOfOnsetDesc": "Select the type of onset from the drop-down list.",
"immTypeOfOnsetDesc": "The type of onset is selected by default.",
"immIsManMadeEventLabel": "Is this a man made event?",
"immIsManMadeEventDesc": "Select Yes or No from the drop-down list.",
"immCountryLabel": "Affected Country",
"immCountryDesc": "NOTE: You may add the targeted region during the import",
"immTitleLabel": "DREF Title",
"immDescriptionOfTheHazardHeading": "Description of the Hazard",
"immHazardDateLabel": "Date when the trigger was met / is expected to be met",
"immHazardDateDesc": "DD/MM/YYYY. Must be today or a future date.",
"immHazardDateAndLocationLabel": "Location and approximate date of the hazard",
"immHazardVulnerabilitiesAndRisksLabel": "Target communities’ vulnerabilities and exposure to the hazard",
"immHazardVulnerabilitiesAndRisksDesc": "Describe the anticipated humanitarian impact and which people are most likely to be affected and why.",
"immHazardDateDesc": "MM/DD/YYYY. Must be today or a future date.",
"immHazardDateAndLocationLabel": "When and where is the hazard expected to happen?",
"immHazardDateAndLocationDesc": "Include here the forecasted date of impact as well as the geographical areas at risk.",
"immHazardVulnerabilitiesAndRisksLabel": "Explain the underlying vulnerabilities and risks the hazard poses for at-risk communities?",
"immHazardVulnerabilitiesAndRisksDesc": "Based on comparison of past events, what humanitarian impacts do you expect? Of what magnitude? (e.g. last time there was a cyclone making landfall with this windspeed, XX houses were destroyed, and we had to launch a DREF/emergency appeal for CHF xxx).",
"immNumAffectedLabel": "Total population likely to be affected",
"immNumAffectedDesc": "People likely to be affected as a direct result of the anticipated event.",
"immNumAffectedDesc": "Includes all those whose lives and livelihoods are at risk as a direct result of the shock or stress.",
"immEstimatedNumberOfAffectedMaleLabel": "Estimated number of affected male",
"immEstimatedNumberOfAffectedFemaleLabel": "Estimated number of affected female",
"immEstimatedNumberOfAffectedGirlsUnder18Label": "Estimated number of affected girls (under 18)",
Expand All @@ -307,22 +308,14 @@
"immIsSurgePersonnelDeployedLabel": "Will surge personnel be deployed?",
"immIsSurgePersonnelDeployedDesc": "Select Yes or No from the drop-down list.",
"immSurgePersonnelDeployedLabel": "Role profile of the deployed personnel",
"immSurgePersonnelDeployedDesc": "Complete only if surge personnel will be deployed.",
"immPoliciesHeading": "Policies",
"immHasAntiFraudCorruptionPolicyLabel": "Does your National Society have anti-fraud and corruption policy?",
"immHasSexualAbusePolicyLabel": "Does your National Society have prevention of sexual exploitation and abuse policy?",
"immHasChildProtectionPolicyLabel": "Does your National Society have child protection/child safeguarding policy?",
"immHasWhistleblowerProtectionPolicyLabel": "Does your National Society have whistleblower protection policy?",
"immHasAntiSexualHarassmentPolicyLabel": "Does your National Society have anti-sexual harassment policy?",
"immAddressedHumanitarianImpactsLabel": "Addressed humanitarian impacts",
"immAddressedHumanitarianImpactsDesc": "Describe the humanitarian impacts the operation aims to address through the proposed early actions and early response.",
"immSurgePersonnelDeployedDesc": "Describe the skills and qualifications/profile of the surge personnel or any additional staff (to be) deployed specifically for the operation.\nWhat expertise or skill sets are required for the personnel being deployed?\nWhat roles will these personnel fulfil?\nAre there specific tasks or sectors they will be managing?",
"immAddressedHumanitarianImpactsLabel": "Which severe humanitarian impacts are your actions addressing, and why?",
"immAddressedHumanitarianImpactsDesc": "Prioritized impact of the foreseen disaster.",
"immTimeframeHeading": "Timeframe",
"immNsRequestDateLabel": "Date of National Society Application",
"immNsRequestDateDesc": "DD/MM/YYYY",
"immOperationTimeframeImminentLabel": "Operation timeframe (days)",
"immOperationTimeframeImminentDesc1": "Indicate the number of days, e.g.",
"immOperationTimeframeImminentDesc2": "45",
"immOperationTimeframeImminentDesc3": ".",
"immOperationTimeframeImminentDesc": "Fixed operation timeframe. This value is predefined and cannot be changed.",
"columnFieldHeader": "Field",
"columnValueHeader": "Value",
"columnDescriptionHeader": "Description",
Expand All @@ -345,7 +338,7 @@
"coverHowToUseDescription": "<b>Mandatory fields</b>\nInput required information in the “Value” column. Do not add data outside of these designated fields.\n\n<b>Collaboration</b>\nThis Excel file can be uploaded to OneDrive/SharePoint/Google Drive for multiple users to work on simultaneously. Please note that only one user can edit any specific cell at a time.\n\n<b>Entry limits</b>\nSome sections, like sources of information, risks and mitigation, and indicators, have a maximum of <b>5 entries</b>. Please do not attempt to add more.",
"coverStructureHeading": "Structure of the template",
"coverStructureResponse": "The template is divided into the following sections:\n\n<b><i>Operation Overview</i></b> – general context of the emergency operation.\n<b><i>Event Details</i></b> – information on the event triggering the DREF request.\n<b><i>Actions and Needs</i></b> – description of key actions and needs.\n<b><i>Operation Plan</i></b> – outline of the planned operation and identified risks.\n<b><i>Timeframes and Contacts</i></b> – key timeframes and relevant contact details.",
"coverStructureImminent": "The template is divided into the following sections:\n\n<b><i>Operation Overview</i></b> – general context of the operation.\n<b><i>Event Details</i></b> – information on the imminent hazard triggering the DREF request.\n<b><i>Operation</i></b> – proposed early actions, early response and support services.\n<b><i>Timeframes and Contacts</i></b> – key timeframes and relevant contact details.",
"coverStructureImminent": "The template is divided into the following sections:\n\n<b><i>Operation Overview</i></b> – general context of the operation.\n<b><i>Scenario Analysis</i></b> – information on the imminent hazard triggering the DREF request.\n<b><i>Plan</i></b> – proposed early actions, early response and support services.\n<b><i>Timeframes and Contacts</i></b> – key timeframes and relevant contact details.",
"coverStepsHeading": "Steps for importing the template",
"coverStepsDescription": "1. Ensure the template is fully completed and all fields are correctly filled.\n2. Log in to the GO platform.\n3. Create a “New DREF Application” and use the <b>Import</b> function to upload this Excel file.\n4. After importing, any additional work on the application should be done directly in the GO platform.",
"respIsManMadeEventDesc1": "Select Yes or No from the drop-down list.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import {
type TypeOfDrefEnum,
} from '#utils/constants';
import { type TemplateSchema } from '#utils/importTemplate';
import {
ONSET_SUDDEN,
OPERATION_TIMEFRAME_IMMINENT,
} from '#views/DrefApplicationForm/common';
import { type DrefRequestBody } from '#views/DrefApplicationForm/schema';

import i18n from './i18n.json';
Expand Down Expand Up @@ -1119,6 +1123,9 @@ function useImportTemplateSchema() {
label: strings.immTypeOfOnsetLabel,
validation: 'number',
optionsKey: 'type_of_onset',
defaultValue: optionsMap.type_of_onset.find(
(option) => option.key === ONSET_SUDDEN,
)?.label,
description: strings.immTypeOfOnsetDesc,
},

Expand Down Expand Up @@ -1158,6 +1165,7 @@ function useImportTemplateSchema() {
type: 'input',
label: strings.immHazardDateAndLocationLabel,
validation: 'textArea',
description: strings.immHazardDateAndLocationDesc,
},

hazard_vulnerabilities_and_risks: {
Expand Down Expand Up @@ -1283,42 +1291,6 @@ function useImportTemplateSchema() {
description: strings.immSurgePersonnelDeployedDesc,
},

has_anti_fraud_corruption_policy: {
headingBefore: strings.immPoliciesHeading,
type: 'select',
optionsKey: '__boolean',
validation: 'boolean',
label: strings.immHasAntiFraudCorruptionPolicyLabel,
},

has_sexual_abuse_policy: {
type: 'select',
optionsKey: '__boolean',
validation: 'boolean',
label: strings.immHasSexualAbusePolicyLabel,
},

has_child_protection_policy: {
type: 'select',
optionsKey: '__boolean',
validation: 'boolean',
label: strings.immHasChildProtectionPolicyLabel,
},

has_whistleblower_protection_policy: {
type: 'select',
optionsKey: '__boolean',
validation: 'boolean',
label: strings.immHasWhistleblowerProtectionPolicyLabel,
},

has_anti_sexual_harassment_policy: {
type: 'select',
optionsKey: '__boolean',
validation: 'boolean',
label: strings.immHasAntiSexualHarassmentPolicyLabel,
},

addressed_humanitarian_impacts: {
type: 'input',
validation: 'textArea',
Expand All @@ -1340,15 +1312,11 @@ function useImportTemplateSchema() {
type: 'input',
validation: 'number',
label: strings.immOperationTimeframeImminentLabel,
description: [
{ text: strings.immOperationTimeframeImminentDesc1 },
{ text: ' ' },
{ text: strings.immOperationTimeframeImminentDesc2, bold: true },
{ text: strings.immOperationTimeframeImminentDesc3 },
],
defaultValue: OPERATION_TIMEFRAME_IMMINENT,
description: strings.immOperationTimeframeImminentDesc,
},
},
}), [strings]);
}), [strings, optionsMap.type_of_onset]);

const drefSchemaByType = useMemo<
Partial<Record<TypeOfDrefEnum, TemplateSchema<DrefRequestBody, typeof optionsMap>>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
SHEET_EVENT_DETAIL,
SHEET_OPERATION,
SHEET_OPERATION_OVERVIEW,
SHEET_PLAN,
SHEET_SCENARIO_ANALYSIS,
SHEET_TIMEFRAMES_AND_CONTACTS,
} from '#utils/domain/dref';
import {
Expand Down Expand Up @@ -537,7 +539,10 @@ async function generateOtherWorksheets(
optionsWorksheet: Worksheet,
workbook: Workbook,
validationStrings: ValidationStrings,
typeOfDref: TypeOfDrefEnum,
) {
const isImminent = typeOfDref === DREF_TYPE_IMMINENT;

const fieldNameToTabNameMap: Record<string, string> = {
...listToMap(
overviewTabFields,
Expand All @@ -547,7 +552,7 @@ async function generateOtherWorksheets(
...listToMap(
eventDetailTabFields,
(key) => key as string,
() => SHEET_EVENT_DETAIL,
() => (isImminent ? SHEET_SCENARIO_ANALYSIS : SHEET_EVENT_DETAIL),
),
...listToMap(
actionsTabFields,
Expand All @@ -557,7 +562,7 @@ async function generateOtherWorksheets(
...listToMap(
operationTabFields,
(key) => key as string,
() => SHEET_OPERATION,
() => (isImminent ? SHEET_PLAN : SHEET_OPERATION),
),
...listToMap(
timeframeAndContactsTabFields,
Expand Down Expand Up @@ -664,6 +669,11 @@ async function generateOtherWorksheets(
templateAction.dataValidation,
);
}

if (isDefined(templateAction.defaultValue)) {
// eslint-disable-next-line no-param-reassign
worksheet.getCell(row, 2).value = templateAction.defaultValue;
}
}
});
});
Expand Down Expand Up @@ -751,6 +761,7 @@ export async function generateTemplate(
listError: templateStrings.validationListError,
errorTitle: templateStrings.validationErrorTitle,
},
typeOfDref,
);

Object.values(sheetMap).forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ function DrefImportModal(props: Props) {
// Require EXACTLY the type's sheet set: a count check would accept a
// Response file (5 sheets) as Imminent (a 4-sheet subset).
const expectedSheetNames = getDrefSheetNames(typeOfDref);
const presentSheetNames = getDrefSheetNames(DREF_TYPE_RESPONSE)
const knownSheetNames = Array.from(new Set([
...getDrefSheetNames(DREF_TYPE_RESPONSE),
...getDrefSheetNames(DREF_TYPE_IMMINENT),
]));
const presentSheetNames = knownSheetNames
.filter((sheetName) => isDefined(workbook.getWorksheet(sheetName)));
const sheetsMatchType = presentSheetNames.length === expectedSheetNames.length
&& expectedSheetNames.every(
Expand Down
4 changes: 2 additions & 2 deletions app/src/views/FlashUpdateDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function Component() {
{flashUpdateResponse.map_files.map((item) => (
<Image
key={item.id}
src={item.file}
src={item.file ?? undefined}
size="md"
/>
))}
Expand All @@ -236,7 +236,7 @@ export function Component() {
{flashUpdateResponse?.graphics_files?.map((item) => (
<Image
key={item.id}
src={item.file}
src={item.file ?? undefined}
caption={item.caption}
size="md"
/>
Expand Down
2 changes: 1 addition & 1 deletion go-api
Submodule go-api updated 61 files
+5 −0 .github/workflows/ci.yml
+1 −1 .python-version
+4 −2 Dockerfile
+43 −43 alert_system/email_processing.py
+1 −1 alert_system/etl/usgs_earthquake/transform.py
+23 −0 alert_system/migrations/0004_alter_alertemailthread_root_email_message_id_and_more.py
+4 −0 alert_system/models.py
+37 −5 api/admin.py
+1 −0 api/filter_set.py
+17 −8 api/management/commands/index_and_notify.py
+5 −3 api/management/commands/ingest_appeal_docs.py
+3 −2 api/management/commands/ingest_appealdocs.py
+12 −12 api/management/commands/ingest_appeals.py
+3 −2 api/management/commands/ingest_deployments.py
+1 −1 api/management/commands/ingest_mdb.py
+6 −4 api/management/commands/sync_appealdocs.py
+15 −17 api/management/commands/sync_molnix.py
+3 −2 api/management/commands/user_registration_reminder.py
+69 −10 api/molnix_utils.py
+17 −10 api/receivers.py
+1 −1 api/templates/admin/base_site.html
+1 −1 api/templates/admin/change_form.html
+4 −4 api/templates/admin/includes/fieldset.html
+1 −0 api/templates/admin/submit_line.html
+82 −76 api/test_views.py
+4 −3 api/views.py
+1 −1 assets
+5 −3 databank/management/commands/ingest_climate.py
+3 −0 deploy/helm/ifrcgo-helm/templates/config/configmap.yaml
+10 −7 deploy/helm/ifrcgo-helm/values.yaml
+8 −5 deployments/drf_views.py
+3 −2 deployments/migrations/0012_auto_20190722_1408.py
+23 −0 deployments/migrations/0096_alter_eru_type_alter_erureadinesstype_type.py
+3 −0 deployments/models.py
+2 −3 deployments/serializers.py
+6 −1 docker-compose.yml
+69 −2 dref/admin.py
+21 −36 dref/serializers.py
+41 −8 dref/test_dref3_filters.py
+123 −22 dref/views.py
+2 −2 local_units/admin.py
+3 −3 main/sentry.py
+53 −9 main/settings.py
+1 −0 main/urls.py
+17 −0 middlewares/middlewares.py
+3 −2 notifications/management/commands/ingest_alerts.py
+5 −5 notifications/templates/email/alert_system/alert_notification.html
+3 −3 notifications/templates/email/alert_system/alert_notification_reply.html
+2 −1 notifications/tests.py
+63 −2 per/drf_views.py
+23 −0 per/serializers.py
+72 −0 per/test_views.py
+5 −3 per/views.py
+8 −10 pyproject.toml
+51 −2 registrations/admin.py
+18 −0 registrations/migrations/0013_userexternaltoken_is_disabled.py
+7 −2 registrations/models.py
+23 −2 registrations/serializers.py
+144 −1 registrations/test_views.py
+46 −1 registrations/views.py
+826 −1,423 uv.lock
Loading