Closed mauromsl closed 5 years ago
@mauromsl there should be no case where a file does not have an article_id. I think we should make the article_id field not null and not blank.
>>> files = models.File.objects.filter(article_id__isnull=True)
>>> files.count()
0
Someone has gone into admin and deleted the article ID for that file...
But your query returned a count of zero, if what you are saying is what happened, shouldn't the count have returned (at least) 1, for the file that triggered the error?
That count was from my copy of the DB. Will look at adding a RunPython migration to handle any with missing PKs.
It looks like
self_article_path()
can returnNone
: https://github.com/BirkbeckCTP/janeway/blob/c80dba661a50bf3220fa63b5e2eaad2c6678821d/src/core/models.py#L628-L630 Which triggers a TypeError being raised here: https://github.com/BirkbeckCTP/janeway/blob/c80dba661a50bf3220fa63b5e2eaad2c6678821d/src/core/models.py#L659