mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-25 09:13:08 +00:00
[API] Filter refactor (#11073)
* Lazy evaluation of optional serializer fields - Add OptionalField dataclass - Pass serializer class and kwargs separately * Refactor BuildLineSerializer class * Simplify gathering * Refactor BuildSerializer * Refactor other Build serializers * Refactor Part serializers * Refactoring more serializers to use OptionalField * More refactoring * Cleanup for mixin class * Ensure any optional fields we added in are not missed * Fixes * Rehydrate optional fields for metadata * Add TreePathSerializer class * Further improvements: - Handle case where optional field shadows model property - Consider read_only and write_only fields * Adjust unit tests * Fix for "build_relational_field" - Handle case where optional field shadows model relation * Fix case where multiple fields can share same filter * additional unit tests * Bump API version * Remove top-level detection - Request object is only available for the top-level serializer anyway * Cache serializer to prevent multiple __init__ calls * Revert caching change - Breaks search results * Simplify field removal * Adjust unit test * Remove docstring comment which is no longer true * Ensure read-only fields are skipped for data import * Use SAFE_METHODS * Do not convert to lowercase * Updated docstring * Remove FilterableSerializerField mixin - Annotation now performed using OptionalField - Code can be greatly simplified * Ensure all fields are returned when generating schema * Fix order of operations * Add assertion to unit test * fix style * Fix api_version * Remove duplicate API entries * Remove duplicate API entries * Fix formatting in api_version.py * Tweak ManufacturerPart serializer * Revert formatting change --------- Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
1 parent
5aaf1cfcab
commit
40b67f5f12
20 files changed
+1263
-956
No files matched your search
@@ -218,8 +218,11 @@ class UserAPITests(InvenTreeAPITestCase):
|
||||
expected_code=200,
|
||||
)
|
||||
self.assertIn('name', response.data)
|
||||
self.assertIn('roles', response.data)
|
||||
self.assertIn('permissions', response.data)
|
||||
|
||||
self.assertGreater(len(response.data['roles']), 0)
|
||||
|
||||
def test_login_redirect(self):
|
||||
"""Test login redirect endpoint."""
|
||||
response = self.get(reverse('api-login-redirect'), expected_code=302)
|
||||
|
||||
Reference in new issue
Block a user