1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: wuiadminbuildblacklist.py 93115 2022-01-01 11:31:46Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Manager WUI - Build Blacklist.
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2012-2022 Oracle Corporation
|
---|
11 |
|
---|
12 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | available from http://www.virtualbox.org. This file is free software;
|
---|
14 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | General Public License (GPL) as published by the Free Software
|
---|
16 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 |
|
---|
20 | The contents of this file may alternatively be used under the terms
|
---|
21 | of the Common Development and Distribution License Version 1.0
|
---|
22 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
23 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
24 | CDDL are applicable instead of those of the GPL.
|
---|
25 |
|
---|
26 | You may elect to license modified versions of this file under the
|
---|
27 | terms and conditions of either the GPL or the CDDL or both.
|
---|
28 | """
|
---|
29 | __version__ = "$Revision: 93115 $"
|
---|
30 |
|
---|
31 |
|
---|
32 | # Validation Kit imports.
|
---|
33 | from testmanager.webui.wuibase import WuiException
|
---|
34 | from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink
|
---|
35 | from testmanager.core.buildblacklist import BuildBlacklistData
|
---|
36 | from testmanager.core.failurereason import FailureReasonLogic
|
---|
37 | from testmanager.core.db import TMDatabaseConnection
|
---|
38 | from testmanager.core import coreconsts
|
---|
39 |
|
---|
40 |
|
---|
41 | class WuiAdminBuildBlacklist(WuiFormContentBase):
|
---|
42 | """
|
---|
43 | WUI Build Black List Form.
|
---|
44 | """
|
---|
45 |
|
---|
46 | def __init__(self, oData, sMode, oDisp):
|
---|
47 | """
|
---|
48 | Prepare & initialize parent
|
---|
49 | """
|
---|
50 |
|
---|
51 | if sMode == WuiFormContentBase.ksMode_Add:
|
---|
52 | sTitle = 'Add Build Blacklist Entry'
|
---|
53 | elif sMode == WuiFormContentBase.ksMode_Edit:
|
---|
54 | sTitle = 'Edit Build Blacklist Entry'
|
---|
55 | else:
|
---|
56 | assert sMode == WuiFormContentBase.ksMode_Show;
|
---|
57 | sTitle = 'Build Black';
|
---|
58 | WuiFormContentBase.__init__(self, oData, sMode, 'BuildBlacklist', oDisp, sTitle);
|
---|
59 |
|
---|
60 | #
|
---|
61 | # Additional data.
|
---|
62 | #
|
---|
63 | self.asTypes = coreconsts.g_kasBuildTypesAll
|
---|
64 | self.asOsArches = coreconsts.g_kasOsDotCpusAll
|
---|
65 |
|
---|
66 | def _populateForm(self, oForm, oData):
|
---|
67 | """
|
---|
68 | Construct an HTML form
|
---|
69 | """
|
---|
70 |
|
---|
71 | aoFailureReasons = FailureReasonLogic(self._oDisp.getDb()).fetchForCombo()
|
---|
72 | if not aoFailureReasons:
|
---|
73 | from testmanager.webui.wuiadmin import WuiAdmin
|
---|
74 | raise WuiException('Please <a href="%s?%s=%s">add</a> some Failure Reasons first.'
|
---|
75 | % (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureReasonAdd));
|
---|
76 |
|
---|
77 | asTypes = self.getListOfItems(self.asTypes, oData.asTypes)
|
---|
78 | asOsArches = self.getListOfItems(self.asOsArches, oData.asOsArches)
|
---|
79 |
|
---|
80 | oForm.addIntRO (BuildBlacklistData.ksParam_idBlacklisting, oData.idBlacklisting, 'Blacklist item ID')
|
---|
81 | oForm.addTimestampRO(BuildBlacklistData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
|
---|
82 | oForm.addTimestampRO(BuildBlacklistData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
|
---|
83 | oForm.addIntRO (BuildBlacklistData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
|
---|
84 |
|
---|
85 | oForm.addComboBox (BuildBlacklistData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason',
|
---|
86 | aoFailureReasons)
|
---|
87 |
|
---|
88 | oForm.addText (BuildBlacklistData.ksParam_sProduct, oData.sProduct, 'Product')
|
---|
89 | oForm.addText (BuildBlacklistData.ksParam_sBranch, oData.sBranch, 'Branch')
|
---|
90 | oForm.addListOfTypes(BuildBlacklistData.ksParam_asTypes, asTypes, 'Build types')
|
---|
91 | oForm.addListOfOsArches(BuildBlacklistData.ksParam_asOsArches, asOsArches, 'Target architectures')
|
---|
92 | oForm.addInt (BuildBlacklistData.ksParam_iFirstRevision, oData.iFirstRevision, 'First revision')
|
---|
93 | oForm.addInt (BuildBlacklistData.ksParam_iLastRevision, oData.iLastRevision, 'Last revision (incl)')
|
---|
94 |
|
---|
95 | oForm.addSubmit();
|
---|
96 |
|
---|
97 | return True;
|
---|
98 |
|
---|
99 |
|
---|
100 | class WuiAdminListOfBlacklistItems(WuiListContentBase):
|
---|
101 | """
|
---|
102 | WUI Admin Build Blacklist Content Generator.
|
---|
103 | """
|
---|
104 |
|
---|
105 | def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp, aiSelectedSortColumns = None):
|
---|
106 | WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
|
---|
107 | sTitle = 'Build Blacklist', sId = 'buildsBlacklist',
|
---|
108 | fnDPrint = fnDPrint, oDisp = oDisp, aiSelectedSortColumns = aiSelectedSortColumns);
|
---|
109 |
|
---|
110 | self._asColumnHeaders = ['ID', 'Failure Reason',
|
---|
111 | 'Product', 'Branch', 'Type',
|
---|
112 | 'OS(es)', 'First Revision', 'Last Revision',
|
---|
113 | 'Actions' ]
|
---|
114 | self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"', 'align="center"',
|
---|
115 | 'align="center"', 'align="center"', 'align="center"', 'align="center"',
|
---|
116 | 'align="center"', 'align="center"', 'align="center"', 'align="center"',
|
---|
117 | 'align="center"' ]
|
---|
118 |
|
---|
119 | def _formatListEntry(self, iEntry):
|
---|
120 | from testmanager.webui.wuiadmin import WuiAdmin
|
---|
121 | oEntry = self._aoEntries[iEntry]
|
---|
122 |
|
---|
123 | sShortFailReason = FailureReasonLogic(TMDatabaseConnection()).getById(oEntry.idFailureReason).sShort
|
---|
124 |
|
---|
125 | aoActions = [
|
---|
126 | WuiTmLink('Details', WuiAdmin.ksScriptName,
|
---|
127 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistDetails,
|
---|
128 | BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting }),
|
---|
129 | ];
|
---|
130 | if self._oDisp is None or not self._oDisp.isReadOnlyUser():
|
---|
131 | aoActions += [
|
---|
132 | WuiTmLink('Edit', WuiAdmin.ksScriptName,
|
---|
133 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistEdit,
|
---|
134 | BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting }),
|
---|
135 | WuiTmLink('Clone', WuiAdmin.ksScriptName,
|
---|
136 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistClone,
|
---|
137 | BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting,
|
---|
138 | WuiAdmin.ksParamEffectiveDate: oEntry.tsEffective, }),
|
---|
139 | WuiTmLink('Remove', WuiAdmin.ksScriptName,
|
---|
140 | { WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistDoRemove,
|
---|
141 | BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting },
|
---|
142 | sConfirm = 'Are you sure you want to remove black list entry #%d?' % (oEntry.idBlacklisting,)),
|
---|
143 | ];
|
---|
144 |
|
---|
145 | return [ oEntry.idBlacklisting,
|
---|
146 | sShortFailReason,
|
---|
147 | oEntry.sProduct,
|
---|
148 | oEntry.sBranch,
|
---|
149 | oEntry.asTypes,
|
---|
150 | oEntry.asOsArches,
|
---|
151 | oEntry.iFirstRevision,
|
---|
152 | oEntry.iLastRevision,
|
---|
153 | aoActions
|
---|
154 | ];
|
---|