Refactor Extension and Version: explicit constructors from File #191

Merged
Oleg-Komarov merged 6 commits from refactor-models into main 2024-06-20 14:40:41 +02:00

6 Commits

Author SHA1 Message Date
dce7a40241 remove the check, rely on FileForm behavior 2024-06-20 14:33:19 +02:00
77fa0f9b05 cleanups 2024-06-20 13:56:26 +02:00
1df59f7a10 add a check that uploaded file belongs to the current user 2024-06-20 12:49:42 +02:00
c6ba74c76d cleanup unused VersionFactory 2024-06-20 12:36:56 +02:00
61525cc9c3 Merge branch 'main' into refactor-models 2024-06-20 12:25:29 +02:00
6d8fd61b23 Refactor Extension and Version: explicit constructors from File
This change solves a blocker for an upcoming drop of Version.file field:
calculating Extension.latest_version relied on having VersionFiles already
populated, but it was triggered on Version.save(), which happens before the
cross table could be populated.

One functional change is that a Version object is now created in
NewVersionView, immediately after the File is saved, and not in
NewVersionFinalizeView, as before.

Tests are rewritten to require only FileFactory, the Extension and Version
objects are created as if it happens in the rest of production code.
This loses a bit on the ergonomics of factories, but overall makes the state of
test objects more consistent, often simplifying the test code.
2024-06-18 19:50:14 +02:00