-
Notifications
You must be signed in to change notification settings - Fork 7
278284 agreements endpoints #4069
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
Conversation
def get_psea_last_assessment_date(self, obj): | ||
if getattr(obj, 'psea_assessment_date', None): | ||
try: | ||
return obj.psea_assessment_date.date().isoformat() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
No description provided.