Skip to content

Commit

Permalink
fix: OUCRC mobile bug
Browse files Browse the repository at this point in the history
[IA-3878] Fix `created_at` is `null` when downloading OUCRC
  • Loading branch information
tdethier authored Jan 20, 2025
2 parents a8b43ed + 6eaf574 commit 457b482
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from itertools import chain

import django_filters
from django.utils import timezone
from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema

from rest_framework import viewsets
from rest_framework.mixins import ListModelMixin
from rest_framework.request import Request
Expand Down Expand Up @@ -78,7 +78,12 @@ def list(self, request: Request, *args, **kwargs) -> Response:
non_editable_org_unit_type_ids = project_org_unit_types - user_editable_org_unit_type_ids

dynamic_configurations = [
OrgUnitChangeRequestConfiguration(org_unit_type_id=org_unit_type_id, org_units_editable=False)
OrgUnitChangeRequestConfiguration(
org_unit_type_id=org_unit_type_id,
org_units_editable=False,
created_at=timezone.now(),
updated_at=timezone.now(),
)
for org_unit_type_id in non_editable_org_unit_type_ids
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import datetime
import time_machine

from django.utils import timezone

from rest_framework import status

from django.contrib.auth.models import Group

from iaso import models as m
from iaso.tests.api.org_unit_change_request_configurations.common_base_with_setup import OUCRCAPIBase

CREATED_AT = datetime.datetime(2025, 1, 20, 10, 31, 0, 0, tzinfo=timezone.utc)


@time_machine.travel(CREATED_AT, tick=False)
class MobileOrgUnitChangeRequestConfigurationAPITestCase(OUCRCAPIBase):
"""
Test mobile OUCRCViewSet.
Expand Down Expand Up @@ -104,8 +112,8 @@ def test_list_ok_with_restricted_write_permission_for_user(self):
"group_set_ids": [],
"editable_reference_form_ids": [],
"other_group_ids": [],
"created_at": None,
"updated_at": None,
"created_at": CREATED_AT.timestamp(),
"updated_at": CREATED_AT.timestamp(),
},
# Because of the configuration of his Profile, the user can't write on `ou_type_water_pokemons`,
# so we override the existing configuration.
Expand All @@ -118,8 +126,8 @@ def test_list_ok_with_restricted_write_permission_for_user(self):
"group_set_ids": [],
"editable_reference_form_ids": [],
"other_group_ids": [],
"created_at": None,
"updated_at": None,
"created_at": CREATED_AT.timestamp(),
"updated_at": CREATED_AT.timestamp(),
},
# Because of the configuration of his Profile, the user can't write on `new_org_unit_type_1`,
# and since there is no existing configuration, we add a dynamic one.
Expand All @@ -132,8 +140,8 @@ def test_list_ok_with_restricted_write_permission_for_user(self):
"group_set_ids": [],
"editable_reference_form_ids": [],
"other_group_ids": [],
"created_at": None,
"updated_at": None,
"created_at": CREATED_AT.timestamp(),
"updated_at": CREATED_AT.timestamp(),
},
# Because of the configuration of his Profile, the user can't write on `new_org_unit_type_2`,
# and since there is no existing configuration, we add a dynamic one.
Expand All @@ -146,8 +154,8 @@ def test_list_ok_with_restricted_write_permission_for_user(self):
"group_set_ids": [],
"editable_reference_form_ids": [],
"other_group_ids": [],
"created_at": None,
"updated_at": None,
"created_at": CREATED_AT.timestamp(),
"updated_at": CREATED_AT.timestamp(),
},
],
)
Expand Down

0 comments on commit 457b482

Please sign in to comment.