Skip to content

Commit 26763e3

Browse files
authored
Merge pull request #150 from unicef/bugfix/fix-failing-program-validation
Fix issue of failing 'validate_program' task function by adding state
2 parents 9afb265 + 9f42f2f commit 26763e3

File tree

1 file changed

+7
-5
lines changed
  • src/country_workspace/workspaces/admin/cleaners

1 file changed

+7
-5
lines changed

src/country_workspace/workspaces/admin/cleaners/validate.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.db.models import Model, QuerySet
55

66
from country_workspace.models import AsyncJob, Household, Program
7+
from country_workspace.state import state
78

89
if TYPE_CHECKING:
910
from country_workspace.models.base import Validable
@@ -32,11 +33,12 @@ def validate_program(job: AsyncJob) -> dict[str, int]:
3233
hh: Household
3334
try:
3435
p: Program = job.program
35-
for hh in Household.objects.filter(batch__program=p):
36-
if hh.validate_with_checker():
37-
valid += 1
38-
else:
39-
invalid += 1
36+
with state.set(tenant=p.country_office, program=p):
37+
for hh in Household.objects.filter(batch__program=p):
38+
if hh.validate_with_checker():
39+
valid += 1
40+
else:
41+
invalid += 1
4042
except Exception as e: # pragma: no cover
4143
logger.error(e)
4244
raise

0 commit comments

Comments
 (0)