Skip to content

πŸ§‘β€πŸ’»(admin) add selftest views mechanism #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qbey
Copy link
Member

@qbey qbey commented Mar 20, 2025

Purpose

This allows to define views available in /admin/selftest/ like an email sender testing view for instance.

I'm still not sure about this...

Proposal

  • provide base selftest views
  • provider an index view for selftests
  • add an example selftest : email
  • add tests

@qbey qbey self-assigned this Mar 20, 2025
@qbey qbey added the backend label Mar 20, 2025
This allows to define views available in /admin/selftest/ like an email
sender testing view for instance.

I'm still not sure about this...
@qbey qbey force-pushed the qbey/add-selftest-views branch from b8f09f9 to de7adb2 Compare March 20, 2025 14:15
@qbey qbey changed the title πŸ§‘β€πŸ’»(admin) provider selftest views πŸ§‘β€πŸ’»(admin) add selftest views mechanism Mar 20, 2025
@qbey qbey requested a review from Copilot March 28, 2025 09:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a mechanism to register and serve selftest views in the Django admin, allowing the addition of testing views (e.g. an email sender test view) under the /admin/selftest/ URL.

  • Introduces a base selftest view (BaseSelftestAdminPageView) and a dedicated index view (IndexSelftestAdminPageView).
  • Adds an example email selftest view (EmailSelftestAdminPageView) with GET and POST handlers for sending test emails.
  • Implements a registry (ViewRegistry) to automatically discover and register selftest views and extends the admin site URLs accordingly.

Reviewed Changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated no comments.

File Description
src/backend/admin/views.py Adds base, index, and email selftest views with GET and POST handling.
src/backend/admin/sites.py Extends the admin site URLs to include registered selftest views.
src/backend/admin/registry.py Implements a registry to auto-discover and register custom selftest views.
Files not reviewed (3)
  • src/backend/admin/templates/selftest/base.html: Language not supported
  • src/backend/admin/templates/selftest/email.html: Language not supported
  • src/backend/admin/templates/selftest/index.html: Language not supported
Comments suppressed due to low confidence (2)

src/backend/admin/registry.py:42

  • [nitpick] Consider handling edge cases where the subclass name matches exactly 'SelftestAdminPageView', which may result in an empty name. A more robust naming strategy would prevent potential routing issues.
base_name = name.replace("SelftestAdminPageView", "").lower()

src/backend/admin/views.py:67

  • The POST method in EmailSelftestAdminPageView does not have test coverage. Please add tests to ensure the email sending behavior and error handling work as expected.
def post(self, request, *args, **kwargs):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant