Skip to content

Project: show search settings in separate form#12843

Open
stsewd wants to merge 6 commits intomainfrom
show-search-settings
Open

Project: show search settings in separate form#12843
stsewd wants to merge 6 commits intomainfrom
show-search-settings

Conversation

@stsewd
Copy link
Member

@stsewd stsewd commented Mar 12, 2026

I didn't include the option to disable search indexing here since its from a separate model and it's only shown when we have disabled search indexing, but isn't that complex to integrate if we wanted 11f16a1.

Closes #11533

Requires readthedocs/ext-theme#709

@stsewd
Copy link
Member Author

stsewd commented Mar 12, 2026

@copilot write a test for this view

Copy link
Contributor

Copilot AI commented Mar 12, 2026

@stsewd I've opened a new pull request, #12844, to work on those changes. Once the pull request is ready, I'll request review from you.

stsewd and others added 3 commits March 12, 2026 19:21
…ew bugs (#12844)

`ProjectSearchSettingsUpdate` had no tests and contained two bugs that
were caught while writing them.

## Bugs fixed

- **Missing `PrivateViewMixin`**: The view didn't inherit from
`PrivateViewMixin`, so unauthenticated users were never redirected to
login — they'd hit `get_object_or_404` directly and get a 404 instead of
a redirect.
- **`get_success_url()` crash on POST**: Used `self.object.slug`, but
Django's `ModelFormMixin.form_valid()` reassigns `self.object =
form.save()` — and since the form saves an `AddonsConfig` instance (not
`Project`), this raised `AttributeError: 'AddonsConfig' object has no
attribute 'slug'`. Fixed to use `self.get_project().slug`.

## Tests added

`TestProjectSearchSettingsUpdate` in
`readthedocs/projects/tests/test_views.py`:

- `test_get_returns_200_for_admin`
- `test_get_returns_404_for_non_admin`
- `test_get_redirects_unauthenticated_user`
- `test_post_updates_search_settings` — verifies
`AddonsConfig.search_enabled` and `search_show_subprojects_filter` are
persisted and redirects to the form URL
- `test_post_updates_partial_search_settings` — verifies partial field
updates work correctly

## Template

Added a placeholder `projects/search_settings_form.html` following the
same pattern as `pull_requests_form.html` (real implementation lives in
ext-theme).

<!-- START COPILOT CODING AGENT TIPS -->
---

📍 Connect Copilot coding agent with [Jira](https://gh.io/cca-jira-docs),
[Azure Boards](https://gh.io/cca-azure-boards-docs) or
[Linear](https://gh.io/cca-linear-docs) to delegate work to Copilot in
one click without leaving your project management tool.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stsewd <4975310+stsewd@users.noreply.github.com>
@stsewd stsewd marked this pull request as ready for review March 16, 2026 21:02
@stsewd stsewd requested a review from a team as a code owner March 16, 2026 21:02
@stsewd stsewd requested a review from humitos March 16, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard & Backend: Search configuration

2 participants