Ajustes wagtail hooks menu collection#865
Ajustes wagtail hooks menu collection#865robertatakenaka wants to merge 7 commits intoscieloorg:mainfrom
Conversation
…nos modelos de team
…oreAdminModelForm
There was a problem hiding this comment.
Pull request overview
This PR performs a structural refactoring of ViewSets and Forms to standardize the Wagtail ecosystem. The main goal is to centralize common logic for handling creator/updater tracking in models that inherit from CommonControlField by using CoreAdminModelForm and CommonControlFieldCreateView instead of custom form and view implementations.
Changes:
- Standardized team app to use generic core classes (CoreAdminModelForm and CommonControlFieldCreateView) instead of custom forms and views
- Moved ClassicWebsiteConfigurationViewSet import from collection to migration app
- Simplified permission filtering logic in issue app by removing redundant collection-based filtering
- Removed obsolete bucket_app_subdir field references from files_storage admin configuration
- Updated template URL to use Wagtail snippet route pattern
- Removed empty URL registration hook from collection app
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| team/wagtail_hooks.py | Added CoreAdminModelForm and CommonControlFieldCreateView to all ViewSets for standardized form handling |
| team/views.py | Removed custom CollectionTeamMemberCreateView in favor of generic core view |
| team/models.py | Removed custom form import, added base_form_class to models using CoreAdminModelForm |
| team/forms.py | Removed entire file containing custom CollectionTeamMemberModelForm |
| migration/wagtail_hooks.py | Removed ClassicWebsiteConfigurationViewSet from MigrationViewSetGroup items (moved to Collection menu) |
| collection/wagtail_hooks.py | Changed to import ClassicWebsiteConfigurationViewSet from migration app, removed redundant ViewSet definition and empty URL hook |
| issue/wagtail_hooks.py | Simplified permission filtering by removing redundant collection-based checks (journal_list_ids already includes journals from collections) |
| files_storage/wagtail_hooks.py | Removed references to obsolete bucket_app_subdir field from list_display and search_fields |
| core/templates/wagtailadmin/summary_items/collection_summary_item.html | Updated URL from modeladmin pattern to Wagtail snippet pattern |
| from config.menu import get_menu_order | ||
| from files_storage.wagtail_hooks import MinioConfigurationViewSet | ||
| from migration.models import ClassicWebsiteConfiguration | ||
| from migration.wagtail_hooks import ClassicWebsiteConfigurationViewSet |
There was a problem hiding this comment.
The ClassicWebsiteConfigurationViewSet is now imported from migration.wagtail_hooks, but the version in that file is missing the permission filtering logic that was present in the removed code here (lines 77-106 of the old version). The removed get_queryset method filtered records based on user collection membership using get_user_membership_ids. Without this filtering, non-superuser users will be able to see all ClassicWebsiteConfiguration records instead of only those associated with their collections. This is a security concern as it could expose configuration data that users should not have access to.
The ClassicWebsiteConfigurationViewSet in migration/wagtail_hooks.py needs to have the same get_queryset permission filtering logic added.
O que esse PR faz?
Este PR realiza uma refatoração estrutural nos ViewSets e Forms do projeto, focando na padronização do ecossistema Wagtail. As principais mudanças incluem:
ClassicWebsiteConfigurationViewSetpara o local correto e remoção de redundâncias de filtragem de permissões nos appsissueecollection.team: Eliminação de formulários (forms.py) e views (views.py) customizados em favor do uso de classes genéricas docore(CoreAdminModelFormeCommonControlFieldCreateView).bucket_app_subdirno app de storage por obsolescência.Onde a revisão poderia começar?
A revisão deve começar por
team/models.pyeteam/wagtail_hooks.py, onde a maior parte da lógica customizada foi substituída pela herança das classes docore. Em seguida, verifiqueissue/wagtail_hooks.pypara validar a simplificação da lógica de filtragem.Como este poderia ser testado manualmente?
CollectionTeamMemberou umaCompany. Verifique se o formulário carrega corretamente e se os campos de controle (criador/editor) são preenchidos automaticamente ao salvar.Algum cenário de contexto que queira dar?
O projeto vinha acumulando diversas implementações manuais de formulários que apenas replicavam a lógica de salvar o
request.usernos camposcreatoreupdated_by. Ao adotar oCoreAdminModelForm, reduzimos o volume de código em aproximadamente 50 linhas e centralizamos a manutenção dessas regras de auditoria no appcore.Screenshots
N/A (As mudanças são estruturais e de backend, não alterando o layout visual, exceto pela correção de links quebrados).
Quais são tickets relevantes?
Referências
core.models.CommonControlField.