Skip to content

Commit

Permalink
Merge branch 'develop' into long-term/remove-tp
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlo-mk authored Nov 4, 2024
2 parents 74e0f74 + cac3165 commit 9ca3af7
Show file tree
Hide file tree
Showing 114 changed files with 3,394 additions and 1,926 deletions.
2 changes: 1 addition & 1 deletion .github/helpers/.env-selenium
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
REDIS_INSTANCE=redis:6379
PYTHONUNBUFFERED=1
SECRET_KEY=secretkey
ENV=dev
DEBUG=true
CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
CACHE_LOCATION=redis://redis:6379/1
CONSTANCE_REDIS_CONNECTION=redis://redis:6379/0
DATABASE_URL=postgis://postgres:postgres@db:5432/postgres
USE_DUMMY_EXCHANGE_RATES=yes
CELERY_TASK_ALWAYS_EAGER=true
3 changes: 2 additions & 1 deletion .github/helpers/.env-unit
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ KOBO_KF_URL=https://kobo.humanitarianresponse.info
KOBO_KC_URL=https://kobo.humanitarianresponse.info
KOBO_MASTER_API_TOKEN=token
EXCHANGE_RATES_API_KEY=token
REDIS_INSTANCE=redis:6379
CACHE_LOCATION=redis://redis:6379/1
CONSTANCE_REDIS_CONNECTION=redis://redis:6379/0
PYTHONUNBUFFERED=1
2 changes: 1 addition & 1 deletion .github/helpers/docker-compose.selenium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
- backend-web-app:/tmp/
command: |
sh -c "
cp -r /packages/__pypackages__/3.11/lib/hct_mis_api/apps/web/* /tmp/
cp -r /packages/__pypackages__/3.12/lib/hct_mis_api/apps/web/* /tmp/
"
restart: "no"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:
continue-on-error: true
with:
name: report
path: ./tests/report/
path: ./tests/selenium/output_data/report/
retention-days: 5
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
5 changes: 0 additions & 5 deletions cypress/package.json

This file was deleted.

402 changes: 0 additions & 402 deletions cypress/yarn.lock

This file was deleted.

6 changes: 5 additions & 1 deletion development_tools/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ DATAMART_URL=https://datamart.unicef.io
EXCHANGE_RATES_API_KEY=
ADMIN_PANEL_URL=unicorn
ROOT_ACCESS_TOKEN=test
CELERY_BROKER_URL="redis://redis:6379/0"
CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
CONSTANCE_REDIS_CONNECTION=redis://redis:6379/0
CACHE_LOCATION=redis://redis:6379/1

PROFILING=off
USE_DUMMY_EXCHANGE_RATES=no
OPENAPI_URL=127.0.0.1:8080/api/rest/
Expand Down
8 changes: 0 additions & 8 deletions development_tools/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ services:
env_file:
- .env
environment:
- REDIS_INSTANCE=redis:6379
- PYTHONUNBUFFERED=1
build:
context: ..
Expand Down Expand Up @@ -61,8 +60,6 @@ services:
image: unicef/hct-mis-backend
env_file:
- .env
environment:
- REDIS_INSTANCE=redis:6379
volumes:
- ../src:/code/
- backend-data:/data
Expand Down Expand Up @@ -90,8 +87,6 @@ services:
image: unicef/hct-mis-backend
env_file:
- .env
environment:
- REDIS_INSTANCE=redis:6379
volumes:
- ../src:/code/
- backend-data:/data
Expand Down Expand Up @@ -186,9 +181,6 @@ services:
ports:
- "5555:5555"
environment:
- REDIS_INSTANCE=redis:6379
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- PYTHONUNBUFFERED=1
depends_on:
- celery-worker
Expand Down
3 changes: 1 addition & 2 deletions development_tools/local_selenium_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ export KOBO_KF_URL=https://kobo.humanitarianresponse.info
export KOBO_KC_URL=https://kobo.humanitarianresponse.info
export ADMIN_PANEL_URL=unicorn
export PROFILING=off
export CYPRESS_TESTING=yes
export DJANGO_ALLOWED_HOST=localhost
export HCT_MIS_FRONTEND_HOST=localhost:8080
export REDIS_INSTANCE=localhost:6379
export PYTHONUNBUFFERED=1
export CELERY_BROKER_URL=redis://localhost:6379/0
export CELERY_RESULT_BACKEND=redis://localhost:6379/0
export CONSTANCE_REDIS_CONNECTION=redis://localhost:6379/0
export CACHE_LOCATION=redis://localhost:6379/1
export USE_DUMMY_EXCHANGE_RATES=yes
export ELASTICSEARCH_HOST=http://localhost:9200
Expand Down
7 changes: 4 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FROM curl as certs
RUN curl -o /data/psql-cert.crt -L https://dl.cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem

# Base image
FROM python:3.11.7-slim-bookworm as base
FROM python:3.12.7-slim-bookworm as base

ARG UID=82

Expand Down Expand Up @@ -42,7 +42,7 @@ RUN apt-get update \
ENV PDM_PACKAGES=/packages
ENV CODE=/code
ENV PDM_PROJECT=$PDM_PACKAGES
ENV PYPACKAGES=$PDM_PACKAGES/__pypackages__/3.11
ENV PYPACKAGES=$PDM_PACKAGES/__pypackages__/3.12
ENV PYTHONPYCACHEPREFIX=/tmp/pycache \
PYTHONPATH=$PYPACKAGES/lib:$PYTHONPATH \
PATH=$PYPACKAGES/bin:$PATH \
Expand All @@ -55,7 +55,8 @@ COPY --from=waitforit /data/waitforit /usr/local/bin/waitforit
# Dist builder image
FROM base as pdm
RUN pip install --upgrade pip &&\
pip install pdm==2.15.2 &&\
pip install pdm==2.19.2 &&\
pip install pdm-backend &&\
pip install setuptools==71.1.0 &&\
pdm config cache_dir /var/cache/pdm &&\
pdm config python.use_venv false &&\
Expand Down
1,146 changes: 579 additions & 567 deletions pdm.lock

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exclude = '''
'''
# TODO: remove migrations exclude rule once it won't create much conflicts between feature branches and develop
[tool.isort]
py_version = 39
py_version = 312
profile = "black"
default_section = "THIRDPARTY"
known_first_party = [
Expand All @@ -48,7 +48,7 @@ include_trailing_comma = true
skip = ["migrations", "snapshots", "venv", ".venv", "__pypackages__", "frontend"]

[tool.mypy]
python_version = 3.11
python_version = 3.12
show_error_codes = true
exclude = [
"migrations",
Expand Down Expand Up @@ -112,7 +112,6 @@ dev = [
"watchdog<3.0.0,>=2.1.8",
"wasmer<2.0.0,>=1.1.0",
"types-selenium<4.0.0,>=3.141.9",
"factory-boy<4,>=3",
"pre-commit<4.0.0,>=3.1.1",
"pytest-rerunfailures<14.0,>=13.0",
"pytest-randomly<4.0.0,>=3.15.0",
Expand All @@ -138,7 +137,7 @@ distribution = true

[project]
name = "hope"
version = "2.12.0"
version = "2.13.0"
description = "HCT MIS is UNICEF's humanitarian cash transfer platform."
authors = [
{ name = "Tivix" },
Expand Down Expand Up @@ -191,6 +190,7 @@ dependencies = [
"django-reversion<6.0.0,>=5.0.2",
"django-silk<6.0.0,>=5.0.1",
"django-smart-admin<3,>=2",
"django-smart-env",
"django-sql-explorer[xls]<4,>=3",
"django-storages[azure]<2.0.0,>=1.12.3",
"django-strategy-field<4.0,>=3.0",
Expand Down Expand Up @@ -222,7 +222,7 @@ dependencies = [
"single-source<1.0.0,>=0.3.0",
"social-auth-app-django<6.0.0,>=5.0.0",
"social-auth-core<5.0.0,>=4.2.0",
"sorl-thumbnail<13.0.0,>=12.8.0",
"sorl-thumbnail==12.9",
"swapper<2.0.0,>=1.3.0",
"tblib<2.0.0,>=1.7.0",
"unicef-power-query<1.0,>=0.4",
Expand All @@ -238,8 +238,9 @@ dependencies = [
"pydyf==0.10.0",
"elastic-transport==8.13.0",
"flower>=2.0.1",
"factory-boy<4,>=3",
]
requires-python = "==3.11.*"
requires-python = "==3.12.*"
readme = "README.md"
license = { text = "None" }

Expand Down
6 changes: 4 additions & 2 deletions src/frontend/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,7 @@ type GrievanceTicketNode implements Node {
relatedTickets: [GrievanceTicketNode]
totalDays: String
documentation: [GrievanceDocumentNode]
targetId: String
}

type GrievanceTicketNodeConnection {
Expand Down Expand Up @@ -4196,6 +4197,7 @@ enum RegistrationDataImportDeduplicationEngineStatus {
PENDING
UPLOADED
IN_PROGRESS
PROCESSING
FINISHED
ERROR
UPLOAD_ERROR
Expand Down Expand Up @@ -4766,8 +4768,8 @@ type TargetPopulationNode implements Node {
buildStatus: TargetPopulationBuildStatus!
builtAt: DateTime
households(offset: Int, before: String, after: String, first: Int, last: Int, orderBy: String, businessArea: String): HouseholdNodeConnection
program: ProgramNode
programCycle: ProgramCycleNode
program: ProgramNode!
programCycle: ProgramCycleNode!
targetingCriteria: TargetingCriteriaNode
sentToDatahub: Boolean!
steficonRule: RuleCommitNode
Expand Down
1 change: 1 addition & 0 deletions src/frontend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ module.exports = {
'^@hooks/(.*)$': '<rootDir>/src/hooks/$1',
'^@generated/(.*)$': '<rootDir>/src/__generated__/$1',
'^@restgenerated/(.*)$': '<rootDir>/src/restgenerated/$1',
'^src/(.*)$': '<rootDir>/src/$1',
},
};
2 changes: 1 addition & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "2.12.0",
"version": "2.12.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
529 changes: 267 additions & 262 deletions src/frontend/src/__generated__/graphql.tsx

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/frontend/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const api = {
return params.toString();
},

async get(url: string, params: Record<string, any> = {}) {
async get(url: string, params: Record<string, any> = {}, filename?: string) {
const query = this.buildParams(params);
const cacheKey = url + (query ? `?${query}` : '');

Expand All @@ -42,6 +42,20 @@ export const api = {
throw new Error(`Error fetching data from ${url}`);
}

// Handle download if URL includes "download"
if (url.includes('download')) {
const blob = await response.blob();
const downloadUrl = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = downloadUrl;
a.download = filename || url.split('/').pop() || 'download';
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(downloadUrl);
return;
}

const etag = response.headers.get('ETag');
const data = await response.json();

Expand Down
16 changes: 12 additions & 4 deletions src/frontend/src/api/paymentModuleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,17 @@ export const fetchSupportingDocument = async (
programId: string,
paymentPlanId: string,
fileId: string,
fileName: string,
): Promise<any> => {
const response = await api.get(
`${businessAreaSlug}/programs/${programId}/payment-plans/${paymentPlanId}/supporting-documents/${fileId}/download/`,
);
return response;
try {
const response = await api.get(
`${businessAreaSlug}/programs/${programId}/payment-plans/${paymentPlanId}/supporting-documents/${fileId}/download/`,
{},
fileName,
);
return response;
} catch (error: any) {
const errorMessage = error?.message || 'An unknown error occurred';
throw new Error(`Failed to fetch supporting document: ${errorMessage}`);
}
};
2 changes: 2 additions & 0 deletions src/frontend/src/api/periodicDataUpdateApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export const fetchPeriodicDataUpdateTemplate = async (
): Promise<any> => {
const response = await api.get(
`${businessAreaSlug}/programs/${programId}/periodic-data-update/periodic-data-update-templates/${templateId}/download/`,
{},
`Periodic_Data_Update_Template_${templateId}`,
);
return response;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const grievanceTicketDetailed = gql`
id
name
}
targetId
businessArea {
postponeDeduplication
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/apollo/fragments/IndividualFragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export const individualMinimal = gql`
lastRegistrationDate
start
firstRegistrationDate
countryOrigin
village
}
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const AllGrievanceTicket = gql`
cursor
node {
id
targetId
status
assignedTo {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Title } from '@core/Title';
import { NewDocumentationFieldArray } from '../../Documentation/NewDocumentationFieldArray';
import { LookUpLinkedTickets } from '../../LookUps/LookUpLinkedTickets/LookUpLinkedTickets';
import { LookUpPaymentRecord } from '../../LookUps/LookUpPaymentRecord/LookUpPaymentRecord';
import { useProgramContext } from 'src/programContext';

const BoxPadding = styled.div`
padding: 15px 0;
Expand Down Expand Up @@ -63,6 +64,8 @@ export function Description({
}: DescriptionProps): ReactElement {
const { t } = useTranslation();
const { isAllPrograms } = useBaseUrl();
const { isSocialDctType } = useProgramContext();

const { data: partnerChoicesData } = usePartnerForGrievanceChoicesQuery({
variables: {
householdId: values.selectedHousehold?.id,
Expand Down Expand Up @@ -160,7 +163,9 @@ export function Description({
size: 3,
},
]
.filter((el) => el)
.filter((el) =>
isSocialDctType ? el.label !== 'Household ID' : el,
)
.map((el) => (
<Grid key={el.label} item xs={el.size as GridSize}>
<LabelizedField label={el.label}>{el.value}</LabelizedField>
Expand Down
Loading

0 comments on commit 9ca3af7

Please sign in to comment.