sending weekly email can crash
last week PRC had a problem:
Dear Piotr,
We did not receive this morning the automatic calendar for NCER project.
Could you please check and send it to all of us (in particular to ibbl)
Have a nice weekend
Best
Jean-Yves
I dig a bit and here is stacktrace that I found in the logs (sorry for poor formatting):
37934 | web.kit_request_weekly_email | 2018-10-26 08:00:04.338545+02 | 2018-10-26 08:00:04.771864+02 | f | Traceback (most recent call last): +|
| | | | | File "/var/www/scheduling-system/env/local/lib/python2.7/site-packages/django_cron/management/commands/runcrons.py", line 73, in run_cron_with_cache_check+|
| | | | | manager.run(force) +|
| | | | | File "/var/www/scheduling-system/env/local/lib/python2.7/site-packages/django_cron/__init__.py", line 215, in run +|
| | | | | self.msg = self.cron_job.do() +|
| | | | | File "/var/www/scheduling-system/smash/web/views/kit.py", line 160, in do +|
| | | | | send_mail(data) +|
| | | | | File "/var/www/scheduling-system/smash/web/views/kit.py", line 109, in send_mail +|
| | | | | email_body += "<td style='" + cell_style + "'>" + appointment.visit.subject.nd_number + "</td>" +|
| | | | | AttributeError: 'NoneType' object has no attribute 'subject'
The problem:
Someone created a general appointment with assessment type requiring sample taking (like skin biopsy). The idea was probably to book a slot for unknown person. So when we prepare weekly email to be sent there is no one assigned to the appointment and it's impossible to access subject data and we have an exception raised.