MT#55988 buildinfo: add clickable jenkins_url field

Change-Id: I3a94aa1c93b03818c40b2cc6800b1507621f1687
mprokop/trixie
Victor Seva 3 years ago
parent 2af7fa19b3
commit 2ebe8a7f2d

@ -1,4 +1,4 @@
# Copyright (C) 2022 The Sipwise Team - http://sipwise.com # Copyright (C) 2022-2023 The Sipwise Team - http://sipwise.com
# #
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free # under the terms of the GNU General Public License as published by the Free
@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
from django.contrib import admin from django.contrib import admin
from django.utils.html import format_html
from import_export import resources from import_export import resources
from import_export.admin import ImportExportModelAdmin from import_export.admin import ImportExportModelAdmin
@ -33,3 +34,7 @@ class BuildInfoAdmin(ImportExportModelAdmin):
"param_distribution", "param_distribution",
"builton", "builton",
) )
readonly_fields = ("jenkins_url",)
def jenkins_url(self, obj):
return format_html("<a href='{url}'>{url}</a>", url=obj.jenkins_url)

@ -16,6 +16,7 @@ from typing import Any
from django.db import models from django.db import models
from .conf import settings
from .utils import datetime from .utils import datetime
from .utils import get_datetime from .utils import get_datetime
@ -45,6 +46,11 @@ class BuildInfo(models.Model):
param_ppa = models.CharField(max_length=50, null=True, blank=True) param_ppa = models.CharField(max_length=50, null=True, blank=True)
objects = BuildInfoManager() objects = BuildInfoManager()
@property
def jenkins_url(self):
base_url = settings.JENKINS_URL
return f"{base_url}/jobs/{self.projectname}/{self.buildnumber}/"
def __str__(self): def __str__(self):
return ( return (
f"{self.jobname}:{self.buildnumber}:" f"{self.jobname}:{self.buildnumber}:"

Loading…
Cancel
Save