Skip to content

Add RemoteRepositoryInline to ProjectAdmin to surface connected remote repository#12813

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-remote-repository-inline
Draft

Add RemoteRepositoryInline to ProjectAdmin to surface connected remote repository#12813
Copilot wants to merge 3 commits intomainfrom
copilot/add-remote-repository-inline

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

ProjectAdmin had no inline visibility into the RemoteRepository connected to a project via the remote_repository FK. Admins had no way to inspect the remote repository details without navigating away from the project page.

Changes

  • readthedocs/projects/admin.py: Added RemoteRepositoryInline (read-only StackedInline) to ProjectAdmin

    • Displays full_name, clone_url, html_url, private, vcs, vcs_provider, default_branch as read-only fields
    • show_change_link = True for direct navigation to the remote repository admin page
    • No add/change/delete permissions — view-only via ReadOnlyInlineMixin
    • Collapsed by default (classes = ["collapse"])
  • readthedocs/oauth/admin.py: No changes (reverted to original state)

Since Project.remote_repository is a FK from ProjectRemoteRepository (not the reverse), Django's standard inline mechanism cannot be used directly in ProjectAdmin. The implementation overrides check() to skip the FK system check and overrides get_formset() to use a modelformset_factory-based formset whose queryset is built from the project's remote_repository_id:

class RemoteRepositoryInline(ReadOnlyInlineMixin, admin.StackedInline):
    model = RemoteRepository
    classes = ["collapse"]
    fields = ("full_name", "clone_url", "html_url", "private", "vcs", "vcs_provider", "default_branch")
    readonly_fields = fields

    @classmethod
    def check(cls, parent_model):
        # No FK from RemoteRepository to Project; handled manually in get_formset()
        return []

    def get_formset(self, request, obj=None, **kwargs):
        qs = RemoteRepository.objects.filter(pk=obj.remote_repository_id) if obj and obj.remote_repository_id else RemoteRepository.objects.none()
        ...

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: ericholscher <25510+ericholscher@users.noreply.github.com>
Copilot AI changed the title [WIP] Add remote repository inline to Project admin Add ProjectInline to RemoteRepositoryAdmin to surface connected projects Feb 25, 2026
Copilot AI requested a review from ericholscher February 25, 2026 03:39
@ericholscher
Copy link
Member

@copilot code review[agent] Do the inline the other way

Co-authored-by: ericholscher <25510+ericholscher@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 26, 2026

@copilot code review[agent] Do the inline the other way

Done in f82441a. The inline is now RemoteRepositoryInline inside ProjectAdmin (in projects/admin.py), showing the connected RemoteRepository when viewing a Project.

Since the FK goes Project → RemoteRepository (not the reverse), a standard Django inline isn't possible in this direction. The implementation uses a modelformset_factory-based formset that builds its queryset from obj.remote_repository_id, and overrides check() to skip the FK system check. All fields are read-only via ReadOnlyInlineMixin.

Copilot AI changed the title Add ProjectInline to RemoteRepositoryAdmin to surface connected projects Add RemoteRepositoryInline to ProjectAdmin to surface connected remote repository Feb 26, 2026
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.

2 participants