Refactor file models #865
Labels
enhancement
Add or improve something on an existing feature
t-shirt epic
A very large piece of work that will need to be broken up into smaller issues
The File models have grown a little hairy over time:
core.models.File
model holds a reference to submission.Article objects and exposes methods to interact with the article. Could use an ArticleFile model instead (or defer this responsibilities tocore.models.Galley
).core.models.File
model exposes the vestigial attributeis_galley
, should be removed and its references replaced with an instance ofGalley
core.models.File
object leaves an orphan file in the filesystem, we should either remove the file or just flag the File object asdeleted
core.models.Galley
holds a key to a Article and File, while File also holds a key to Article. The two could get out of sync. Either we make Galley inherit from a File base model OR Galley holds a key to an ArticleFile but not to an Article`core.models.Galley
hasis_remote
andremote_file
attributes which are interdependent. The presence of aremote_file
should indicate if a galley is remote (could expose a property namedis_remote
preserve the original interface)core.models.File
also hasis_remote
andremote_url
which can get out of sync with Galley. Should only exist on one of the two models.core.models.Galley
andcore.models.File
expose a method to build a path for serving an article. Both are currently in use.core.models.File
objects cannot access the file itself, unless you somehow know where the article lives in the filesystem (under articles, under journals, under plugins...). AFile
instance should be able to retrieve the file on its own. Ideally, we would use Django's ``FileSystemStorage` for this, as we do with other files in the codebase.core.models.File
exposes instance methodsget_file_path
andget_article_path
whereget_file_path
takes an argumentarticle_id
whilst already holding in its state an article id. This means that a file instance could serve the path to any article file, not just itself.core.models.File
exposes an instance method namedpreprint_path
. This should be on a different model, as not all instances of File are preprintscore.models.FileHistory
is clever but it is tightly coupled with Article model. Should work for any fileThe text was updated successfully, but these errors were encountered: