openlibhums / openlibhums/janeway
Refactor file models
Open
Nobody has claimed this yet.
enhancement
Infrastructure
janeway 2.0
refactoring
t-shirt epic
- Dominant language
- Python
- Stars
- 238
- Forks
- 97
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 8
Description
The File models have grown a little hairy over time:
- The
core.models.Filemodel 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). - The
core.models.Filemodel exposes the vestigial attributeis_galley, should be removed and its references replaced with an instance ofGalley - Deleting a
core.models.Fileobject leaves an orphan file in the filesystem, we should either remove the file or just flag the File object asdeleted core.models.Galleyholds 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.Galleyhasis_remoteandremote_fileattributes which are interdependent. The presence of aremote_fileshould indicate if a galley is remote (could expose a property namedis_remotepreserve the original interface)core.models.Filealso hasis_remoteandremote_urlwhich can get out of sync with Galley. Should only exist on one of the two models.core.models.Galleyandcore.models.Fileexpose a method to build a path for serving an article. Both are currently in use.core.models.Fileobjects cannot access the file itself, unless you somehow know where the article lives in the filesystem (under articles, under journals, under plugins...). AFileinstance 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.Fileexposes instance methodsget_file_pathandget_article_pathwhereget_file_pathtakes an argumentarticle_idwhilst 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.Fileexposes an instance method namedpreprint_path. This should be on a different model, as not all instances of File are preprintscore.models.FileHistoryis clever but it is tightly coupled with Article model. Should work for any file
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by mapping the relationships and references among core.models.File, core.models.Galley, core.models.FileHistory, and submission.Article. Review existing uses of Django FileSystemStorage and the path-building methods before deciding where responsibilities belong. Done means resolving the listed ownership, consistency, deletion, storage, and generic-history concerns without leaving conflicting model interfaces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100