wuiadminbuildblacklist.py revision cf22150eaeeb72431bf1cf65c309a431454fb22b
4b3769ce483ece06f60f983193712492b920144fJake Feasel# -*- coding: utf-8 -*-
4b3769ce483ece06f60f983193712492b920144fJake Feasel# $Id$
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel"""
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan MmillerTest Manager WUI - Build Blacklist.
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller"""
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel__copyright__ = \
4b3769ce483ece06f60f983193712492b920144fJake Feasel"""
4b3769ce483ece06f60f983193712492b920144fJake FeaselCopyright (C) 2012-2014 Oracle Corporation
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake FeaselThis file is part of VirtualBox Open Source Edition (OSE), as
4b3769ce483ece06f60f983193712492b920144fJake Feaselavailable from http://www.virtualbox.org. This file is free software;
4b3769ce483ece06f60f983193712492b920144fJake Feaselyou can redistribute it and/or modify it under the terms of the GNU
4b3769ce483ece06f60f983193712492b920144fJake FeaselGeneral Public License (GPL) as published by the Free Software
4b3769ce483ece06f60f983193712492b920144fJake FeaselFoundation, in version 2 as it comes in the "COPYING" file of the
4b3769ce483ece06f60f983193712492b920144fJake FeaselVirtualBox OSE distribution. VirtualBox OSE is distributed in the
4b3769ce483ece06f60f983193712492b920144fJake Feaselhope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake FeaselThe contents of this file may alternatively be used under the terms
4b3769ce483ece06f60f983193712492b920144fJake Feaselof the Common Development and Distribution License Version 1.0
4b3769ce483ece06f60f983193712492b920144fJake Feasel(CDDL) only, as it comes in the "COPYING.CDDL" file of the
4b3769ce483ece06f60f983193712492b920144fJake FeaselVirtualBox OSE distribution, in which case the provisions of the
4b3769ce483ece06f60f983193712492b920144fJake FeaselCDDL are applicable instead of those of the GPL.
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake FeaselYou may elect to license modified versions of this file under the
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmillerterms and conditions of either the GPL or the CDDL or both.
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller"""
4b3769ce483ece06f60f983193712492b920144fJake Feasel__version__ = "$Revision$"
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel# Validation Kit imports.
4b3769ce483ece06f60f983193712492b920144fJake Feaselfrom testmanager.webui.wuibase import WuiException
4b3769ce483ece06f60f983193712492b920144fJake Feaselfrom testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink
4b3769ce483ece06f60f983193712492b920144fJake Feaselfrom testmanager.core.buildblacklist import BuildBlacklistData
4b3769ce483ece06f60f983193712492b920144fJake Feaselfrom testmanager.core.failurereason import FailureReasonLogic
4b3769ce483ece06f60f983193712492b920144fJake Feaselfrom testmanager.core.db import TMDatabaseConnection
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmillerfrom testmanager.core import coreconsts
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmillerclass WuiAdminBuildBlacklist(WuiFormContentBase):
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller """
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller WUI Build Black List Form.
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller """
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller def __init__(self, oData, sMode, oDisp):
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller """
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller Prepare & initialize parent
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller """
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller
0b90cf39da4c7ba2b843ffd3512d84d009b5dff0Brendan Mmiller if sMode == WuiFormContentBase.ksMode_Add:
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller sTitle = 'Add Build Blacklist Entry'
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller elif sMode == WuiFormContentBase.ksMode_Edit:
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller sTitle = 'Edit Build Blacklist Entry'
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller else:
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller assert sMode == WuiFormContentBase.ksMode_Show;
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller sTitle = 'Build Black';
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller WuiFormContentBase.__init__(self, oData, sMode, 'BuildBlacklist', oDisp, sTitle);
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller #
4b3769ce483ece06f60f983193712492b920144fJake Feasel # Additional data.
4b3769ce483ece06f60f983193712492b920144fJake Feasel #
4b3769ce483ece06f60f983193712492b920144fJake Feasel self.asTypes = coreconsts.g_kasBuildTypesAll
4b3769ce483ece06f60f983193712492b920144fJake Feasel self.asOsArches = coreconsts.g_kasOsDotCpusAll
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel def _populateForm(self, oForm, oData):
4b3769ce483ece06f60f983193712492b920144fJake Feasel """
0c3f79f75f596c8d6700b2de830000f754bb28a9Phill Cunnington Construct an HTML form
4b3769ce483ece06f60f983193712492b920144fJake Feasel """
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel aoFailureReasons = FailureReasonLogic(self._oDisp.getDb()).fetchForCombo()
4b3769ce483ece06f60f983193712492b920144fJake Feasel if len(aoFailureReasons) == 0:
4b3769ce483ece06f60f983193712492b920144fJake Feasel from testmanager.webui.wuiadmin import WuiAdmin
4b3769ce483ece06f60f983193712492b920144fJake Feasel raise WuiException('Please <a href="%s?%s=%s">add</a> some Failure Reasons first.'
4b3769ce483ece06f60f983193712492b920144fJake Feasel % (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureReasonShowAdd));
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel asTypes = self.getListOfItems(self.asTypes, oData.asTypes)
4b3769ce483ece06f60f983193712492b920144fJake Feasel asOsArches = self.getListOfItems(self.asOsArches, oData.asOsArches)
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel oForm.addIntRO (BuildBlacklistData.ksParam_idBlacklisting, oData.idBlacklisting, 'Blacklist item ID')
b4260bb3e2303240ecf6c7e4e5639439c3f98889Brendan Mmiller oForm.addTimestampRO(BuildBlacklistData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
oForm.addTimestampRO(BuildBlacklistData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
oForm.addIntRO (BuildBlacklistData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
oForm.addComboBox (BuildBlacklistData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason',
aoFailureReasons)
oForm.addText (BuildBlacklistData.ksParam_sProduct, oData.sProduct, 'Product')
oForm.addText (BuildBlacklistData.ksParam_sBranch, oData.sBranch, 'Branch')
oForm.addListOfTypes(BuildBlacklistData.ksParam_asTypes, asTypes, 'Build types')
oForm.addListOfOsArches(BuildBlacklistData.ksParam_asOsArches, asOsArches, 'Target architectures')
oForm.addInt (BuildBlacklistData.ksParam_iFirstRevision, oData.iFirstRevision, 'First revision')
oForm.addInt (BuildBlacklistData.ksParam_iLastRevision, oData.iLastRevision, 'Last revision (incl)')
oForm.addSubmit();
return True;
class WuiAdminListOfBlacklistItems(WuiListContentBase):
"""
WUI Admin Build Blacklist Content Generator.
"""
def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
sTitle = 'Build Blacklist', sId = 'buildsBlacklist',
fnDPrint = fnDPrint, oDisp = oDisp);
self._asColumnHeaders = ['ID', 'Failure Reason',
'Product', 'Branch', 'Type',
'OS(es)', 'First Revision', 'Last Revision',
'Actions' ]
self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"', 'align="center"',
'align="center"', 'align="center"', 'align="center"', 'align="center"',
'align="center"', 'align="center"', 'align="center"', 'align="center"',
'align="center"' ]
def _formatListEntry(self, iEntry):
from testmanager.webui.wuiadmin import WuiAdmin
oEntry = self._aoEntries[iEntry]
sShortFailReason = \
FailureReasonLogic(TMDatabaseConnection()).getById(oEntry.idFailureReason).sShort
return [ oEntry.idBlacklisting,
sShortFailReason,
oEntry.sProduct,
oEntry.sBranch,
oEntry.asTypes,
oEntry.asOsArches,
oEntry.iFirstRevision,
oEntry.iLastRevision,
[ WuiTmLink('Details', WuiAdmin.ksScriptName,
{ WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistDetails,
BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting }),
WuiTmLink('Edit', WuiAdmin.ksScriptName,
{ WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistEdit,
BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting }),
WuiTmLink('Clone', WuiAdmin.ksScriptName,
{ WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistClone,
BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting,
WuiAdmin.ksParamEffectiveDate: oEntry.tsEffective, }),
WuiTmLink('Remove', WuiAdmin.ksScriptName,
{ WuiAdmin.ksParamAction: WuiAdmin.ksActionBuildBlacklistDoRemove,
BuildBlacklistData.ksParam_idBlacklisting: oEntry.idBlacklisting },
sConfirm = 'Are you sure you want to remove black list entry #%d?' % (oEntry.idBlacklisting,)),
]
];