wbcore 2.2.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wbcore/__init__.py +1 -0
- wbcore/admin.py +197 -0
- wbcore/apps.py +17 -0
- wbcore/cache/__init__.py +0 -0
- wbcore/cache/buttons.py +22 -0
- wbcore/cache/decorators.py +29 -0
- wbcore/cache/mixins.py +48 -0
- wbcore/cache/registry.py +90 -0
- wbcore/cache/views.py +18 -0
- wbcore/configs/__init__.py +11 -0
- wbcore/configs/configs.py +51 -0
- wbcore/configs/decorators.py +11 -0
- wbcore/configs/registry.py +35 -0
- wbcore/configs/views.py +11 -0
- wbcore/configurations/__init__.py +1 -0
- wbcore/configurations/base.py +45 -0
- wbcore/configurations/configurations/__init__.py +16 -0
- wbcore/configurations/configurations/apps.py +54 -0
- wbcore/configurations/configurations/authentication.py +43 -0
- wbcore/configurations/configurations/base.py +15 -0
- wbcore/configurations/configurations/cache.py +20 -0
- wbcore/configurations/configurations/celery.py +26 -0
- wbcore/configurations/configurations/i18nl10n.py +10 -0
- wbcore/configurations/configurations/mail.py +2 -0
- wbcore/configurations/configurations/maintenance.py +53 -0
- wbcore/configurations/configurations/media.py +22 -0
- wbcore/configurations/configurations/middleware.py +27 -0
- wbcore/configurations/configurations/network.py +19 -0
- wbcore/configurations/configurations/rest_framework.py +42 -0
- wbcore/configurations/configurations/static.py +28 -0
- wbcore/configurations/configurations/templates.py +17 -0
- wbcore/configurations/configurations/uvicorn.py +9 -0
- wbcore/configurations/configurations/wbcore.py +68 -0
- wbcore/content_type/__init__.py +0 -0
- wbcore/content_type/admin.py +8 -0
- wbcore/content_type/filters.py +19 -0
- wbcore/content_type/serializers.py +89 -0
- wbcore/content_type/utils.py +30 -0
- wbcore/content_type/viewsets.py +80 -0
- wbcore/contrib/__init__.py +0 -0
- wbcore/contrib/agenda/__init__.py +0 -0
- wbcore/contrib/agenda/admin/__init__.py +2 -0
- wbcore/contrib/agenda/admin/calendar_item.py +13 -0
- wbcore/contrib/agenda/admin/conference_room.py +18 -0
- wbcore/contrib/agenda/apps.py +6 -0
- wbcore/contrib/agenda/configurations.py +11 -0
- wbcore/contrib/agenda/factories/__init__.py +2 -0
- wbcore/contrib/agenda/factories/calendar_item.py +47 -0
- wbcore/contrib/agenda/factories/conference_room.py +19 -0
- wbcore/contrib/agenda/filters/__init__.py +2 -0
- wbcore/contrib/agenda/filters/calendar_item.py +64 -0
- wbcore/contrib/agenda/filters/conference_room.py +41 -0
- wbcore/contrib/agenda/migrations/0001_initial.py +84 -0
- wbcore/contrib/agenda/migrations/0002_initial.py +26 -0
- wbcore/contrib/agenda/migrations/0003_calendaritem_endpoint_basename.py +42 -0
- wbcore/contrib/agenda/migrations/0004_alter_calendaritem_item_type.py +17 -0
- wbcore/contrib/agenda/migrations/0005_building_and_more.py +94 -0
- wbcore/contrib/agenda/migrations/0006_calendaritem_is_deletable.py +17 -0
- wbcore/contrib/agenda/migrations/0007_alter_calendaritem_options.py +21 -0
- wbcore/contrib/agenda/migrations/0008_alter_calendaritem_item_type.py +17 -0
- wbcore/contrib/agenda/migrations/0009_alter_calendaritem_icon.py +18 -0
- wbcore/contrib/agenda/migrations/__init__.py +0 -0
- wbcore/contrib/agenda/models/__init__.py +2 -0
- wbcore/contrib/agenda/models/calendar_item.py +238 -0
- wbcore/contrib/agenda/models/conference_room.py +95 -0
- wbcore/contrib/agenda/release_notes/1_0_0.md +13 -0
- wbcore/contrib/agenda/release_notes/__init__.py +0 -0
- wbcore/contrib/agenda/serializers/__init__.py +10 -0
- wbcore/contrib/agenda/serializers/calendar_item.py +76 -0
- wbcore/contrib/agenda/serializers/conference_room.py +98 -0
- wbcore/contrib/agenda/signals.py +8 -0
- wbcore/contrib/agenda/tests/__init__.py +0 -0
- wbcore/contrib/agenda/tests/conftest.py +14 -0
- wbcore/contrib/agenda/tests/signals.py +16 -0
- wbcore/contrib/agenda/tests/test_models.py +34 -0
- wbcore/contrib/agenda/tests/test_viewsets.py +171 -0
- wbcore/contrib/agenda/tests/tests.py +25 -0
- wbcore/contrib/agenda/typings.py +19 -0
- wbcore/contrib/agenda/urls.py +25 -0
- wbcore/contrib/agenda/viewsets/__init__.py +13 -0
- wbcore/contrib/agenda/viewsets/buttons/__init__.py +1 -0
- wbcore/contrib/agenda/viewsets/buttons/conference_room.py +20 -0
- wbcore/contrib/agenda/viewsets/calendar_items.py +168 -0
- wbcore/contrib/agenda/viewsets/conference_room.py +48 -0
- wbcore/contrib/agenda/viewsets/display/__init__.py +2 -0
- wbcore/contrib/agenda/viewsets/display/calendar_items.py +17 -0
- wbcore/contrib/agenda/viewsets/display/conference_room.py +41 -0
- wbcore/contrib/agenda/viewsets/endpoints/__init__.py +1 -0
- wbcore/contrib/agenda/viewsets/endpoints/calendar_items.py +18 -0
- wbcore/contrib/agenda/viewsets/menu/__init__.py +2 -0
- wbcore/contrib/agenda/viewsets/menu/calendar_items.py +17 -0
- wbcore/contrib/agenda/viewsets/menu/conference_room.py +37 -0
- wbcore/contrib/agenda/viewsets/titles/__init__.py +2 -0
- wbcore/contrib/agenda/viewsets/titles/calendar_items.py +7 -0
- wbcore/contrib/agenda/viewsets/titles/conference_room.py +24 -0
- wbcore/contrib/ai/__init__.py +0 -0
- wbcore/contrib/ai/apps.py +5 -0
- wbcore/contrib/ai/exceptions.py +42 -0
- wbcore/contrib/ai/llm/__init__.py +0 -0
- wbcore/contrib/ai/llm/config.py +107 -0
- wbcore/contrib/ai/llm/decorators.py +10 -0
- wbcore/contrib/ai/llm/mixins.py +35 -0
- wbcore/contrib/ai/llm/utils.py +45 -0
- wbcore/contrib/authentication/__init__.py +9 -0
- wbcore/contrib/authentication/admin.py +247 -0
- wbcore/contrib/authentication/apps.py +14 -0
- wbcore/contrib/authentication/authentication.py +162 -0
- wbcore/contrib/authentication/configs.py +9 -0
- wbcore/contrib/authentication/configurations.py +53 -0
- wbcore/contrib/authentication/dynamic_preferences_registry.py +26 -0
- wbcore/contrib/authentication/factories/__init__.py +3 -0
- wbcore/contrib/authentication/factories/tokens.py +15 -0
- wbcore/contrib/authentication/factories/users.py +82 -0
- wbcore/contrib/authentication/factories/users_activities.py +19 -0
- wbcore/contrib/authentication/filters.py +18 -0
- wbcore/contrib/authentication/management/__init__.py +14 -0
- wbcore/contrib/authentication/migrations/0001_initial_squashed.py +174 -0
- wbcore/contrib/authentication/migrations/0002_profile.py +26 -0
- wbcore/contrib/authentication/migrations/0003_alter_user_profile.py +34 -0
- wbcore/contrib/authentication/migrations/0004_token.py +51 -0
- wbcore/contrib/authentication/migrations/0005_user_external_calendar_settings.py +17 -0
- wbcore/contrib/authentication/migrations/0006_auto_20231206_1422.py +13 -0
- wbcore/contrib/authentication/migrations/__init__.py +0 -0
- wbcore/contrib/authentication/models/__init__.py +3 -0
- wbcore/contrib/authentication/models/tokens.py +140 -0
- wbcore/contrib/authentication/models/users.py +225 -0
- wbcore/contrib/authentication/models/users_activities.py +112 -0
- wbcore/contrib/authentication/release_notes/1_0_0.md +13 -0
- wbcore/contrib/authentication/release_notes/__init__.py +0 -0
- wbcore/contrib/authentication/serializers/__init__.py +14 -0
- wbcore/contrib/authentication/serializers/users.py +350 -0
- wbcore/contrib/authentication/serializers/users_activites.py +37 -0
- wbcore/contrib/authentication/tasks.py +29 -0
- wbcore/contrib/authentication/tests/__init__.py +0 -0
- wbcore/contrib/authentication/tests/conftest.py +18 -0
- wbcore/contrib/authentication/tests/e2e/__init__.py +1 -0
- wbcore/contrib/authentication/tests/e2e/e2e_auth_utility.py +20 -0
- wbcore/contrib/authentication/tests/signals.py +17 -0
- wbcore/contrib/authentication/tests/test_configs.py +6 -0
- wbcore/contrib/authentication/tests/test_serializers.py +6 -0
- wbcore/contrib/authentication/tests/test_tasks.py +33 -0
- wbcore/contrib/authentication/tests/test_tokens.py +126 -0
- wbcore/contrib/authentication/tests/test_users.py +338 -0
- wbcore/contrib/authentication/tests/test_viewsets.py +6 -0
- wbcore/contrib/authentication/tests/tests.py +15 -0
- wbcore/contrib/authentication/urls.py +97 -0
- wbcore/contrib/authentication/utils.py +10 -0
- wbcore/contrib/authentication/viewsets/__init__.py +19 -0
- wbcore/contrib/authentication/viewsets/buttons/__init__.py +1 -0
- wbcore/contrib/authentication/viewsets/buttons/users.py +55 -0
- wbcore/contrib/authentication/viewsets/display/__init__.py +6 -0
- wbcore/contrib/authentication/viewsets/display/user_activities.py +85 -0
- wbcore/contrib/authentication/viewsets/display/users.py +72 -0
- wbcore/contrib/authentication/viewsets/endpoints/__init__.py +6 -0
- wbcore/contrib/authentication/viewsets/endpoints/user_activities.py +22 -0
- wbcore/contrib/authentication/viewsets/endpoints/users.py +20 -0
- wbcore/contrib/authentication/viewsets/menu/__init__.py +6 -0
- wbcore/contrib/authentication/viewsets/menu/user_activities.py +39 -0
- wbcore/contrib/authentication/viewsets/menu/users.py +16 -0
- wbcore/contrib/authentication/viewsets/titles/__init__.py +12 -0
- wbcore/contrib/authentication/viewsets/titles/user_activities.py +31 -0
- wbcore/contrib/authentication/viewsets/titles/users.py +26 -0
- wbcore/contrib/authentication/viewsets/user_activities.py +222 -0
- wbcore/contrib/authentication/viewsets/users.py +328 -0
- wbcore/contrib/color/migrations/0001_initial.py +33 -0
- wbcore/contrib/color/migrations/0002_alter_colorgradient_colors.py +25 -0
- wbcore/contrib/color/migrations/__init__.py +0 -0
- wbcore/contrib/currency/__init__.py +0 -0
- wbcore/contrib/currency/admin.py +32 -0
- wbcore/contrib/currency/apps.py +5 -0
- wbcore/contrib/currency/dynamic_preferences_registry.py +39 -0
- wbcore/contrib/currency/factories.py +39 -0
- wbcore/contrib/currency/import_export/__init__.py +0 -0
- wbcore/contrib/currency/import_export/backends/__init__.py +1 -0
- wbcore/contrib/currency/import_export/backends/fixerio/__init__.py +1 -0
- wbcore/contrib/currency/import_export/backends/fixerio/currency_fx_rates.py +66 -0
- wbcore/contrib/currency/import_export/backends/utils.py +5 -0
- wbcore/contrib/currency/import_export/handlers/__init__.py +2 -0
- wbcore/contrib/currency/import_export/handlers/currency.py +24 -0
- wbcore/contrib/currency/import_export/handlers/currency_fx_rates.py +28 -0
- wbcore/contrib/currency/import_export/parsers/__init__.py +0 -0
- wbcore/contrib/currency/import_export/parsers/fixerio/__init__.py +0 -0
- wbcore/contrib/currency/import_export/parsers/fixerio/currency_fx_rates.py +34 -0
- wbcore/contrib/currency/migrations/0001_initial.py +89 -0
- wbcore/contrib/currency/migrations/__init__.py +0 -0
- wbcore/contrib/currency/models.py +176 -0
- wbcore/contrib/currency/release_notes/1_0_0.md +13 -0
- wbcore/contrib/currency/release_notes/__init__.py +0 -0
- wbcore/contrib/currency/serializers.py +40 -0
- wbcore/contrib/currency/tests/__init__.py +0 -0
- wbcore/contrib/currency/tests/conftest.py +7 -0
- wbcore/contrib/currency/tests/test_models.py +104 -0
- wbcore/contrib/currency/tests/test_serializers.py +62 -0
- wbcore/contrib/currency/tests/test_viewsets.py +197 -0
- wbcore/contrib/currency/urls.py +19 -0
- wbcore/contrib/currency/viewsets/__init__.py +2 -0
- wbcore/contrib/currency/viewsets/buttons/__init__.py +0 -0
- wbcore/contrib/currency/viewsets/currency.py +56 -0
- wbcore/contrib/currency/viewsets/currency_fx_rates.py +32 -0
- wbcore/contrib/currency/viewsets/display/__init__.py +2 -0
- wbcore/contrib/currency/viewsets/display/currency.py +37 -0
- wbcore/contrib/currency/viewsets/display/currency_fx_rates.py +9 -0
- wbcore/contrib/currency/viewsets/endpoints/__init__.py +1 -0
- wbcore/contrib/currency/viewsets/endpoints/currency_fx_rates.py +14 -0
- wbcore/contrib/currency/viewsets/menu/__init__.py +1 -0
- wbcore/contrib/currency/viewsets/menu/currency.py +8 -0
- wbcore/contrib/currency/viewsets/preview/__init__.py +1 -0
- wbcore/contrib/currency/viewsets/preview/currency.py +10 -0
- wbcore/contrib/currency/viewsets/titles/__init__.py +2 -0
- wbcore/contrib/currency/viewsets/titles/currency.py +6 -0
- wbcore/contrib/currency/viewsets/titles/currency_fx_rates.py +8 -0
- wbcore/contrib/dataloader/__init__.py +1 -0
- wbcore/contrib/dataloader/apps.py +5 -0
- wbcore/contrib/dataloader/dataloaders/__init__.py +2 -0
- wbcore/contrib/dataloader/dataloaders/dataloaders.py +24 -0
- wbcore/contrib/dataloader/dataloaders/proxies.py +81 -0
- wbcore/contrib/dataloader/models/__init__.py +1 -0
- wbcore/contrib/dataloader/models/entities.py +29 -0
- wbcore/contrib/dataloader/models/querysets/__init__.py +1 -0
- wbcore/contrib/dataloader/models/querysets/entities.py +27 -0
- wbcore/contrib/dataloader/tests/__init__.py +0 -0
- wbcore/contrib/dataloader/tests/conftest.py +26 -0
- wbcore/contrib/dataloader/tests/test/__init__.py +0 -0
- wbcore/contrib/dataloader/tests/test/dataloaders/__init__.py +0 -0
- wbcore/contrib/dataloader/tests/test/dataloaders/dataloaders.py +18 -0
- wbcore/contrib/dataloader/tests/test/dataloaders/protocols.py +6 -0
- wbcore/contrib/dataloader/tests/test/dataloaders/proxies.py +11 -0
- wbcore/contrib/dataloader/tests/test/factories.py +13 -0
- wbcore/contrib/dataloader/tests/test/models.py +10 -0
- wbcore/contrib/dataloader/tests/test_dataloaders.py +37 -0
- wbcore/contrib/dataloader/tests/test_entities.py +12 -0
- wbcore/contrib/dataloader/utils.py +17 -0
- wbcore/contrib/directory/__init__.py +0 -0
- wbcore/contrib/directory/admin/__init__.py +14 -0
- wbcore/contrib/directory/admin/contacts.py +54 -0
- wbcore/contrib/directory/admin/entries.py +230 -0
- wbcore/contrib/directory/admin/relationships.py +73 -0
- wbcore/contrib/directory/apps.py +6 -0
- wbcore/contrib/directory/configs.py +8 -0
- wbcore/contrib/directory/configurations.py +69 -0
- wbcore/contrib/directory/dynamic_preferences_registry.py +61 -0
- wbcore/contrib/directory/factories/__init__.py +34 -0
- wbcore/contrib/directory/factories/contacts.py +71 -0
- wbcore/contrib/directory/factories/entries.py +169 -0
- wbcore/contrib/directory/factories/relationships.py +77 -0
- wbcore/contrib/directory/filters/__init__.py +22 -0
- wbcore/contrib/directory/filters/contacts.py +233 -0
- wbcore/contrib/directory/filters/entries.py +247 -0
- wbcore/contrib/directory/filters/relationships.py +89 -0
- wbcore/contrib/directory/migrations/0001_initial.py +871 -0
- wbcore/contrib/directory/migrations/0002_auto_20230414_1553.py +42 -0
- wbcore/contrib/directory/migrations/0003_remove_entry_last_event.py +16 -0
- wbcore/contrib/directory/migrations/0004_entry_is_draft_entry.py +21 -0
- wbcore/contrib/directory/migrations/0005_entry_salutation.py +17 -0
- wbcore/contrib/directory/migrations/0006_employeremployeerelationship_position_name.py +23 -0
- wbcore/contrib/directory/migrations/0007_alter_bankingcontact_options.py +20 -0
- wbcore/contrib/directory/migrations/0008_bankingcontact_access.py +17 -0
- wbcore/contrib/directory/migrations/0009_remove_entry_external_identfier_and_more.py +22 -0
- wbcore/contrib/directory/migrations/__init__.py +0 -0
- wbcore/contrib/directory/models/__init__.py +27 -0
- wbcore/contrib/directory/models/contacts.py +554 -0
- wbcore/contrib/directory/models/entries.py +889 -0
- wbcore/contrib/directory/models/relationships.py +634 -0
- wbcore/contrib/directory/preferences.py +10 -0
- wbcore/contrib/directory/release_notes/1_0_0.md +13 -0
- wbcore/contrib/directory/release_notes/1_0_1.md +13 -0
- wbcore/contrib/directory/release_notes/__init__.py +0 -0
- wbcore/contrib/directory/serializers/__init__.py +63 -0
- wbcore/contrib/directory/serializers/companies.py +158 -0
- wbcore/contrib/directory/serializers/contacts.py +404 -0
- wbcore/contrib/directory/serializers/entries.py +344 -0
- wbcore/contrib/directory/serializers/entry_representations.py +35 -0
- wbcore/contrib/directory/serializers/persons.py +209 -0
- wbcore/contrib/directory/serializers/relationships.py +332 -0
- wbcore/contrib/directory/signals.py +3 -0
- wbcore/contrib/directory/tests/__init__.py +0 -0
- wbcore/contrib/directory/tests/conftest.py +60 -0
- wbcore/contrib/directory/tests/disable_signals.py +52 -0
- wbcore/contrib/directory/tests/e2e/__init__.py +7 -0
- wbcore/contrib/directory/tests/e2e/e2e_directory_utility.py +162 -0
- wbcore/contrib/directory/tests/signals.py +90 -0
- wbcore/contrib/directory/tests/test_configs.py +6 -0
- wbcore/contrib/directory/tests/test_filters.py +59 -0
- wbcore/contrib/directory/tests/test_models.py +285 -0
- wbcore/contrib/directory/tests/test_permissions.py +122 -0
- wbcore/contrib/directory/tests/test_serializers.py +201 -0
- wbcore/contrib/directory/tests/test_viewsets.py +677 -0
- wbcore/contrib/directory/tests/tests.py +130 -0
- wbcore/contrib/directory/typings.py +17 -0
- wbcore/contrib/directory/urls.py +135 -0
- wbcore/contrib/directory/viewsets/__init__.py +58 -0
- wbcore/contrib/directory/viewsets/buttons/__init__.py +7 -0
- wbcore/contrib/directory/viewsets/buttons/contacts.py +16 -0
- wbcore/contrib/directory/viewsets/buttons/entries.py +133 -0
- wbcore/contrib/directory/viewsets/buttons/relationships.py +31 -0
- wbcore/contrib/directory/viewsets/contacts.py +393 -0
- wbcore/contrib/directory/viewsets/display/__init__.py +36 -0
- wbcore/contrib/directory/viewsets/display/contacts.py +380 -0
- wbcore/contrib/directory/viewsets/display/entries.py +501 -0
- wbcore/contrib/directory/viewsets/display/relationships.py +315 -0
- wbcore/contrib/directory/viewsets/display/utils.py +33 -0
- wbcore/contrib/directory/viewsets/endpoints/__init__.py +22 -0
- wbcore/contrib/directory/viewsets/endpoints/contacts.py +54 -0
- wbcore/contrib/directory/viewsets/endpoints/entries.py +30 -0
- wbcore/contrib/directory/viewsets/endpoints/relationships.py +105 -0
- wbcore/contrib/directory/viewsets/entries.py +212 -0
- wbcore/contrib/directory/viewsets/menu/__init__.py +16 -0
- wbcore/contrib/directory/viewsets/menu/contacts.py +25 -0
- wbcore/contrib/directory/viewsets/menu/entries.py +61 -0
- wbcore/contrib/directory/viewsets/menu/relationships.py +31 -0
- wbcore/contrib/directory/viewsets/menu/utils.py +72 -0
- wbcore/contrib/directory/viewsets/mixins.py +11 -0
- wbcore/contrib/directory/viewsets/previews/__init__.py +2 -0
- wbcore/contrib/directory/viewsets/previews/contacts.py +18 -0
- wbcore/contrib/directory/viewsets/previews/entries.py +31 -0
- wbcore/contrib/directory/viewsets/relationships.py +241 -0
- wbcore/contrib/directory/viewsets/titles/__init__.py +30 -0
- wbcore/contrib/directory/viewsets/titles/contacts.py +122 -0
- wbcore/contrib/directory/viewsets/titles/entries.py +29 -0
- wbcore/contrib/directory/viewsets/titles/relationships.py +86 -0
- wbcore/contrib/directory/viewsets/titles/utils.py +46 -0
- wbcore/contrib/directory/viewsets/utils.py +101 -0
- wbcore/contrib/documents/__init__.py +0 -0
- wbcore/contrib/documents/admin.py +79 -0
- wbcore/contrib/documents/apps.py +6 -0
- wbcore/contrib/documents/factories.py +43 -0
- wbcore/contrib/documents/filters.py +82 -0
- wbcore/contrib/documents/migrations/0001_initial.py +189 -0
- wbcore/contrib/documents/migrations/0002_documentmodelrelationship_primary_and_more.py +22 -0
- wbcore/contrib/documents/migrations/0003_alter_documentmodelrelationship_unique_together_and_more.py +30 -0
- wbcore/contrib/documents/migrations/0004_auto_20240103_0958.py +44 -0
- wbcore/contrib/documents/migrations/0005_document_valid_from_document_valid_until_and_more.py +32 -0
- wbcore/contrib/documents/migrations/__init__.py +0 -0
- wbcore/contrib/documents/models/__init__.py +4 -0
- wbcore/contrib/documents/models/document_model_relationships.py +57 -0
- wbcore/contrib/documents/models/document_types.py +35 -0
- wbcore/contrib/documents/models/documents.py +309 -0
- wbcore/contrib/documents/models/mixins.py +10 -0
- wbcore/contrib/documents/models/shareable_links.py +90 -0
- wbcore/contrib/documents/release_notes/1_0_0.md +13 -0
- wbcore/contrib/documents/release_notes/__init__.py +0 -0
- wbcore/contrib/documents/serializers/__init__.py +12 -0
- wbcore/contrib/documents/serializers/document_model_relationships.py +31 -0
- wbcore/contrib/documents/serializers/document_types.py +40 -0
- wbcore/contrib/documents/serializers/documents.py +64 -0
- wbcore/contrib/documents/serializers/shareable_links.py +90 -0
- wbcore/contrib/documents/urls.py +42 -0
- wbcore/contrib/documents/viewsets/__init__.py +10 -0
- wbcore/contrib/documents/viewsets/buttons/__init__.py +3 -0
- wbcore/contrib/documents/viewsets/buttons/documents.py +53 -0
- wbcore/contrib/documents/viewsets/buttons/shareable_links.py +20 -0
- wbcore/contrib/documents/viewsets/buttons/signals.py +13 -0
- wbcore/contrib/documents/viewsets/display/__init__.py +4 -0
- wbcore/contrib/documents/viewsets/display/document_model_relationships.py +18 -0
- wbcore/contrib/documents/viewsets/display/document_types.py +23 -0
- wbcore/contrib/documents/viewsets/display/documents.py +101 -0
- wbcore/contrib/documents/viewsets/display/shareable_links.py +65 -0
- wbcore/contrib/documents/viewsets/document_model_relationships.py +25 -0
- wbcore/contrib/documents/viewsets/document_types.py +37 -0
- wbcore/contrib/documents/viewsets/documents.py +107 -0
- wbcore/contrib/documents/viewsets/endpoints/__init__.py +5 -0
- wbcore/contrib/documents/viewsets/endpoints/documents.py +19 -0
- wbcore/contrib/documents/viewsets/endpoints/documents_model_relationships.py +13 -0
- wbcore/contrib/documents/viewsets/endpoints/shareable_links.py +45 -0
- wbcore/contrib/documents/viewsets/menu/__init__.py +1 -0
- wbcore/contrib/documents/viewsets/menu/documents.py +24 -0
- wbcore/contrib/documents/viewsets/previews/__init__.py +1 -0
- wbcore/contrib/documents/viewsets/previews/documents.py +10 -0
- wbcore/contrib/documents/viewsets/shareable_links.py +109 -0
- wbcore/contrib/documents/viewsets/titles/__init__.py +3 -0
- wbcore/contrib/documents/viewsets/titles/document_types.py +13 -0
- wbcore/contrib/documents/viewsets/titles/documents.py +26 -0
- wbcore/contrib/documents/viewsets/titles/shareable_links.py +13 -0
- wbcore/contrib/dynamic_preferences/__init__.py +0 -0
- wbcore/contrib/dynamic_preferences/types.py +19 -0
- wbcore/contrib/example_app/__init__.py +0 -0
- wbcore/contrib/example_app/admin.py +117 -0
- wbcore/contrib/example_app/apps.py +6 -0
- wbcore/contrib/example_app/factories/__init__.py +8 -0
- wbcore/contrib/example_app/factories/event.py +26 -0
- wbcore/contrib/example_app/factories/league.py +15 -0
- wbcore/contrib/example_app/factories/match.py +25 -0
- wbcore/contrib/example_app/factories/person.py +32 -0
- wbcore/contrib/example_app/factories/role.py +9 -0
- wbcore/contrib/example_app/factories/sport.py +12 -0
- wbcore/contrib/example_app/factories/stadium.py +12 -0
- wbcore/contrib/example_app/factories/team.py +35 -0
- wbcore/contrib/example_app/filters/__init__.py +9 -0
- wbcore/contrib/example_app/filters/event.py +80 -0
- wbcore/contrib/example_app/filters/league.py +74 -0
- wbcore/contrib/example_app/filters/match.py +92 -0
- wbcore/contrib/example_app/filters/person.py +77 -0
- wbcore/contrib/example_app/filters/role.py +17 -0
- wbcore/contrib/example_app/filters/sport.py +26 -0
- wbcore/contrib/example_app/filters/stadium.py +30 -0
- wbcore/contrib/example_app/filters/team.py +77 -0
- wbcore/contrib/example_app/filters/teamresult.py +47 -0
- wbcore/contrib/example_app/migrations/0001_initial.py +498 -0
- wbcore/contrib/example_app/migrations/0002_sportperson_profile.py +49 -0
- wbcore/contrib/example_app/migrations/0003_change_stadium_capacity.py +31 -0
- wbcore/contrib/example_app/migrations/0004_alter_player_transfer_value.py +21 -0
- wbcore/contrib/example_app/migrations/0005_sportperson_profile_image.py +23 -0
- wbcore/contrib/example_app/migrations/0006_league_season_period_player_is_active_and_more.py +116 -0
- wbcore/contrib/example_app/migrations/0007_alter_player_options_alter_team_options_and_more.py +40 -0
- wbcore/contrib/example_app/migrations/__init__.py +0 -0
- wbcore/contrib/example_app/models.py +906 -0
- wbcore/contrib/example_app/serializers/__init__.py +31 -0
- wbcore/contrib/example_app/serializers/league.py +111 -0
- wbcore/contrib/example_app/serializers/match_event.py +304 -0
- wbcore/contrib/example_app/serializers/person_team.py +280 -0
- wbcore/contrib/example_app/serializers/role.py +16 -0
- wbcore/contrib/example_app/serializers/season.py +53 -0
- wbcore/contrib/example_app/serializers/sport.py +37 -0
- wbcore/contrib/example_app/serializers/stadium.py +58 -0
- wbcore/contrib/example_app/serializers/teamresult.py +43 -0
- wbcore/contrib/example_app/tests/__init__.py +0 -0
- wbcore/contrib/example_app/tests/conftest.py +13 -0
- wbcore/contrib/example_app/tests/e2e/__init__.py +1 -0
- wbcore/contrib/example_app/tests/e2e/e2e_example_app_utility.py +51 -0
- wbcore/contrib/example_app/tests/e2e/test_league.py +69 -0
- wbcore/contrib/example_app/tests/e2e/test_person.py +67 -0
- wbcore/contrib/example_app/tests/e2e/test_teams.py +56 -0
- wbcore/contrib/example_app/tests/signals.py +7 -0
- wbcore/contrib/example_app/tests/test_displays.py +40 -0
- wbcore/contrib/example_app/tests/test_filters.py +70 -0
- wbcore/contrib/example_app/tests/test_utils.py +25 -0
- wbcore/contrib/example_app/urls.py +79 -0
- wbcore/contrib/example_app/utils.py +20 -0
- wbcore/contrib/example_app/viewsets/__init__.py +29 -0
- wbcore/contrib/example_app/viewsets/buttons/__init__.py +2 -0
- wbcore/contrib/example_app/viewsets/buttons/person.py +18 -0
- wbcore/contrib/example_app/viewsets/buttons/team.py +23 -0
- wbcore/contrib/example_app/viewsets/displays/__init__.py +23 -0
- wbcore/contrib/example_app/viewsets/displays/event.py +186 -0
- wbcore/contrib/example_app/viewsets/displays/league.py +390 -0
- wbcore/contrib/example_app/viewsets/displays/match.py +264 -0
- wbcore/contrib/example_app/viewsets/displays/person.py +251 -0
- wbcore/contrib/example_app/viewsets/displays/role.py +16 -0
- wbcore/contrib/example_app/viewsets/displays/season.py +65 -0
- wbcore/contrib/example_app/viewsets/displays/sport.py +115 -0
- wbcore/contrib/example_app/viewsets/displays/stadium.py +149 -0
- wbcore/contrib/example_app/viewsets/displays/team.py +230 -0
- wbcore/contrib/example_app/viewsets/displays/teamresult.py +30 -0
- wbcore/contrib/example_app/viewsets/endpoints/__init__.py +12 -0
- wbcore/contrib/example_app/viewsets/endpoints/endpoints.py +79 -0
- wbcore/contrib/example_app/viewsets/event.py +287 -0
- wbcore/contrib/example_app/viewsets/league.py +72 -0
- wbcore/contrib/example_app/viewsets/match.py +119 -0
- wbcore/contrib/example_app/viewsets/menu/__init__.py +1 -0
- wbcore/contrib/example_app/viewsets/menu/menus.py +102 -0
- wbcore/contrib/example_app/viewsets/menus.py +63 -0
- wbcore/contrib/example_app/viewsets/person.py +133 -0
- wbcore/contrib/example_app/viewsets/role.py +25 -0
- wbcore/contrib/example_app/viewsets/season.py +23 -0
- wbcore/contrib/example_app/viewsets/sport.py +26 -0
- wbcore/contrib/example_app/viewsets/stadium.py +30 -0
- wbcore/contrib/example_app/viewsets/team.py +68 -0
- wbcore/contrib/example_app/viewsets/teamresult.py +106 -0
- wbcore/contrib/example_app/viewsets/titles/__init__.py +9 -0
- wbcore/contrib/example_app/viewsets/titles/event.py +41 -0
- wbcore/contrib/example_app/viewsets/titles/league.py +24 -0
- wbcore/contrib/example_app/viewsets/titles/match.py +34 -0
- wbcore/contrib/example_app/viewsets/titles/person.py +35 -0
- wbcore/contrib/example_app/viewsets/titles/role.py +13 -0
- wbcore/contrib/example_app/viewsets/titles/sport.py +13 -0
- wbcore/contrib/example_app/viewsets/titles/stadium.py +13 -0
- wbcore/contrib/example_app/viewsets/titles/team.py +24 -0
- wbcore/contrib/example_app/viewsets/titles/teamresult.py +12 -0
- wbcore/contrib/geography/__init__.py +0 -0
- wbcore/contrib/geography/admin.py +30 -0
- wbcore/contrib/geography/apps.py +5 -0
- wbcore/contrib/geography/factories.py +46 -0
- wbcore/contrib/geography/import_export/__init__.py +0 -0
- wbcore/contrib/geography/import_export/resources/__init__.py +0 -0
- wbcore/contrib/geography/import_export/resources/geography.py +10 -0
- wbcore/contrib/geography/migrations/0001_initial.py +110 -0
- wbcore/contrib/geography/migrations/__init__.py +0 -0
- wbcore/contrib/geography/models.py +147 -0
- wbcore/contrib/geography/release_notes/1_0_0.md +13 -0
- wbcore/contrib/geography/release_notes/__init__.py +0 -0
- wbcore/contrib/geography/serializers.py +32 -0
- wbcore/contrib/geography/tests/__init__.py +0 -0
- wbcore/contrib/geography/tests/conftest.py +12 -0
- wbcore/contrib/geography/tests/signals.py +7 -0
- wbcore/contrib/geography/tests/test_models.py +12 -0
- wbcore/contrib/geography/tests/test_serializers.py +7 -0
- wbcore/contrib/geography/tests/test_viewsets.py +6 -0
- wbcore/contrib/geography/tests/tests.py +12 -0
- wbcore/contrib/geography/urls.py +12 -0
- wbcore/contrib/geography/viewsets/__init__.py +1 -0
- wbcore/contrib/geography/viewsets/buttons/__init__.py +0 -0
- wbcore/contrib/geography/viewsets/display/__init__.py +1 -0
- wbcore/contrib/geography/viewsets/display/geography.py +32 -0
- wbcore/contrib/geography/viewsets/endpoints/__init__.py +0 -0
- wbcore/contrib/geography/viewsets/geography.py +57 -0
- wbcore/contrib/geography/viewsets/menu/__init__.py +1 -0
- wbcore/contrib/geography/viewsets/menu/geography.py +8 -0
- wbcore/contrib/geography/viewsets/preview/__init__.py +1 -0
- wbcore/contrib/geography/viewsets/preview/geography.py +19 -0
- wbcore/contrib/geography/viewsets/titles/__init__.py +0 -0
- wbcore/contrib/geography/viewsets/titles/geography.py +14 -0
- wbcore/contrib/gleap/__init__.py +0 -0
- wbcore/contrib/gleap/apps.py +5 -0
- wbcore/contrib/gleap/configs.py +11 -0
- wbcore/contrib/gleap/configurations.py +6 -0
- wbcore/contrib/gleap/hashes.py +13 -0
- wbcore/contrib/gleap/tests/__init__.py +0 -0
- wbcore/contrib/gleap/tests/conftest.py +1 -0
- wbcore/contrib/gleap/tests/tests.py +29 -0
- wbcore/contrib/gleap/urls.py +7 -0
- wbcore/contrib/gleap/views.py +31 -0
- wbcore/contrib/guardian/migrations/0001_initial.py +103 -0
- wbcore/contrib/guardian/migrations/__init__.py +0 -0
- wbcore/contrib/guardian/models/__init__.py +1 -0
- wbcore/contrib/guardian/models/mixins.py +138 -0
- wbcore/contrib/guardian/models/models.py +29 -0
- wbcore/contrib/guardian/tests/__init__.py +0 -0
- wbcore/contrib/guardian/tests/conftest.py +1 -0
- wbcore/contrib/guardian/tests/test_model_mixins.py +93 -0
- wbcore/contrib/guardian/tests/test_tasks.py +77 -0
- wbcore/contrib/guardian/tests/test_utils.py +196 -0
- wbcore/contrib/guardian/tests/test_viewsets.py +48 -0
- wbcore/contrib/guardian/viewsets/__init__.py +1 -0
- wbcore/contrib/guardian/viewsets/configs/__init__.py +4 -0
- wbcore/contrib/guardian/viewsets/configs/buttons.py +27 -0
- wbcore/contrib/guardian/viewsets/configs/displays.py +43 -0
- wbcore/contrib/guardian/viewsets/configs/endpoints.py +18 -0
- wbcore/contrib/guardian/viewsets/configs/titles.py +16 -0
- wbcore/contrib/guardian/viewsets/mixins.py +6 -0
- wbcore/contrib/guardian/viewsets/viewsets.py +139 -0
- wbcore/contrib/icons/__init__.py +1 -0
- wbcore/contrib/icons/apps.py +5 -0
- wbcore/contrib/icons/backends/__init__.py +5 -0
- wbcore/contrib/icons/backends/default.py +374 -0
- wbcore/contrib/icons/backends/material.py +135 -0
- wbcore/contrib/icons/icons.py +169 -0
- wbcore/contrib/icons/models.py +11 -0
- wbcore/contrib/icons/serializers.py +18 -0
- wbcore/contrib/io/__init__.py +0 -0
- wbcore/contrib/io/admin.py +150 -0
- wbcore/contrib/io/apps.py +27 -0
- wbcore/contrib/io/backends/__init__.py +5 -0
- wbcore/contrib/io/backends/abstract.py +60 -0
- wbcore/contrib/io/backends/mail.py +85 -0
- wbcore/contrib/io/backends/sftp.py +63 -0
- wbcore/contrib/io/backends/stream.py +92 -0
- wbcore/contrib/io/backends/utils.py +42 -0
- wbcore/contrib/io/configs/__init__.py +0 -0
- wbcore/contrib/io/configs/endpoints.py +12 -0
- wbcore/contrib/io/configurations/__init__.py +1 -0
- wbcore/contrib/io/configurations/base.py +7 -0
- wbcore/contrib/io/dynamic_preferences_registry.py +15 -0
- wbcore/contrib/io/enums.py +15 -0
- wbcore/contrib/io/exceptions.py +16 -0
- wbcore/contrib/io/factories.py +202 -0
- wbcore/contrib/io/imports.py +305 -0
- wbcore/contrib/io/management/__init__.py +13 -0
- wbcore/contrib/io/migrations/0001_initial_squashed.py +319 -0
- wbcore/contrib/io/migrations/0002_importsource_creator.py +26 -0
- wbcore/contrib/io/migrations/0003_auto_20240103_1000.py +46 -0
- wbcore/contrib/io/migrations/0004_alter_importsource_status_exportsource.py +134 -0
- wbcore/contrib/io/migrations/0005_exportsource_data_alter_exportsource_query_str_and_more.py +67 -0
- wbcore/contrib/io/migrations/0006_alter_exportsource_query_params.py +20 -0
- wbcore/contrib/io/migrations/0007_alter_exportsource_query_params.py +23 -0
- wbcore/contrib/io/migrations/__init__.py +0 -0
- wbcore/contrib/io/mixins.py +37 -0
- wbcore/contrib/io/models.py +1005 -0
- wbcore/contrib/io/release_notes/1_0_0.md +13 -0
- wbcore/contrib/io/release_notes/__init__.py +0 -0
- wbcore/contrib/io/resources.py +177 -0
- wbcore/contrib/io/serializers.py +136 -0
- wbcore/contrib/io/tests/__init__.py +0 -0
- wbcore/contrib/io/tests/conftest.py +42 -0
- wbcore/contrib/io/tests/test_backends.py +128 -0
- wbcore/contrib/io/tests/test_exports.py +130 -0
- wbcore/contrib/io/tests/test_imports.py +167 -0
- wbcore/contrib/io/tests/test_models.py +363 -0
- wbcore/contrib/io/tests/tests.py +18 -0
- wbcore/contrib/io/urls.py +28 -0
- wbcore/contrib/io/utils.py +44 -0
- wbcore/contrib/io/viewset_mixins.py +301 -0
- wbcore/contrib/io/viewsets.py +138 -0
- wbcore/contrib/notifications/__init__.py +0 -0
- wbcore/contrib/notifications/admin.py +61 -0
- wbcore/contrib/notifications/apps.py +38 -0
- wbcore/contrib/notifications/backends/__init__.py +0 -0
- wbcore/contrib/notifications/backends/abstract_backend.py +13 -0
- wbcore/contrib/notifications/backends/console/__init__.py +1 -0
- wbcore/contrib/notifications/backends/console/backends.py +25 -0
- wbcore/contrib/notifications/backends/firebase/__init__.py +1 -0
- wbcore/contrib/notifications/backends/firebase/backends.py +102 -0
- wbcore/contrib/notifications/configs.py +12 -0
- wbcore/contrib/notifications/configurations.py +9 -0
- wbcore/contrib/notifications/dispatch.py +71 -0
- wbcore/contrib/notifications/factories/__init__.py +0 -0
- wbcore/contrib/notifications/factories/notification_types.py +22 -0
- wbcore/contrib/notifications/factories/notifications.py +16 -0
- wbcore/contrib/notifications/factories/tokens.py +11 -0
- wbcore/contrib/notifications/migrations/0001_initial.py +116 -0
- wbcore/contrib/notifications/migrations/0002_notificationusertoken_unique_user_token_device.py +18 -0
- wbcore/contrib/notifications/migrations/0003_notificationusertoken_updated.py +17 -0
- wbcore/contrib/notifications/migrations/0004_alter_notification_body.py +17 -0
- wbcore/contrib/notifications/migrations/0005_alter_notification_endpoint.py +17 -0
- wbcore/contrib/notifications/migrations/0006_notification_created.py +25 -0
- wbcore/contrib/notifications/migrations/__init__.py +0 -0
- wbcore/contrib/notifications/models/__init__.py +3 -0
- wbcore/contrib/notifications/models/notification_types.py +112 -0
- wbcore/contrib/notifications/models/notifications.py +81 -0
- wbcore/contrib/notifications/models/tokens.py +45 -0
- wbcore/contrib/notifications/release_notes/1_0_0.md +13 -0
- wbcore/contrib/notifications/release_notes/__init__.py +0 -0
- wbcore/contrib/notifications/serializers/__init__.py +5 -0
- wbcore/contrib/notifications/serializers/notification_types.py +36 -0
- wbcore/contrib/notifications/serializers/notifications.py +33 -0
- wbcore/contrib/notifications/tasks.py +55 -0
- wbcore/contrib/notifications/tests/__init__.py +0 -0
- wbcore/contrib/notifications/tests/conftest.py +47 -0
- wbcore/contrib/notifications/tests/test_backends/__init__.py +0 -0
- wbcore/contrib/notifications/tests/test_backends/test_firebase.py +78 -0
- wbcore/contrib/notifications/tests/test_configs.py +7 -0
- wbcore/contrib/notifications/tests/test_models/__init__.py +0 -0
- wbcore/contrib/notifications/tests/test_models/test_notification_types.py +84 -0
- wbcore/contrib/notifications/tests/test_models/test_notifications.py +45 -0
- wbcore/contrib/notifications/tests/test_models/test_tokens.py +21 -0
- wbcore/contrib/notifications/tests/test_serializers/__init__.py +0 -0
- wbcore/contrib/notifications/tests/test_serializers/test_notification_types.py +53 -0
- wbcore/contrib/notifications/tests/test_serializers/test_notifications.py +23 -0
- wbcore/contrib/notifications/tests/test_tasks.py +71 -0
- wbcore/contrib/notifications/tests/test_utils.py +0 -0
- wbcore/contrib/notifications/tests/test_viewsets/__init__.py +0 -0
- wbcore/contrib/notifications/tests/test_viewsets/test_notification_types.py +121 -0
- wbcore/contrib/notifications/tests/test_viewsets/test_notifications.py +120 -0
- wbcore/contrib/notifications/urls.py +26 -0
- wbcore/contrib/notifications/utils.py +20 -0
- wbcore/contrib/notifications/views.py +62 -0
- wbcore/contrib/notifications/viewsets/__init__.py +5 -0
- wbcore/contrib/notifications/viewsets/menus.py +14 -0
- wbcore/contrib/notifications/viewsets/notification_types.py +40 -0
- wbcore/contrib/notifications/viewsets/notifications.py +57 -0
- wbcore/contrib/tags/__init__.py +0 -0
- wbcore/contrib/tags/admin.py +17 -0
- wbcore/contrib/tags/apps.py +9 -0
- wbcore/contrib/tags/factories.py +27 -0
- wbcore/contrib/tags/filters.py +42 -0
- wbcore/contrib/tags/migrations/0001_initial.py +62 -0
- wbcore/contrib/tags/migrations/__init__.py +0 -0
- wbcore/contrib/tags/models/__init__.py +2 -0
- wbcore/contrib/tags/models/mixins.py +27 -0
- wbcore/contrib/tags/models/tags.py +103 -0
- wbcore/contrib/tags/release_notes/1_0_0.md +13 -0
- wbcore/contrib/tags/release_notes/__init__.py +0 -0
- wbcore/contrib/tags/serializers.py +87 -0
- wbcore/contrib/tags/signals.py +17 -0
- wbcore/contrib/tags/tests/__init__.py +0 -0
- wbcore/contrib/tags/tests/conftest.py +7 -0
- wbcore/contrib/tags/tests/tests.py +17 -0
- wbcore/contrib/tags/urls.py +14 -0
- wbcore/contrib/tags/viewsets/__init__.py +8 -0
- wbcore/contrib/tags/viewsets/display.py +50 -0
- wbcore/contrib/tags/viewsets/menu.py +15 -0
- wbcore/contrib/tags/viewsets/viewsets.py +58 -0
- wbcore/contrib/workflow/__init__.py +1 -0
- wbcore/contrib/workflow/admin/__init__.py +15 -0
- wbcore/contrib/workflow/admin/condition.py +8 -0
- wbcore/contrib/workflow/admin/data.py +14 -0
- wbcore/contrib/workflow/admin/display.py +8 -0
- wbcore/contrib/workflow/admin/process.py +36 -0
- wbcore/contrib/workflow/admin/step.py +91 -0
- wbcore/contrib/workflow/admin/transition.py +8 -0
- wbcore/contrib/workflow/admin/workflow.py +8 -0
- wbcore/contrib/workflow/apps.py +26 -0
- wbcore/contrib/workflow/configs.py +10 -0
- wbcore/contrib/workflow/decorators.py +25 -0
- wbcore/contrib/workflow/dispatch.py +23 -0
- wbcore/contrib/workflow/factories/__init__.py +18 -0
- wbcore/contrib/workflow/factories/condition.py +15 -0
- wbcore/contrib/workflow/factories/data.py +22 -0
- wbcore/contrib/workflow/factories/display.py +27 -0
- wbcore/contrib/workflow/factories/process.py +69 -0
- wbcore/contrib/workflow/factories/step.py +155 -0
- wbcore/contrib/workflow/factories/transition.py +25 -0
- wbcore/contrib/workflow/factories/workflow.py +19 -0
- wbcore/contrib/workflow/filters/__init__.py +24 -0
- wbcore/contrib/workflow/filters/condition.py +23 -0
- wbcore/contrib/workflow/filters/data.py +24 -0
- wbcore/contrib/workflow/filters/process.py +164 -0
- wbcore/contrib/workflow/filters/step.py +226 -0
- wbcore/contrib/workflow/filters/transition.py +41 -0
- wbcore/contrib/workflow/filters/workflow.py +43 -0
- wbcore/contrib/workflow/migrations/0001_initial.py +788 -0
- wbcore/contrib/workflow/migrations/0002_alter_step_step_type.py +31 -0
- wbcore/contrib/workflow/migrations/0003_alter_condition_attribute_name_and_more.py +75 -0
- wbcore/contrib/workflow/migrations/0004_alter_userstep_assignee_method.py +27 -0
- wbcore/contrib/workflow/migrations/0005_alter_userstep_assignee_method.py +17 -0
- wbcore/contrib/workflow/migrations/__init__.py +0 -0
- wbcore/contrib/workflow/models/__init__.py +19 -0
- wbcore/contrib/workflow/models/condition.py +123 -0
- wbcore/contrib/workflow/models/data.py +238 -0
- wbcore/contrib/workflow/models/display.py +33 -0
- wbcore/contrib/workflow/models/process.py +243 -0
- wbcore/contrib/workflow/models/step.py +735 -0
- wbcore/contrib/workflow/models/transition.py +70 -0
- wbcore/contrib/workflow/models/workflow.py +307 -0
- wbcore/contrib/workflow/serializers/__init__.py +37 -0
- wbcore/contrib/workflow/serializers/condition.py +64 -0
- wbcore/contrib/workflow/serializers/data.py +135 -0
- wbcore/contrib/workflow/serializers/display.py +25 -0
- wbcore/contrib/workflow/serializers/process.py +182 -0
- wbcore/contrib/workflow/serializers/signals.py +25 -0
- wbcore/contrib/workflow/serializers/step.py +364 -0
- wbcore/contrib/workflow/serializers/transition.py +80 -0
- wbcore/contrib/workflow/serializers/workflow.py +124 -0
- wbcore/contrib/workflow/sites.py +43 -0
- wbcore/contrib/workflow/tests/__init__.py +0 -0
- wbcore/contrib/workflow/tests/conftest.py +57 -0
- wbcore/contrib/workflow/tests/test_configs.py +6 -0
- wbcore/contrib/workflow/tests/test_dispatch.py +88 -0
- wbcore/contrib/workflow/tests/test_displays.py +119 -0
- wbcore/contrib/workflow/tests/test_filters.py +86 -0
- wbcore/contrib/workflow/tests/test_serializers.py +177 -0
- wbcore/contrib/workflow/tests/test_viewsets.py +358 -0
- wbcore/contrib/workflow/tests/test_workflow_assignees.py +225 -0
- wbcore/contrib/workflow/tests/tests.py +24 -0
- wbcore/contrib/workflow/urls.py +66 -0
- wbcore/contrib/workflow/utils.py +13 -0
- wbcore/contrib/workflow/viewsets/__init__.py +17 -0
- wbcore/contrib/workflow/viewsets/buttons/__init__.py +1 -0
- wbcore/contrib/workflow/viewsets/buttons/step.py +67 -0
- wbcore/contrib/workflow/viewsets/condition.py +32 -0
- wbcore/contrib/workflow/viewsets/data.py +33 -0
- wbcore/contrib/workflow/viewsets/display/__init__.py +15 -0
- wbcore/contrib/workflow/viewsets/display/condition.py +50 -0
- wbcore/contrib/workflow/viewsets/display/data.py +50 -0
- wbcore/contrib/workflow/viewsets/display/process.py +185 -0
- wbcore/contrib/workflow/viewsets/display/step.py +453 -0
- wbcore/contrib/workflow/viewsets/display/transition.py +75 -0
- wbcore/contrib/workflow/viewsets/display/workflow.py +167 -0
- wbcore/contrib/workflow/viewsets/endpoints/__init__.py +5 -0
- wbcore/contrib/workflow/viewsets/endpoints/condition.py +9 -0
- wbcore/contrib/workflow/viewsets/endpoints/data.py +9 -0
- wbcore/contrib/workflow/viewsets/endpoints/process.py +11 -0
- wbcore/contrib/workflow/viewsets/endpoints/step.py +24 -0
- wbcore/contrib/workflow/viewsets/endpoints/transition.py +18 -0
- wbcore/contrib/workflow/viewsets/menu/__init__.py +15 -0
- wbcore/contrib/workflow/viewsets/menu/condition.py +18 -0
- wbcore/contrib/workflow/viewsets/menu/data.py +18 -0
- wbcore/contrib/workflow/viewsets/menu/process.py +18 -0
- wbcore/contrib/workflow/viewsets/menu/step.py +123 -0
- wbcore/contrib/workflow/viewsets/menu/transition.py +18 -0
- wbcore/contrib/workflow/viewsets/menu/workflow.py +18 -0
- wbcore/contrib/workflow/viewsets/process.py +171 -0
- wbcore/contrib/workflow/viewsets/step.py +229 -0
- wbcore/contrib/workflow/viewsets/titles/__init__.py +16 -0
- wbcore/contrib/workflow/viewsets/titles/condition.py +13 -0
- wbcore/contrib/workflow/viewsets/titles/data.py +13 -0
- wbcore/contrib/workflow/viewsets/titles/process.py +26 -0
- wbcore/contrib/workflow/viewsets/titles/step.py +101 -0
- wbcore/contrib/workflow/viewsets/titles/transition.py +13 -0
- wbcore/contrib/workflow/viewsets/titles/workflow.py +13 -0
- wbcore/contrib/workflow/viewsets/transition.py +57 -0
- wbcore/contrib/workflow/viewsets/workflow.py +36 -0
- wbcore/contrib/workflow/workflows/__init__.py +1 -0
- wbcore/contrib/workflow/workflows/assignees.py +82 -0
- wbcore/crontab/__init__.py +0 -0
- wbcore/crontab/serializers.py +23 -0
- wbcore/crontab/viewsets.py +9 -0
- wbcore/dispatch.py +55 -0
- wbcore/docs/__init__.py +25 -0
- wbcore/docs/orderable.md +29 -0
- wbcore/docs/reparent.md +13 -0
- wbcore/dynamic_preferences_registry.py +29 -0
- wbcore/enums.py +98 -0
- wbcore/filters/__init__.py +21 -0
- wbcore/filters/backends.py +19 -0
- wbcore/filters/defaults.py +69 -0
- wbcore/filters/fields/__init__.py +15 -0
- wbcore/filters/fields/booleans.py +6 -0
- wbcore/filters/fields/choices.py +61 -0
- wbcore/filters/fields/content_type.py +33 -0
- wbcore/filters/fields/datetime.py +91 -0
- wbcore/filters/fields/models.py +113 -0
- wbcore/filters/fields/multiple_lookups.py +19 -0
- wbcore/filters/fields/numbers.py +46 -0
- wbcore/filters/fields/text.py +6 -0
- wbcore/filters/filterset.py +217 -0
- wbcore/filters/lookups.py +41 -0
- wbcore/filters/mixins.py +112 -0
- wbcore/filters/utils.py +21 -0
- wbcore/forms.py +125 -0
- wbcore/frontend.py +23 -0
- wbcore/frontend_user_configuration.py +96 -0
- wbcore/fsm/__init__.py +0 -0
- wbcore/fsm/markdown_extensions.py +31 -0
- wbcore/fsm/mixins.py +114 -0
- wbcore/management/__init__.py +88 -0
- wbcore/management/commands/__init__.py +0 -0
- wbcore/management/commands/bootstrap.py +18 -0
- wbcore/management/commands/clean_obsolete_object.py +21 -0
- wbcore/management/commands/handle_release_notes.py +53 -0
- wbcore/markdown/__init__.py +1 -0
- wbcore/markdown/admin.py +9 -0
- wbcore/markdown/dynamic_preferences_registry.py +16 -0
- wbcore/markdown/models.py +38 -0
- wbcore/markdown/template.py +38 -0
- wbcore/markdown/utils.py +36 -0
- wbcore/markdown/views.py +67 -0
- wbcore/menus/__init__.py +2 -0
- wbcore/menus/menus.py +96 -0
- wbcore/menus/registry.py +28 -0
- wbcore/menus/views.py +41 -0
- wbcore/messages.py +51 -0
- wbcore/metadata/__init__.py +0 -0
- wbcore/metadata/configs/__init__.py +0 -0
- wbcore/metadata/configs/base.py +86 -0
- wbcore/metadata/configs/buttons/__init__.py +4 -0
- wbcore/metadata/configs/buttons/bases.py +91 -0
- wbcore/metadata/configs/buttons/buttons.py +142 -0
- wbcore/metadata/configs/buttons/enums.py +25 -0
- wbcore/metadata/configs/buttons/metadata.py +8 -0
- wbcore/metadata/configs/buttons/view_config.py +176 -0
- wbcore/metadata/configs/display/__init__.py +4 -0
- wbcore/metadata/configs/display/configs.py +15 -0
- wbcore/metadata/configs/display/display.py +234 -0
- wbcore/metadata/configs/display/formatting.py +50 -0
- wbcore/metadata/configs/display/instance_display/__init__.py +15 -0
- wbcore/metadata/configs/display/instance_display/display.py +37 -0
- wbcore/metadata/configs/display/instance_display/enums.py +7 -0
- wbcore/metadata/configs/display/instance_display/layouts/__init__.py +3 -0
- wbcore/metadata/configs/display/instance_display/layouts/inlines.py +58 -0
- wbcore/metadata/configs/display/instance_display/layouts/layouts.py +77 -0
- wbcore/metadata/configs/display/instance_display/layouts/sections.py +43 -0
- wbcore/metadata/configs/display/instance_display/operators.py +22 -0
- wbcore/metadata/configs/display/instance_display/pages.py +40 -0
- wbcore/metadata/configs/display/instance_display/shortcuts.py +70 -0
- wbcore/metadata/configs/display/instance_display/signals.py +3 -0
- wbcore/metadata/configs/display/instance_display/styles.py +42 -0
- wbcore/metadata/configs/display/instance_display/utils.py +74 -0
- wbcore/metadata/configs/display/list_display.py +230 -0
- wbcore/metadata/configs/display/models.py +20 -0
- wbcore/metadata/configs/display/view_config.py +82 -0
- wbcore/metadata/configs/display/views.py +48 -0
- wbcore/metadata/configs/display/windows.py +28 -0
- wbcore/metadata/configs/documentations.py +11 -0
- wbcore/metadata/configs/endpoints.py +176 -0
- wbcore/metadata/configs/fields.py +17 -0
- wbcore/metadata/configs/filter_fields.py +42 -0
- wbcore/metadata/configs/identifiers.py +25 -0
- wbcore/metadata/configs/ordering_fields.py +24 -0
- wbcore/metadata/configs/paginations.py +11 -0
- wbcore/metadata/configs/preview.py +41 -0
- wbcore/metadata/configs/primary_keys.py +9 -0
- wbcore/metadata/configs/search_fields.py +9 -0
- wbcore/metadata/configs/titles.py +48 -0
- wbcore/metadata/configs/window_types.py +13 -0
- wbcore/metadata/exceptions.py +0 -0
- wbcore/metadata/metadata.py +33 -0
- wbcore/metadata/mixins.py +105 -0
- wbcore/metadata/tests/__init__.py +0 -0
- wbcore/metadata/tests/test_buttons.py +179 -0
- wbcore/metadata/utils.py +4 -0
- wbcore/migrations/0001_initial_squashed_squashed_0010_preset_appliedpreset.py +398 -0
- wbcore/migrations/0011_genericmodel.py +22 -0
- wbcore/migrations/0012_delete_notification.py +15 -0
- wbcore/migrations/0013_delete_colorgradient.py +14 -0
- wbcore/migrations/0014_biguserobjectpermission_system.py +44 -0
- wbcore/migrations/__init__.py +0 -0
- wbcore/models/__init__.py +6 -0
- wbcore/models/base.py +182 -0
- wbcore/models/fields.py +29 -0
- wbcore/models/orderable.py +6 -0
- wbcore/pagination.py +65 -0
- wbcore/pandas/__init__.py +0 -0
- wbcore/pandas/fields.py +136 -0
- wbcore/pandas/filters.py +113 -0
- wbcore/pandas/filterset.py +26 -0
- wbcore/pandas/metadata.py +14 -0
- wbcore/pandas/utils.py +129 -0
- wbcore/pandas/views.py +157 -0
- wbcore/permissions/__init__.py +0 -0
- wbcore/permissions/backend.py +35 -0
- wbcore/permissions/mixins.py +72 -0
- wbcore/permissions/permissions.py +50 -0
- wbcore/permissions/registry.py +32 -0
- wbcore/permissions/shortcuts.py +37 -0
- wbcore/permissions/utils.py +26 -0
- wbcore/release_notes/__init__.py +0 -0
- wbcore/release_notes/admin.py +30 -0
- wbcore/release_notes/buttons.py +25 -0
- wbcore/release_notes/display.py +57 -0
- wbcore/release_notes/filters.py +35 -0
- wbcore/release_notes/models.py +65 -0
- wbcore/release_notes/serializers.py +19 -0
- wbcore/release_notes/utils.py +14 -0
- wbcore/release_notes/viewsets.py +45 -0
- wbcore/reversion/__init__.py +0 -0
- wbcore/reversion/filters.py +38 -0
- wbcore/reversion/serializers.py +80 -0
- wbcore/reversion/viewsets/__init__.py +6 -0
- wbcore/reversion/viewsets/buttons.py +94 -0
- wbcore/reversion/viewsets/displays.py +44 -0
- wbcore/reversion/viewsets/endpoints.py +29 -0
- wbcore/reversion/viewsets/titles.py +17 -0
- wbcore/reversion/viewsets/viewsets.py +111 -0
- wbcore/routers.py +63 -0
- wbcore/search/__init__.py +62 -0
- wbcore/serializers/__init__.py +66 -0
- wbcore/serializers/fields/__init__.py +58 -0
- wbcore/serializers/fields/boolean.py +51 -0
- wbcore/serializers/fields/choice.py +36 -0
- wbcore/serializers/fields/datetime.py +143 -0
- wbcore/serializers/fields/fields.py +190 -0
- wbcore/serializers/fields/file.py +20 -0
- wbcore/serializers/fields/fsm.py +20 -0
- wbcore/serializers/fields/json.py +56 -0
- wbcore/serializers/fields/list.py +105 -0
- wbcore/serializers/fields/mixins.py +175 -0
- wbcore/serializers/fields/number.py +103 -0
- wbcore/serializers/fields/other.py +42 -0
- wbcore/serializers/fields/primary_key.py +22 -0
- wbcore/serializers/fields/related.py +152 -0
- wbcore/serializers/fields/text.py +136 -0
- wbcore/serializers/fields/types.py +41 -0
- wbcore/serializers/mixins.py +24 -0
- wbcore/serializers/serializers.py +415 -0
- wbcore/serializers/utils.py +142 -0
- wbcore/shares/__init__.py +1 -0
- wbcore/shares/config.py +63 -0
- wbcore/shares/decorator.py +13 -0
- wbcore/shares/signals.py +3 -0
- wbcore/shares/sites.py +28 -0
- wbcore/shares/views.py +24 -0
- wbcore/signals/__init__.py +6 -0
- wbcore/signals/filters.py +3 -0
- wbcore/signals/instance_buttons.py +5 -0
- wbcore/signals/merge.py +4 -0
- wbcore/signals/models.py +8 -0
- wbcore/signals/permissions.py +3 -0
- wbcore/signals/serializers.py +5 -0
- wbcore/tasks.py +83 -0
- wbcore/templates/reversion/__init__.py +0 -0
- wbcore/templates/reversion/compare_detail.html +19 -0
- wbcore/test/__init__.py +30 -0
- wbcore/test/mixins.py +709 -0
- wbcore/test/signals.py +6 -0
- wbcore/test/tests.py +131 -0
- wbcore/test/utils.py +227 -0
- wbcore/tests/__init__.py +0 -0
- wbcore/tests/conftest.py +55 -0
- wbcore/tests/e2e/__init__.py +0 -0
- wbcore/tests/e2e/test_e2e.py +24 -0
- wbcore/tests/models.py +6 -0
- wbcore/tests/test_cache/__init__.py +0 -0
- wbcore/tests/test_cache/test_decorators.py +30 -0
- wbcore/tests/test_cache/test_mixins.py +29 -0
- wbcore/tests/test_cache/test_registry.py +57 -0
- wbcore/tests/test_configs.py +65 -0
- wbcore/tests/test_enums.py +54 -0
- wbcore/tests/test_fields/__init__.py +0 -0
- wbcore/tests/test_fields/test_boolean_fields.py +48 -0
- wbcore/tests/test_fields/test_choice_fields.py +48 -0
- wbcore/tests/test_fields/test_datetime_fields.py +151 -0
- wbcore/tests/test_fields/test_fields.py +23 -0
- wbcore/tests/test_fields/test_file_fields.py +52 -0
- wbcore/tests/test_fields/test_json_fields.py +28 -0
- wbcore/tests/test_fields/test_list_fields.py +27 -0
- wbcore/tests/test_fields/test_mixins.py +111 -0
- wbcore/tests/test_fields/test_number_fields.py +190 -0
- wbcore/tests/test_fields/test_other_fields.py +61 -0
- wbcore/tests/test_fields/test_primary_key_fields.py +52 -0
- wbcore/tests/test_fields/test_related.py +80 -0
- wbcore/tests/test_fields/test_text_fields.py +117 -0
- wbcore/tests/test_filters/__init__.py +0 -0
- wbcore/tests/test_filters/test_mixins.py +108 -0
- wbcore/tests/test_filters/test_pandas.py +114 -0
- wbcore/tests/test_list_display.py +31 -0
- wbcore/tests/test_models/__init__.py +0 -0
- wbcore/tests/test_models/test_fields.py +25 -0
- wbcore/tests/test_models/test_mixins.py +31 -0
- wbcore/tests/test_new_display/__init__.py +0 -0
- wbcore/tests/test_new_display/test_inlines.py +13 -0
- wbcore/tests/test_new_display/test_layouts.py +15 -0
- wbcore/tests/test_new_display/test_operators.py +15 -0
- wbcore/tests/test_new_display/test_pages.py +8 -0
- wbcore/tests/test_new_display/test_sections.py +0 -0
- wbcore/tests/test_new_display/test_shortcuts.py +38 -0
- wbcore/tests/test_new_display/test_utils.py +48 -0
- wbcore/tests/test_pagination.py +31 -0
- wbcore/tests/test_serializers/__init__.py +0 -0
- wbcore/tests/test_serializers/test_fields.py +140 -0
- wbcore/tests/test_serializers/test_mixins.py +53 -0
- wbcore/tests/test_serializers/test_related.py +77 -0
- wbcore/tests/test_something.py +39 -0
- wbcore/tests/test_utils/__init__.py +0 -0
- wbcore/tests/test_utils/test_date.py +49 -0
- wbcore/tests/test_utils/test_date_builder.py +99 -0
- wbcore/tests/test_utils/test_primary.py +79 -0
- wbcore/tests/test_utils/test_signals.py +38 -0
- wbcore/tests/test_viewsets.py +20 -0
- wbcore/urls.py +114 -0
- wbcore/utils/__init__.py +13 -0
- wbcore/utils/cache.py +8 -0
- wbcore/utils/date.py +220 -0
- wbcore/utils/date_builder/__init__.py +18 -0
- wbcore/utils/date_builder/components.py +42 -0
- wbcore/utils/date_builder/offsets.py +27 -0
- wbcore/utils/deprecations.py +11 -0
- wbcore/utils/enum.py +23 -0
- wbcore/utils/figures.py +290 -0
- wbcore/utils/html.py +8 -0
- wbcore/utils/importlib.py +13 -0
- wbcore/utils/itertools.py +40 -0
- wbcore/utils/models.py +275 -0
- wbcore/utils/numbers.py +69 -0
- wbcore/utils/prettytable.py +35 -0
- wbcore/utils/print.py +29 -0
- wbcore/utils/renderers.py +13 -0
- wbcore/utils/rrules.py +37 -0
- wbcore/utils/serializers.py +8 -0
- wbcore/utils/settings.py +5 -0
- wbcore/utils/signals.py +36 -0
- wbcore/utils/string_loader.py +42 -0
- wbcore/utils/strings.py +77 -0
- wbcore/utils/task.py +6 -0
- wbcore/utils/urls.py +70 -0
- wbcore/utils/views.py +201 -0
- wbcore/views.py +26 -0
- wbcore/viewsets/__init__.py +10 -0
- wbcore/viewsets/encoders.py +18 -0
- wbcore/viewsets/generics.py +5 -0
- wbcore/viewsets/mixins.py +290 -0
- wbcore/viewsets/utils.py +26 -0
- wbcore/viewsets/viewsets.py +142 -0
- wbcore-2.2.1.dist-info/METADATA +62 -0
- wbcore-2.2.1.dist-info/RECORD +1035 -0
- wbcore-2.2.1.dist-info/WHEEL +5 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from contextlib import suppress
|
|
3
|
+
from typing import Any, ClassVar, Type
|
|
4
|
+
|
|
5
|
+
from django.db.models.fields import NOT_PROVIDED
|
|
6
|
+
from rest_framework.fields import empty
|
|
7
|
+
from rest_framework.serializers import Field
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def decorator(position: str, value: str, decorator_type: str = "icon") -> dict:
|
|
13
|
+
assert position in ("left", "right"), "Decorator Position can only be right or left"
|
|
14
|
+
assert decorator_type in ("icon", "text"), "Decorator Type can only be icon or text"
|
|
15
|
+
return {"position": position, "value": value, "type": decorator_type}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class WBCoreSerializerFieldMixin:
|
|
19
|
+
"""
|
|
20
|
+
A mixin that takes care of adding all the necessary magic to each implementation
|
|
21
|
+
of the serializer fields
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
*args,
|
|
27
|
+
decorators=None,
|
|
28
|
+
depends_on=None,
|
|
29
|
+
math=None,
|
|
30
|
+
extra=None,
|
|
31
|
+
read_only=False,
|
|
32
|
+
copyable=None,
|
|
33
|
+
related_key=None,
|
|
34
|
+
**kwargs,
|
|
35
|
+
):
|
|
36
|
+
if not decorators:
|
|
37
|
+
decorators = list()
|
|
38
|
+
if not depends_on:
|
|
39
|
+
depends_on = list()
|
|
40
|
+
self.extra = extra
|
|
41
|
+
self.decorators = decorators
|
|
42
|
+
self.depends_on = depends_on
|
|
43
|
+
self.math = math
|
|
44
|
+
self.copyable = copyable
|
|
45
|
+
# To satisfy DRF assertion, we detect if the readonly given is a callable and in that case, we consider the default read only attribute to be true
|
|
46
|
+
self._callable_read_only = None
|
|
47
|
+
if callable(read_only):
|
|
48
|
+
self._callable_read_only = read_only
|
|
49
|
+
read_only = True
|
|
50
|
+
self.related_key = related_key
|
|
51
|
+
super().__init__(*args, read_only=read_only, **kwargs)
|
|
52
|
+
|
|
53
|
+
def _evaluate_read_only(self):
|
|
54
|
+
if self._callable_read_only:
|
|
55
|
+
# if view is present, we use it as parameter to the callable, otherwise we assume read_only is True
|
|
56
|
+
if view := self.view:
|
|
57
|
+
self.read_only = self._callable_read_only(view)
|
|
58
|
+
else:
|
|
59
|
+
self.read_only = True
|
|
60
|
+
|
|
61
|
+
def bind(self, field_name, parent):
|
|
62
|
+
super().bind(field_name, parent)
|
|
63
|
+
# After binding to the parent happens, we evaluate the callable readonly if given
|
|
64
|
+
self._evaluate_read_only()
|
|
65
|
+
|
|
66
|
+
def get_related_key(self) -> str:
|
|
67
|
+
return self.related_key or self.source
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def view(self):
|
|
71
|
+
# Helper property to return the stored instantiated view in the context
|
|
72
|
+
return self.context.get("view", getattr(self.context.get("request"), "parser_context", {}).get("view"))
|
|
73
|
+
|
|
74
|
+
def set_attr(self, attr, value):
|
|
75
|
+
setattr(self, attr, value)
|
|
76
|
+
self._kwargs[attr] = value
|
|
77
|
+
|
|
78
|
+
def append_depend_on(self, depend_on):
|
|
79
|
+
existing_fields = [elem["field"] for elem in self.depends_on]
|
|
80
|
+
if depend_on["field"] not in existing_fields:
|
|
81
|
+
self.depends_on.append(depend_on)
|
|
82
|
+
self._kwargs["depends_on"] = self.depends_on
|
|
83
|
+
|
|
84
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
85
|
+
if meta := getattr(self.parent, "Meta", None):
|
|
86
|
+
if field_name in getattr(meta, "required_fields", []):
|
|
87
|
+
self.required = True
|
|
88
|
+
|
|
89
|
+
representation = {
|
|
90
|
+
"key": field_name,
|
|
91
|
+
"label": getattr(self, "label", None),
|
|
92
|
+
"type": getattr(self, "field_type", "undefined"),
|
|
93
|
+
"required": getattr(self, "required", True),
|
|
94
|
+
"read_only": getattr(self, "read_only", False),
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
default = getattr(self, "default", None)
|
|
98
|
+
if default is None or default == empty or default == NOT_PROVIDED:
|
|
99
|
+
try:
|
|
100
|
+
default = self.parent.Meta.model._meta._forward_fields_map[field_name].default
|
|
101
|
+
except Exception: # TODO Add some explicit exception handling
|
|
102
|
+
pass
|
|
103
|
+
|
|
104
|
+
if default is not None and default != empty and default != NOT_PROVIDED:
|
|
105
|
+
if callable(default):
|
|
106
|
+
if getattr(default, "requires_context", False):
|
|
107
|
+
default = default(self)
|
|
108
|
+
else:
|
|
109
|
+
default = default()
|
|
110
|
+
if default is not None:
|
|
111
|
+
representation["default"] = self.to_representation(default)
|
|
112
|
+
|
|
113
|
+
representation["decorators"] = getattr(self, "decorators", [])
|
|
114
|
+
representation["depends_on"] = getattr(self, "depends_on", [])
|
|
115
|
+
|
|
116
|
+
for _attr in ["help_text", "extra"]:
|
|
117
|
+
attr = getattr(self, _attr, None)
|
|
118
|
+
if attr:
|
|
119
|
+
representation[_attr] = attr
|
|
120
|
+
|
|
121
|
+
if self.math:
|
|
122
|
+
representation["math"] = self.math
|
|
123
|
+
if self.copyable:
|
|
124
|
+
representation["copyable"] = self.copyable
|
|
125
|
+
return field_name, representation
|
|
126
|
+
|
|
127
|
+
def validate_empty_values(self, data):
|
|
128
|
+
if isinstance(data, str) and data == "null":
|
|
129
|
+
data = None
|
|
130
|
+
return super().validate_empty_values(data)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class RangeMixin(WBCoreSerializerFieldMixin, Field):
|
|
134
|
+
"""
|
|
135
|
+
This mixin represents a range in the form of:
|
|
136
|
+
(value1,value2)
|
|
137
|
+
|
|
138
|
+
When using this mixin, you must supply the internal_field (usually the postgres wrapper) that converts the range tuple to some datastructure.
|
|
139
|
+
"""
|
|
140
|
+
|
|
141
|
+
default_error_messages = {
|
|
142
|
+
"lower_gt_upper": "The upper bound must be greater than the lower bound.",
|
|
143
|
+
}
|
|
144
|
+
internal_field: ClassVar[Type]
|
|
145
|
+
|
|
146
|
+
def _transform_range(self, lower, upper, inward: bool | None = None):
|
|
147
|
+
return lower, upper
|
|
148
|
+
|
|
149
|
+
def to_internal_value(self, data) -> Any:
|
|
150
|
+
# If formdata is used, we need to separate the string into the range
|
|
151
|
+
if isinstance(data, str) and "," in data:
|
|
152
|
+
data = data.split(",")
|
|
153
|
+
lower = upper = None
|
|
154
|
+
if isinstance(data, list):
|
|
155
|
+
if len(data) > 0 and data[0]:
|
|
156
|
+
lower = super().to_internal_value(data[0])
|
|
157
|
+
if len(data) > 1 and data[1]:
|
|
158
|
+
upper = super().to_internal_value(data[1])
|
|
159
|
+
lower, upper = self._transform_range(lower, upper, inward=True)
|
|
160
|
+
if lower and upper and lower >= upper:
|
|
161
|
+
self.fail("lower_gt_upper")
|
|
162
|
+
return self.internal_field(lower, upper)
|
|
163
|
+
|
|
164
|
+
def to_representation(self, instance):
|
|
165
|
+
lower, upper = self._transform_range(instance.lower, instance.upper, inward=False)
|
|
166
|
+
with suppress(Exception):
|
|
167
|
+
lower = super().to_representation(lower)
|
|
168
|
+
with suppress(Exception):
|
|
169
|
+
upper = super().to_representation(upper)
|
|
170
|
+
return lower, upper
|
|
171
|
+
|
|
172
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
173
|
+
key, representation = super().get_representation(request, field_name)
|
|
174
|
+
representation["range"] = True
|
|
175
|
+
return key, representation
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from psycopg.types.range import NumericRange
|
|
2
|
+
from rest_framework import serializers
|
|
3
|
+
|
|
4
|
+
from .mixins import RangeMixin, WBCoreSerializerFieldMixin, decorator
|
|
5
|
+
from .types import DisplayMode, WBCoreType
|
|
6
|
+
|
|
7
|
+
percent_decorator = decorator(position="right", value="%", decorator_type="text")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class NumberFieldMixin:
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
*args,
|
|
14
|
+
percent=False,
|
|
15
|
+
display_mode=DisplayMode.DECIMAL,
|
|
16
|
+
precision=2,
|
|
17
|
+
delimiter=",",
|
|
18
|
+
decimal_mark=".",
|
|
19
|
+
signed: bool = True,
|
|
20
|
+
**kwargs,
|
|
21
|
+
):
|
|
22
|
+
super().__init__(*args, **kwargs)
|
|
23
|
+
self.percent = percent
|
|
24
|
+
self.delimiter = delimiter
|
|
25
|
+
self.decimal_mark = decimal_mark
|
|
26
|
+
if self.delimiter == self.decimal_mark:
|
|
27
|
+
raise ValueError("Decimal mark and delimiter need to be different character")
|
|
28
|
+
self.display_mode = display_mode
|
|
29
|
+
self.precision = kwargs.get("decimal_places", precision)
|
|
30
|
+
self.max_digits = kwargs.get("max_digits", 34)
|
|
31
|
+
self.signed = signed
|
|
32
|
+
|
|
33
|
+
def set_precision(self, precision):
|
|
34
|
+
self.precision = precision
|
|
35
|
+
self._kwargs["precision"] = self.precision
|
|
36
|
+
|
|
37
|
+
def set_percent(self, percent):
|
|
38
|
+
self.percent = percent
|
|
39
|
+
self._kwargs["percent"] = self.percent
|
|
40
|
+
|
|
41
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
42
|
+
key, representation = super().get_representation(request, field_name)
|
|
43
|
+
representation["display_mode"] = self.display_mode.value
|
|
44
|
+
representation["precision"] = self.precision
|
|
45
|
+
representation["max_digits"] = self.max_digits
|
|
46
|
+
representation["delimiter"] = self.delimiter
|
|
47
|
+
representation["decimal_mark"] = self.decimal_mark
|
|
48
|
+
representation["signed"] = self.signed
|
|
49
|
+
|
|
50
|
+
if self.percent: # TODO: Discuss with Christoph if this is necessary like this
|
|
51
|
+
representation["type"] = WBCoreType.PERCENT.value
|
|
52
|
+
representation["precision"] = self.precision - 2
|
|
53
|
+
return key, representation
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class IntegerField(NumberFieldMixin, WBCoreSerializerFieldMixin, serializers.IntegerField):
|
|
57
|
+
field_type = WBCoreType.NUMBER.value
|
|
58
|
+
|
|
59
|
+
def __init__(self, *args, **kwargs):
|
|
60
|
+
super().__init__(*args, **kwargs)
|
|
61
|
+
self.precision = 0
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class YearField(IntegerField):
|
|
65
|
+
def __init__(self, *args, **kwargs):
|
|
66
|
+
super().__init__(*args, **kwargs)
|
|
67
|
+
self.delimiter = ""
|
|
68
|
+
self.decimal_mark = "."
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class DecimalField(NumberFieldMixin, WBCoreSerializerFieldMixin, serializers.DecimalField):
|
|
72
|
+
field_type = WBCoreType.NUMBER.value
|
|
73
|
+
|
|
74
|
+
# TODO: If this is used, then the validation for max_digits and decimal_fields is not done
|
|
75
|
+
# def validate_precision(self, value):
|
|
76
|
+
# return value
|
|
77
|
+
|
|
78
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
79
|
+
field_name, representation = super().get_representation(request, field_name)
|
|
80
|
+
|
|
81
|
+
if meta := getattr(self.parent, "Meta", None):
|
|
82
|
+
odp = getattr(meta, "override_decimal_places", None)
|
|
83
|
+
percent_fields = getattr(meta, "percent_fields", [])
|
|
84
|
+
if odp is not None and field_name not in percent_fields:
|
|
85
|
+
representation["precision"] = odp
|
|
86
|
+
|
|
87
|
+
return field_name, representation
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class FloatField(NumberFieldMixin, WBCoreSerializerFieldMixin, serializers.FloatField):
|
|
91
|
+
field_type = WBCoreType.NUMBER.value
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class DecimalRangeField(RangeMixin, WBCoreSerializerFieldMixin, serializers.DecimalField):
|
|
95
|
+
field_type = WBCoreType.NUMBER.value
|
|
96
|
+
internal_field = NumericRange
|
|
97
|
+
|
|
98
|
+
def __init__(self, max_digits=None, decimal_places=None, **kwargs):
|
|
99
|
+
if not max_digits:
|
|
100
|
+
max_digits = 3
|
|
101
|
+
if not decimal_places:
|
|
102
|
+
decimal_places = 2
|
|
103
|
+
super().__init__(max_digits, decimal_places, **kwargs)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# TODO: Most likely to be removed
|
|
2
|
+
from rest_framework import serializers
|
|
3
|
+
|
|
4
|
+
from .mixins import WBCoreSerializerFieldMixin
|
|
5
|
+
from .number import IntegerField
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class StarRatingField(IntegerField):
|
|
9
|
+
field_type = "starrating"
|
|
10
|
+
|
|
11
|
+
def __init__(self, *args, **kwargs):
|
|
12
|
+
super().__init__(*args, **kwargs)
|
|
13
|
+
self.delimiter = ""
|
|
14
|
+
self.decimal_mark = ""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class EmojiRatingField(IntegerField):
|
|
18
|
+
field_type = "emojirating"
|
|
19
|
+
|
|
20
|
+
def __init__(self, *args, **kwargs):
|
|
21
|
+
super().__init__(*args, **kwargs)
|
|
22
|
+
self.delimiter = ""
|
|
23
|
+
self.decimal_mark = ""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class RangeSelectField(WBCoreSerializerFieldMixin, serializers.FloatField):
|
|
27
|
+
field_type = "rangeselect"
|
|
28
|
+
|
|
29
|
+
def __init__(self, *args, start: float = 0.0, end: float = 1.0, step_size: float = 0.25, **kwargs):
|
|
30
|
+
self.color = kwargs.pop("color", "rgb(133, 144, 162)")
|
|
31
|
+
self.start = start
|
|
32
|
+
self.end = end
|
|
33
|
+
self.step_size = step_size
|
|
34
|
+
super().__init__(*args, **kwargs)
|
|
35
|
+
|
|
36
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
37
|
+
key, representation = super().get_representation(request, field_name)
|
|
38
|
+
representation["color"] = self.color
|
|
39
|
+
representation["start"] = self.start
|
|
40
|
+
representation["end"] = self.end
|
|
41
|
+
representation["step_size"] = self.step_size
|
|
42
|
+
return key, representation
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from rest_framework import serializers
|
|
2
|
+
|
|
3
|
+
from .mixins import WBCoreSerializerFieldMixin
|
|
4
|
+
from .types import WBCoreType
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class PrimaryKeyField(WBCoreSerializerFieldMixin, serializers.IntegerField):
|
|
8
|
+
field_type = WBCoreType.PRIMARY_KEY.value
|
|
9
|
+
|
|
10
|
+
def __init__(self, *args, **kwargs):
|
|
11
|
+
kwargs["read_only"] = True
|
|
12
|
+
kwargs["required"] = False
|
|
13
|
+
super().__init__(*args, **kwargs)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PrimaryKeyCharField(WBCoreSerializerFieldMixin, serializers.CharField):
|
|
17
|
+
field_type = WBCoreType.PRIMARY_KEY.value
|
|
18
|
+
|
|
19
|
+
def __init__(self, *args, **kwargs):
|
|
20
|
+
kwargs["read_only"] = True
|
|
21
|
+
kwargs["required"] = False
|
|
22
|
+
super().__init__(*args, **kwargs)
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
from contextlib import suppress
|
|
2
|
+
|
|
3
|
+
from django.core.exceptions import FieldDoesNotExist
|
|
4
|
+
from rest_framework import serializers
|
|
5
|
+
from rest_framework.fields import empty
|
|
6
|
+
from rest_framework.relations import ManyRelatedField, PKOnlyObject
|
|
7
|
+
from rest_framework.request import Request
|
|
8
|
+
|
|
9
|
+
from .list import ListFieldMixin
|
|
10
|
+
from .mixins import WBCoreSerializerFieldMixin
|
|
11
|
+
from .types import WBCoreType
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class WBCoreManyRelatedField(ListFieldMixin, WBCoreSerializerFieldMixin, ManyRelatedField):
|
|
15
|
+
def __init__(self, *args, **kwargs):
|
|
16
|
+
required = kwargs.get("required", True)
|
|
17
|
+
if not required:
|
|
18
|
+
kwargs["allow_null"] = True
|
|
19
|
+
super().__init__(*args, **kwargs)
|
|
20
|
+
|
|
21
|
+
def bind(self, field_name, parent):
|
|
22
|
+
super().bind(field_name, parent)
|
|
23
|
+
# The `many=True` parameter on the related field returns this class,
|
|
24
|
+
# where `children_relation` is directly bound to it. However, the context
|
|
25
|
+
# processor does not yet have access to the request, so the `view` property
|
|
26
|
+
# is currently `None`. To handle this, we need to explicitly re-evaluate
|
|
27
|
+
# the `read_only` property for the `children_relation` when the binding
|
|
28
|
+
# occurs from the List serializer to this instance.
|
|
29
|
+
self.child_relation.context["view"] = self.view
|
|
30
|
+
self.child_relation._evaluate_read_only()
|
|
31
|
+
if not self.child_relation.read_only and hasattr(self.child_relation, "_queryset"):
|
|
32
|
+
setattr(self.child_relation, "queryset", self.child_relation._queryset)
|
|
33
|
+
|
|
34
|
+
def get_representation(self, request: Request, field_name: str) -> tuple[str, dict]:
|
|
35
|
+
key, representation = self.child_relation.get_representation(request, field_name)
|
|
36
|
+
representation["multiple"] = True
|
|
37
|
+
if not representation.get("label", None) and self.label:
|
|
38
|
+
representation["label"] = self.label
|
|
39
|
+
return key, representation
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class PrimaryKeyRelatedField(WBCoreSerializerFieldMixin, serializers.PrimaryKeyRelatedField):
|
|
43
|
+
MANY_RELATION_KWARGS = (
|
|
44
|
+
"read_only",
|
|
45
|
+
"write_only",
|
|
46
|
+
"required",
|
|
47
|
+
"default",
|
|
48
|
+
"initial",
|
|
49
|
+
"source",
|
|
50
|
+
"label",
|
|
51
|
+
"help_text",
|
|
52
|
+
"style",
|
|
53
|
+
"error_messages",
|
|
54
|
+
"allow_empty",
|
|
55
|
+
"html_cutoff",
|
|
56
|
+
"html_cutoff_text",
|
|
57
|
+
"allow_null",
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def __init__(self, *args, queryset=None, read_only=False, **kwargs):
|
|
61
|
+
self.field_type = kwargs.pop("field_type", WBCoreType.SELECT.value)
|
|
62
|
+
if callable(read_only) and queryset is not None:
|
|
63
|
+
self._queryset = queryset # we unset any given queryset to be compliant with the RelatedField assertion
|
|
64
|
+
queryset = None
|
|
65
|
+
super().__init__(*args, queryset=queryset, read_only=read_only, **kwargs)
|
|
66
|
+
|
|
67
|
+
def __new__(cls, *args, **kwargs):
|
|
68
|
+
kwargs["style"] = {"base_template": "input.html"}
|
|
69
|
+
return super().__new__(cls, *args, **kwargs)
|
|
70
|
+
|
|
71
|
+
def bind(self, field_name, parent):
|
|
72
|
+
super().bind(field_name, parent)
|
|
73
|
+
# In case we had to unset the queryset attribute because read_only was a callable, we reinstate it here.
|
|
74
|
+
if not self.read_only and hasattr(self, "_queryset"):
|
|
75
|
+
setattr(self, "queryset", self._queryset)
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def many_init(cls, *args, **kwargs):
|
|
79
|
+
list_kwargs = {"child_relation": cls(*args, **kwargs)}
|
|
80
|
+
for key in kwargs:
|
|
81
|
+
if key in cls.MANY_RELATION_KWARGS:
|
|
82
|
+
list_kwargs[key] = kwargs[key]
|
|
83
|
+
return WBCoreManyRelatedField(**list_kwargs)
|
|
84
|
+
|
|
85
|
+
def run_validation(self, data=empty):
|
|
86
|
+
if (data is empty) and (view := self.parent.context.get("view", None)):
|
|
87
|
+
parent_model_id = view.kwargs.get(f"{self.field_name}_id")
|
|
88
|
+
if parent_model_id:
|
|
89
|
+
data = parent_model_id
|
|
90
|
+
|
|
91
|
+
return super().run_validation(data)
|
|
92
|
+
|
|
93
|
+
def get_representation(self, request: Request, field_name: str) -> tuple[str, dict]:
|
|
94
|
+
key, representation = super().get_representation(request, field_name)
|
|
95
|
+
if default := representation.get("default", None):
|
|
96
|
+
if isinstance(default, list):
|
|
97
|
+
representation["default"] = [getattr(d, "id", d) for d in default]
|
|
98
|
+
elif id := getattr(default, "id", None):
|
|
99
|
+
representation["default"] = id
|
|
100
|
+
return key, representation
|
|
101
|
+
|
|
102
|
+
def to_representation(self, value):
|
|
103
|
+
# In case we annotate the representation, we need to ensure that the value is an object
|
|
104
|
+
if isinstance(value, (list, tuple, set)):
|
|
105
|
+
return [self.to_representation(d) for d in value]
|
|
106
|
+
try:
|
|
107
|
+
if isinstance(value, str):
|
|
108
|
+
try:
|
|
109
|
+
value = int(value)
|
|
110
|
+
except ValueError:
|
|
111
|
+
value = None
|
|
112
|
+
if isinstance(value, int):
|
|
113
|
+
value = PKOnlyObject(value)
|
|
114
|
+
return super().to_representation(value)
|
|
115
|
+
except Exception:
|
|
116
|
+
pass
|
|
117
|
+
return None
|
|
118
|
+
|
|
119
|
+
def get_queryset(self):
|
|
120
|
+
"""
|
|
121
|
+
Allow queryset to be callable
|
|
122
|
+
"""
|
|
123
|
+
if callable(self.queryset):
|
|
124
|
+
self.queryset = self.queryset()
|
|
125
|
+
qs = super().get_queryset()
|
|
126
|
+
|
|
127
|
+
# if limite_choices_to is defined on the model field, we use it to restrict the related queryset
|
|
128
|
+
with suppress(AttributeError, FieldDoesNotExist):
|
|
129
|
+
if limit_choices_to := getattr(
|
|
130
|
+
self.parent.Meta.model._meta.get_field(self.field_name), "_limit_choices_to", None
|
|
131
|
+
):
|
|
132
|
+
if isinstance(limit_choices_to, dict):
|
|
133
|
+
qs = qs.filter(**limit_choices_to)
|
|
134
|
+
else:
|
|
135
|
+
qs = qs.filter(limit_choices_to)
|
|
136
|
+
return qs
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class ListSerializer(WBCoreSerializerFieldMixin, serializers.ListSerializer):
|
|
140
|
+
"""
|
|
141
|
+
A Wrapper around the normal DRF ListSerializer which also return the child representation
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
def get_representation(self, request: Request, field_name: str) -> tuple[str, dict]:
|
|
145
|
+
_, representation = self.child.get_representation(request, field_name)
|
|
146
|
+
representation["multiple"] = True
|
|
147
|
+
related_key = self.get_related_key()
|
|
148
|
+
representation["related_key"] = related_key
|
|
149
|
+
|
|
150
|
+
# TODO: improve and don't monkeypatch
|
|
151
|
+
rv = related_key if "." not in related_key else related_key.replace(".", "__")
|
|
152
|
+
return rv, representation
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
from django.core.exceptions import ValidationError
|
|
4
|
+
from django.utils.translation import gettext as _
|
|
5
|
+
from rest_framework import serializers
|
|
6
|
+
from rest_framework.reverse import reverse
|
|
7
|
+
|
|
8
|
+
from .mixins import WBCoreSerializerFieldMixin
|
|
9
|
+
from .types import ReturnContentType, WBCoreType
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CharField(WBCoreSerializerFieldMixin, serializers.CharField):
|
|
13
|
+
field_type = WBCoreType.TEXT.value
|
|
14
|
+
|
|
15
|
+
def __init__(self, *args, **kwargs):
|
|
16
|
+
self.secure = kwargs.pop("secure", False)
|
|
17
|
+
self.placeholder = kwargs.pop("placeholder", None)
|
|
18
|
+
super().__init__(*args, allow_null=kwargs.pop("allow_null", True), **kwargs)
|
|
19
|
+
|
|
20
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
21
|
+
key, representation = super().get_representation(request, field_name)
|
|
22
|
+
|
|
23
|
+
if self.placeholder:
|
|
24
|
+
representation["placeholder"] = self.placeholder
|
|
25
|
+
|
|
26
|
+
# Add secure attribute if required
|
|
27
|
+
if self.secure:
|
|
28
|
+
representation["secure"] = True
|
|
29
|
+
|
|
30
|
+
return key, representation
|
|
31
|
+
|
|
32
|
+
def validate_empty_values(self, data):
|
|
33
|
+
if (self.allow_null or self.allow_blank) and data is None:
|
|
34
|
+
data = ""
|
|
35
|
+
return super().validate_empty_values(data)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class TelephoneField(CharField):
|
|
39
|
+
field_type = WBCoreType.TELEPHONE.value
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class StringRelatedField(WBCoreSerializerFieldMixin, serializers.StringRelatedField):
|
|
43
|
+
field_type = WBCoreType.TEXT.value
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class TextAreaField(CharField):
|
|
47
|
+
field_type = WBCoreType.TEXTAREA.value
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class CodeField(CharField):
|
|
51
|
+
field_type = WBCoreType.TEXTAREA.value
|
|
52
|
+
|
|
53
|
+
def to_internal_value(self, data):
|
|
54
|
+
try:
|
|
55
|
+
compile(data, "", "exec")
|
|
56
|
+
except Exception as e:
|
|
57
|
+
raise ValidationError(_("Compiling script failed with the exception: {}".format(e)))
|
|
58
|
+
return super().to_internal_value(data)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class TextField(CharField):
|
|
62
|
+
field_type = WBCoreType.TEXTEDITOR.value
|
|
63
|
+
texteditor_content_type = ReturnContentType.HTML.value
|
|
64
|
+
|
|
65
|
+
def __init__(self, *args, **kwargs):
|
|
66
|
+
"""The constructor method.
|
|
67
|
+
This pops the 'plugin_configs' dict from the kwargs and calls the
|
|
68
|
+
parents init method.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
plugin_configs : dict, optional
|
|
73
|
+
A dictionary that contains a dictionary for each plugin of the
|
|
74
|
+
texteditor. The configuration for each plugin must be available
|
|
75
|
+
under a unique key.
|
|
76
|
+
"""
|
|
77
|
+
self.plugin_configs = kwargs.pop("plugin_configs", None)
|
|
78
|
+
super().__init__(*args, **kwargs)
|
|
79
|
+
|
|
80
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
81
|
+
key, representation = super().get_representation(request, field_name)
|
|
82
|
+
representation["content_type"] = self.texteditor_content_type
|
|
83
|
+
if not self.plugin_configs:
|
|
84
|
+
representation["plugin_configs"] = {}
|
|
85
|
+
else:
|
|
86
|
+
representation["plugin_configs"] = self.plugin_configs(request)
|
|
87
|
+
return key, representation
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class MarkdownTextField(TextField):
|
|
91
|
+
field_type = WBCoreType.MARKDOWNEDITOR.value
|
|
92
|
+
texteditor_content_type = ReturnContentType.MARKDOWN.value
|
|
93
|
+
|
|
94
|
+
def __init__(self, metadata_field=None, *args, **kwargs):
|
|
95
|
+
self.metadata_field = metadata_field
|
|
96
|
+
super().__init__(*args, **kwargs)
|
|
97
|
+
|
|
98
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
99
|
+
key, representation = super().get_representation(request, field_name)
|
|
100
|
+
representation["image_upload"] = reverse("wbcore:markdown-asset-upload", request=request)
|
|
101
|
+
representation["tags"] = reverse("wbcore:markdown-tags", request=request)
|
|
102
|
+
if self.metadata_field:
|
|
103
|
+
representation["metadata_field"] = self.metadata_field
|
|
104
|
+
return key, representation
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class ColorPickerField(CharField):
|
|
108
|
+
field_type = WBCoreType.COLOR.value
|
|
109
|
+
|
|
110
|
+
def __init__(self, *args, **kwargs):
|
|
111
|
+
kwargs["copyable"] = True
|
|
112
|
+
super().__init__(*args, **kwargs)
|
|
113
|
+
|
|
114
|
+
def to_internal_value(self, data):
|
|
115
|
+
if not re.search(r"^#(?:[0-9a-fA-F]{3}){1,2}$", data):
|
|
116
|
+
raise ValidationError(_("Please provide a valid hexadecimal color."))
|
|
117
|
+
return super().to_internal_value(data)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class URLField(CharField):
|
|
121
|
+
field_type = WBCoreType.URL.value
|
|
122
|
+
|
|
123
|
+
def __init__(self, open_internally: bool = False, *args, **kwargs):
|
|
124
|
+
"""
|
|
125
|
+
Args:
|
|
126
|
+
open_internally: If true, notify the frontend to open the url as an internal widget
|
|
127
|
+
"""
|
|
128
|
+
self.open_internally = open_internally
|
|
129
|
+
super().__init__(*args, **kwargs)
|
|
130
|
+
|
|
131
|
+
def get_representation(self, request, field_name) -> tuple[str, dict]:
|
|
132
|
+
key, representation = super().get_representation(request, field_name)
|
|
133
|
+
representation["open_internally"] = (
|
|
134
|
+
self.open_internally(self.view) if callable(self.open_internally) else self.open_internally
|
|
135
|
+
)
|
|
136
|
+
return key, representation
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class WBCoreType(Enum):
|
|
5
|
+
TEXT = "text"
|
|
6
|
+
TELEPHONE = "tel"
|
|
7
|
+
TEXTEDITOR = "texteditor"
|
|
8
|
+
TEMPLATED_TEXTEDITOR = "templatedtexteditor"
|
|
9
|
+
TEXTAREA = "textarea"
|
|
10
|
+
MARKDOWNEDITOR = "markdowneditor"
|
|
11
|
+
NUMBER = "number"
|
|
12
|
+
DATETIME = "datetime"
|
|
13
|
+
DATE = "date"
|
|
14
|
+
DATERANGE = "daterange"
|
|
15
|
+
DURATION = "duration"
|
|
16
|
+
TIME = "time"
|
|
17
|
+
PRIMARY_KEY = "primary_key"
|
|
18
|
+
BOOLEAN = "boolean"
|
|
19
|
+
SELECT = "select"
|
|
20
|
+
IMAGE = "image"
|
|
21
|
+
FILE = "file"
|
|
22
|
+
LIST = "list"
|
|
23
|
+
PERCENT = "percent"
|
|
24
|
+
JSON = "json"
|
|
25
|
+
JSONTABLE = "table"
|
|
26
|
+
ICON = "iconselect"
|
|
27
|
+
COLOR = "color"
|
|
28
|
+
URL = "url"
|
|
29
|
+
SPARKLINE = "sparkline"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ReturnContentType(Enum):
|
|
33
|
+
HTML = "html"
|
|
34
|
+
JSON = "json"
|
|
35
|
+
MARKDOWN = "markdown"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class DisplayMode(Enum):
|
|
39
|
+
DECIMAL = "decimal"
|
|
40
|
+
SHORTENED = "shortened"
|
|
41
|
+
SCIENTIFIC = "scientific"
|