Skip to content

Conversation

alex-run-code
Copy link
Contributor

No description provided.

def get_psea_last_assessment_date(self, obj):
if getattr(obj, 'psea_assessment_date', None):
try:
return obj.psea_assessment_date.date().isoformat()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would this raise an exception? and which type of exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is that if psea_assessment_date is already a date (or some other type like str), calling .date() fails.
Exception type: typically AttributeError (e.g., "'datetime.date' object has no attribute 'date'")

But this might be too convoluted, let's just use a regular datefield

file_field = getattr(obj, 'attached_agreement', None)
if file_field:
try:
return file_field.url if file_field.name else None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this bit throws me off a bit... I don’t understand why you would do that there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea here was that if file_field.name doesnt exist, file_field.url would throw a ValueError, but let's keep it simple with a url field.

@fpbonet fpbonet enabled auto-merge (squash) October 16, 2025 08:54
@fpbonet fpbonet disabled auto-merge October 16, 2025 09:00
@fpbonet fpbonet merged commit 580c3d9 into develop Oct 16, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants