Skip to content

Commit

Permalink
Merge pull request #2503 from ohcnetwork/develop
Browse files Browse the repository at this point in the history
Merge Develop to Staging v24.40.0 | Patch
  • Loading branch information
khavinshankar authored Sep 27, 2024
2 parents 31f7b77 + b9a169b commit d6e4aa0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion care/facility/api/serializers/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def validate(self, attrs):
return validated

def validate_taken_at(self, value):
if value and value > timezone.now():
if value and value > timezone.now() + timedelta(minutes=2):
msg = "Cannot create an update in the future"
raise serializers.ValidationError(msg)
return value
14 changes: 7 additions & 7 deletions care/utils/event_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ def get_changed_fields(old: Model, new: Model) -> set[str]:
def serialize_field(obj: Model, field_name: str):
if "__" in field_name:
field_name, sub_field = field_name.split("__", 1)
related_object = getattr(obj, field_name, None)
return serialize_field(related_object, sub_field)
related_obj = getattr(obj, field_name, None)
return serialize_field(related_obj, sub_field)

Check warning on line 28 in care/utils/event_utils.py

View check run for this annotation

Codecov / codecov/patch

care/utils/event_utils.py#L27-L28

Added lines #L27 - L28 were not covered by tests

value = None
try:
value = getattr(object, field_name)
value = getattr(obj, field_name)

Check warning on line 32 in care/utils/event_utils.py

View check run for this annotation

Codecov / codecov/patch

care/utils/event_utils.py#L32

Added line #L32 was not covered by tests
except AttributeError:
if object is not None:
if obj is not None:
logger.warning(
"Field %s not found in %s", field_name, object.__class__.__name__
"Field %s not found in %s", field_name, obj.__class__.__name__
)
return None

try:
# serialize choice fields with display value
field = object._meta.get_field(field_name) # noqa: SLF001
field = obj._meta.get_field(field_name) # noqa: SLF001

Check warning on line 42 in care/utils/event_utils.py

View check run for this annotation

Codecov / codecov/patch

care/utils/event_utils.py#L42

Added line #L42 was not covered by tests
if issubclass(field.__class__, Field) and field.choices:
value = getattr(object, f"get_{field_name}_display", lambda: value)()
value = getattr(obj, f"get_{field_name}_display", lambda: value)()
except FieldDoesNotExist:
# the required field is a property and not a model field
pass
Expand Down
2 changes: 1 addition & 1 deletion care/utils/ulid/ulid.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ULID(BaseULID):
@classmethod
def parse(cls, value) -> Self:
if isinstance(value, BaseULID):
return cls.parse_baseulid(value)
return cls.parse_ulid(value)

Check warning on line 17 in care/utils/ulid/ulid.py

View check run for this annotation

Codecov / codecov/patch

care/utils/ulid/ulid.py#L17

Added line #L17 was not covered by tests
if isinstance(value, UUID):
return cls.parse_uuid(value)

Check warning on line 19 in care/utils/ulid/ulid.py

View check run for this annotation

Codecov / codecov/patch

care/utils/ulid/ulid.py#L19

Added line #L19 was not covered by tests
if isinstance(value, str):
Expand Down

0 comments on commit d6e4aa0

Please sign in to comment.