Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lando/main/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.forms import CheckboxSelectMultiple, MultipleChoiceField
from django.forms import Field as FormField
from django.http import HttpRequest
from django.urls import reverse
from django.utils.translation import gettext_lazy

from lando.main.models import (
Expand Down Expand Up @@ -112,9 +113,14 @@ class JobAdmin(admin.ModelAdmin):
)
search_fields = ("requester_email", "landed_commit_id")

def view_on_site(self, instance: LandingJob) -> str:
url = reverse("jobs-page", kwargs={"job_id": instance.id})
return url


class LandingJobAdmin(JobAdmin):
model = LandingJob

list_display = (
"id",
"revisions",
Expand Down Expand Up @@ -251,6 +257,12 @@ class RevisionAdmin(admin.ModelAdmin):
)
search_fields = ("revision_id",)

def view_on_site(self, instance: Revision) -> str | None:
if not instance.revision_id:
return None
url = reverse("revisions-page", kwargs={"revision_id": instance.revision_id})
return url

Comment on lines +260 to +265
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might as well implement this for a pull request based revision?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do we have a dedicated Lando page for those yet?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, I had a look, and we could link it to the pull-request view via the pull_number on the Revision, but we also need a repo_name, which I think is only associated to the revision via a LandingJob, so I don't think we have enough information to link.

Can you think of another way to get it?

Copy link
Copy Markdown
Member Author

@shtrom shtrom Feb 27, 2026

Choose a reason for hiding this comment

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

It may actually make more sense to complete the model to have a pull_repo[_name], because a pull_number in isolation is a bit meaningless. We may also want to add a is_pull_request?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, I'm gonna land this as is, but we should follow up with adding support for PRs. Added a note here: https://bugzilla.mozilla.org/show_bug.cgi?id=2012875#c4

def revision(self, instance: Revision) -> str:
"""Return a Phabricator-like revision identifier."""
idstr = f"{instance.id}"
Expand Down