Describe the bug
Going to the url of a work imported from AO3 gives an error page. The following error is logged:
django.request ERROR 2024-04-24 13:51:06,149 log 116173 139814288162880 Internal Server Error: /works/52/
Traceback (most recent call last):
File "/home/ourchive/ourchive/virtualenv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/ourchive/ourchive/virtualenv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ourchive/ourchive/virtualenv/lib/python3.10/site-packages/django/views/decorators/http.py", line 64, in inner
return func(request, *args, **kwargs)
File "/home/ourchive/ourchive/ourchive_app/frontend/views.py", line 1230, in work
chapter = format_date_for_template(chapter, 'updated_on')
File "/home/ourchive/ourchive/ourchive_app/frontend/view_utils.py", line 331, in format_date_for_template
obj[field_name] = parse(obj[field_name]).date()
File "/home/ourchive/ourchive/virtualenv/lib/python3.10/site-packages/dateutil/parser/_parser.py", line 1368, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/home/ourchive/ourchive/virtualenv/lib/python3.10/site-packages/dateutil/parser/_parser.py", line 640, in parse
res, skipped_tokens = self._parse(timestr, **kwargs)
File "/home/ourchive/ourchive/virtualenv/lib/python3.10/site-packages/dateutil/parser/_parser.py", line 719, in _parse
l = _timelex.split(timestr) # Splits the timestr into tokens
File "/home/ourchive/ourchive/virtualenv/lib/python3.10/site-packages/dateutil/parser/_parser.py", line 201, in split
return list(cls(s))
File "/home/ourchive/ourchive/virtualenv/lib/python3.10/site-packages/dateutil/parser/_parser.py", line 69, in __init__
raise TypeError('Parser must be a string or character stream, not '
What's happening is that formatting the chapter updated_on date for the template is failing, because the chapter has a value of None for that field. The work has a value for updated_on - it's just the chapter that doesn't. Looking in the ETL code a bit, I think that we just can't get an updated date for individual chapters from the AO3 data, so it never gets mapped. In that case, it shouldn't be required to display the chapter or its work.
I will submit a PR to ignore the chapter updated_on if we don't have it, so that the work can be shown. If I'm wrong and this should rather be fixed in the AO3 importer, I can do that instead. :)
Describe the bug Going to the url of a work imported from AO3 gives an error page. The following error is logged:
What's happening is that formatting the chapter updated_on date for the template is failing, because the chapter has a value of None for that field. The work has a value for updated_on - it's just the chapter that doesn't. Looking in the ETL code a bit, I think that we just can't get an updated date for individual chapters from the AO3 data, so it never gets mapped. In that case, it shouldn't be required to display the chapter or its work.
I will submit a PR to ignore the chapter updated_on if we don't have it, so that the work can be shown. If I'm wrong and this should rather be fixed in the AO3 importer, I can do that instead. :)
To Reproduce
"updated_on": null
Expected behavior Opening the url of a work should display the work.
Desktop (please complete the following information):
Hosting Digital Ocean droplet running Ubuntu 22.04.