Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Develop to Staging v24.40.0 | Patch #2503

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

value = None
try:
value = getattr(object, field_name)
value = getattr(obj, field_name)
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
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)
if isinstance(value, UUID):
return cls.parse_uuid(value)
if isinstance(value, str):
Expand Down
Loading