Skip to content

Commit

Permalink
Don't update admin orgs from NGO Hub
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Nov 13, 2024
1 parent 57b256b commit 1e8ce08
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions backend/hub/workers/update_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,16 @@ def get_ngo_hub_data(ngohub_org_id: int, token: str = "") -> Dict:

def update_organization_process(organization_id: int, token: str = ""):
errors: List[str] = []
task_result: Dict[str, any] = {"organization_id": organization_id}

organization: Organization = Organization.objects.get(id=organization_id)

if organization.status == Organization.STATUS.admin:
logger.info(f"Organization {organization.id} is an admin organization and cannot be updated.")
task_result["errors"] = ["Organization is an admin organization and cannot be updated."]

return task_result

organization.ngohub_last_update_started = timezone.now()
organization.save()

Expand Down Expand Up @@ -219,7 +226,6 @@ def update_organization_process(organization_id: int, token: str = ""):

organization.save()

task_result: Dict[str, any] = {"organization_id": organization_id}
if errors:
task_result["errors"] = errors

Expand Down Expand Up @@ -272,12 +278,14 @@ def update_outdated_organizations():

last_7_days = timezone.now() - timezone.timedelta(days=7)
accepted_statuses = (Organization.STATUS.accepted, Organization.STATUS.pending)
organizations = Organization.objects.filter(
modified__lte=last_7_days,
status__in=accepted_statuses,
).order_by(
"modified"
)[:limit]
organizations = (
Organization.objects.filter(
modified__lte=last_7_days,
status__in=accepted_statuses,
)
.exclude(status=Organization.STATUS.admin)
.order_by("modified")[:limit]
)

organizations_ids: List[int] = []
if not organizations:
Expand Down

0 comments on commit 1e8ce08

Please sign in to comment.