Repository navigation
Single table for file attachments - #7420
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7420 +/- ##
==========================================
+ Coverage 83.84% 84.01% +0.16%
==========================================
Files 1058 1066 +8
Lines 46442 46618 +176
Branches 1386 1389 +3
==========================================
+ Hits 38941 39166 +225
+ Misses 7141 7092 -49
Partials 360 360
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
- Add new mixin class to designate which models can have attachments
- Ensure other apps are at the correct migration state beforehand
- ContentType does not allow easy API serialization
- Ensure all apps are "up to date" before removing legacy tables
…enTree into attachments-refactor
- Seems to play havoc with bootup sequence
- Use get_global_setting
|
@matmair all passing now, ready for merge if you're happy :) |
| def run_validation(self, data=empty): | ||
| """Override default validation behaviour for this field type.""" | ||
| strict_urls = get_global_setting('INVENTREE_STRICT_URLS', True, cache=False) | ||
| strict_urls = get_global_setting('INVENTREE_STRICT_URLS', cache=False) |
There was a problem hiding this comment.
The default value filters through from the definition of the setting itself, and does not need to be passed here.
| forbidden = [ | ||
| "'", | ||
| '"', | ||
| '#', | ||
| '@', | ||
| '!', | ||
| '&', | ||
| '^', | ||
| '<', | ||
| '>', | ||
| ':', | ||
| ';', | ||
| '/', | ||
| '\\', | ||
| '|', | ||
| '?', | ||
| '*', | ||
| '%', | ||
| '~', | ||
| '`', | ||
| ] |
There was a problem hiding this comment.
We did not add checks when we fixed the original issues as there was some sever time pressure. I will try to add unit tests for unsafe uploads to my todo
| if get_global_setting('INVENTREE_INSTANCE_TITLE'): | ||
| return get_global_setting('INVENTREE_INSTANCE') |
There was a problem hiding this comment.
Q: Why are these defualts changed?
There was a problem hiding this comment.
As above, duplicating the default value here is not required.
| expected_code=201, | ||
| max_query_time=15, | ||
| max_query_count=1000, # TODO: Should look into this | ||
| max_query_count=500 * len(qs), |
There was a problem hiding this comment.
C: 500 queries per entry seems a bit much - do we need to optimise this endpoint?
There was a problem hiding this comment.
The label printing is pretty inefficient, but there's a lot of work required to profile exactly why
| for k in self.plugin_settings_keys(): | ||
| try: | ||
| val = get_global_setting(k, False, create=False) | ||
| val = get_global_setting(k) |
There was a problem hiding this comment.
Q: Why were the defaults removed?
|
One additonal comment: I do not think #5429 is really covered by this but would be closed - wdyt? |
|
With regard to #5429 - we can add the "tags" mixin to the new attachment model, and then the tags can be used for custom data storage. Potentially could add metadata also. |
|
Thank you for the addition! |
* Add basic model for handling generic attachments * Refactor migration * Data migration to convert old files across * Admin updates * Increase comment field max_length * Adjust field name * Remove legacy serializer classes / endpoints * Expose new model to API * Admin site list filters * Remove legacy attachment models - Add new mixin class to designate which models can have attachments * Update data migration - Ensure other apps are at the correct migration state beforehand * Add migrations to remove legacy attachment tables * Fix for "rename_attachment" callback * Refactor model_type field - ContentType does not allow easy API serialization * Set allowed options for admin * Update model verbose names * Fix logic for file upload * Add choices for serializer * Add API filtering * Fix for API filter * Fix for attachment tables in PUI - Still not solved permission issues * Bump API version * Record user when uploading attachment via API * Refactor <AttachmentTable /> for PUI * Display 'file_size' in PUI attachment table * Fix company migrations * Include permission informtion in roles API endpoint * Read user permissions in PUI * Simplify permission checks for <AttachmentTable /> * Automatically clean up old content types * Cleanup PUI * Fix typo in data migration * Add reverse data migration * Update unit tests * Use InMemoryStorage for media files in test mode * Data migration unit test * Fix "model_type" field - It is a required field after all * Add permission check for serializer * Fix permission check for CUI * Fix PUI import * Test python lib against specific branch - Will be reverted once code is merged * Revert STORAGES setting - Might be worth looking into again * Fix part unit test * Fix unit test for sales order * Use 'get_global_setting' * Use 'get_global_setting' * Update setting getter * Unit tests * Tweaks * Revert change to settings.py * More updates for get_global_setting * Relax API query count requirement * remove illegal chars and add unit tests * Fix unit tests * Fix frontend unit tests * settings management updates * Prevent db write under more conditions * Simplify settings code * Pop values before creating filters * Prevent settings write under certain conditions * Add debug msg * Clear db on record import * Refactor permissions checks - Allows extension / customization of permission checks at a later date * Unit test updates * Prevent delete of attachment without correct permissions * Adjust odcker.yaml * Cleanup data migrations * Tweak migration tests for build app * Update data migration - Handle case with missing data * Prevent debug shell in TESTING mode * Update migration dependencies - Ensure all apps are "up to date" before removing legacy tables * add file size test * Update migration tests * Revert some settings caching changes * Fix incorrect logic in migration * Update unit tests * Prevent create on CURRENCY_CODES - Seems to play havoc with bootup sequence * Fix unit test * Some refactoring - Use get_global_setting * Fix typo * Revert change * Add "tags" and "metadata" * Include "tags" field in API serializer * add "metadata" endpoint for attachments
Refactoring how "attachments" are stored, moving to a single table approach.
Tasks
InvenTreeAttachmentMixinclass mixinRelated Issues