Skip to content

Commit 668fe6d

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/dev_env
* origin/develop: add env variables to Dockerfile Add connect src configuration Fix CSP configuration github fixes Update django-celery-boost version Add docstring to DataGetter AB#241769: aurora import according to use beneficiary groups (#63) Add few more tests removes parrallel tests due to fale positive Fix tests Add cache for Kobo data add tests Household/Individual change history history initial commit
2 parents f4bdd4d + 6d63899 commit 668fe6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+5914
-577
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,12 @@ jobs:
142142
-e CELERY_BROKER_URL=${CELERY_BROKER_URL} \
143143
-e CACHE_URL=${CACHE_URL} \
144144
-e SECRET_KEY=super-secret-key-just-for-testing \
145-
-e HOPE_API_URL="https://dev-hope.unitst.org/api/rest/" \
146-
-e AURORA_API_URL="https://uni-hope-ukr-sr-dev.unitst.org/api/" \
147145
-v "./output/:/app/output" \
148146
-v "./src/:/app/src" \
149147
-v "./tests:/app/tests" \
150148
-v "./pytest.ini:/app/pytest.ini" \
151149
-t ${{env.IMAGE}} \
152-
pytest tests/ --create-db --selenium -n auto -v --maxfail=5 --migrations --cov-report xml:./output/coverage.xml --record-mode none
150+
pytest tests/ --create-db --selenium -v --maxfail=5 --migrations --cov-report xml:./output/coverage.xml --record-mode none
153151
154152
- name: Upload coverage to Codecov
155153
uses: codecov/codecov-action@v4

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ ENV PATH=/venv/bin:/usr/local/bin/:/usr/bin:/bin \
131131
PGSSLCERT="/tmp/postgresql.crt" \
132132
UV_PROJECT_ENVIRONMENT=/venv \
133133
VIRTUAL_ENV=/venv \
134-
UWSGI_PROCESSES=4
134+
UWSGI_PROCESSES=4 \
135+
MEDIA_ROOT="${MEDIA_ROOT:-/var/run/app/media}" \
136+
STATIC_ROOT="${STATIC_ROOT:-/var/run/app/static}"
135137

136138
RUN <<EOF cat> /RELEASE
137139
{"version": "$VERSION",

docker/bin/docker-entrypoint.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/sh -e
22

33

4-
export MEDIA_ROOT="${MEDIA_ROOT:-/var/run/app/media}"
5-
export STATIC_ROOT="${STATIC_ROOT:-/var/run/app/static}"
64
export UWSGI_PROCESSES="${UWSGI_PROCESSES:-"4"}"
75
export DJANGO_SETTINGS_MODULE="country_workspace.config.settings"
86
mkdir -p "${MEDIA_ROOT}" "${STATIC_ROOT}" || echo "Cannot create dirs ${MEDIA_ROOT} ${STATIC_ROOT}"

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies = [
1919
"django-adminfilters>=2.5.2",
2020
"django-cacheops>=7.1",
2121
"django-celery-beat>=2.6.0",
22-
"django-celery-boost>=0.5.0",
22+
"django-celery-boost>=0.6.2",
2323
"django-celery-results>=2.5.1",
2424
"django-concurrency>=2.6.0",
2525
"django-constance>=4.1.3",
@@ -51,6 +51,7 @@ dependencies = [
5151
"sentry-sdk>=2.7.1",
5252
"social-auth-app-django",
5353
"unicef-security>=1.5.1",
54+
"django-pghistory>=3.5.4",
5455
]
5556
[project.scripts]
5657
celery-monitor = "country_workspace.__monitor__:run"

ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ section-order = ["future", "standard-library", "third-party", "first-party", "l
9090
[lint.per-file-ignores]
9191
"tests/**.py" = ["S101", "PLR2004", "S", "SIM117", "D", "UP", "PLR0913", "ANN", "N999"]
9292
"src/**/versioning/**.py" = ["N999", ]
93+
"src/**/migrations/**.py" = ["E501", ]

src/country_workspace/admin/beneficiary_group.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.http import HttpRequest
33

44
from country_workspace.models import BeneficiaryGroup
5+
56
from .base import BaseModelAdmin
67

78

src/country_workspace/admin/user.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.db.models import Q, QuerySet
44
from django.http import HttpRequest, JsonResponse
55
from unicef_security.admin import UserAdminPlus
6+
67
from ..models import User
78

89

src/country_workspace/cache/middleware.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ def process_response(self, request: HttpRequest, response: HttpResponse) -> Http
3636
timeout = self.page_timeout
3737
patch_response_headers(response, timeout)
3838
if response.status_code == 200:
39-
cache_key = self.manager.build_key_from_request(request, "view", getattr(request.user, "pk", ""))
40-
response.headers["Etag"] = cache_key
39+
if "Etag" in response.headers:
40+
cache_key = response.headers["Etag"]
41+
else:
42+
cache_key = self.manager.build_key_from_request(request, "view", getattr(request.user, "pk", ""))
43+
response.headers["Etag"] = cache_key
4144
if hasattr(response, "render") and callable(response.render):
4245
response.add_post_render_callback(lambda r: self.manager.store(cache_key, r))
4346
else:

src/country_workspace/config/fragments/constance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"KOBO_MASTER_API_TOKEN": (KOBO_MASTER_API_TOKEN, "Kobo API Master Access Token", "write_only_input"),
5252
"KOBO_PROJECT_VIEW_ID": (KOBO_PROJECT_VIEW_ID, "Kobo Project View ID", str),
5353
"KOBO_KF_URL": (KOBO_KF_URL, "Kobo Server address", str),
54+
"KOBO_CACHE_TTL": (86400, "Kobo data cache TTL", int),
5455
"CACHE_TIMEOUT": (86400, "Cache Redis TTL", int),
5556
"CACHE_BY_VERSION": (False, "Invalidate Cache on CW version change", bool),
5657
"CONCURRENCY_GUARD": (
@@ -74,6 +75,7 @@
7475
"KOBO_MASTER_API_TOKEN",
7576
"KOBO_PROJECT_VIEW_ID",
7677
"KOBO_KF_URL",
78+
"KOBO_CACHE_TTL",
7779
),
7880
"Data consistency": ("CONCURRENCY_GUARD",),
7981
}

src/country_workspace/config/fragments/csp.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
CSP_DEFAULT_SRC = [
2-
"'self'",
3-
"'unsafe-inline'",
4-
"cdnjs.cloudflare.com",
5-
"saunihopedev.blob.core.windows.net",
6-
"saunihopestg.blob.core.windows.net",
7-
"saunihopetrn.blob.core.windows.net",
8-
"saunihopeprd.blob.core.windows.net",
9-
]
1+
CSP_DEFAULT_SRC = ["'none'"]
102
CSP_STYLE_SRC = [
113
"'self'",
124
"'unsafe-inline'",
135
"same-origin",
6+
"cdnjs.cloudflare.com",
147
"fonts.googleapis.com",
158
"fonts.gstatic.com",
169
"saunihopedev.blob.core.windows.net",
@@ -43,7 +36,6 @@
4336
]
4437
CSP_FONT_SRC = [
4538
"'self'",
46-
"fonts.googleapis.com",
4739
"same-origin",
4840
"fonts.googleapis.com",
4941
"fonts.gstatic.com",
@@ -53,3 +45,4 @@
5345
"saunihopetrn.blob.core.windows.net",
5446
"saunihopeprd.blob.core.windows.net",
5547
]
48+
CSP_CONNECT_SRC = ["'self'"]

0 commit comments

Comments
 (0)