cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# $Id$
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncTest Manager WUI - Failure Reasons Web content generator.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__copyright__ = \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2012-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncavailable from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncGeneral Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThe contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncof the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncYou may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncterms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__version__ = "$Revision$"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Validation Kit imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.webui.wuibase import WuiException
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.core.failurereason import FailureReasonData
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.core.failurecategory import FailureCategoryLogic
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.core.db import TMDatabaseConnection
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass WuiAdminFailureReason(WuiFormContentBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WUI Failure Reason HTML content generator.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, oFailureReasonData, sMode, oDisp):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Prepare & initialize parent
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sMode == WuiFormContentBase.ksMode_Add:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sTitle = 'Add Failure Reason'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSubmitAction = oDisp.ksActionFailureReasonAdd
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sMode == WuiFormContentBase.ksMode_Edit:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sTitle = 'Edit Failure Reason'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSubmitAction = oDisp.ksActionFailureReasonEdit
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise WuiException('Unknown parameter')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WuiFormContentBase.__init__(self, oFailureReasonData, sMode, 'FailureReason', oDisp, sTitle,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSubmitAction = sSubmitAction, fEditable = False); ## @todo non-standard action names.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _populateForm(self, oForm, oData):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Construct an HTML form
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoFailureCategories = FailureCategoryLogic(TMDatabaseConnection()).getFailureCategoriesForCombo()
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(aoFailureCategories) == 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testmanager.webui.wuiadmin import WuiAdmin
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sExceptionMsg = 'Please <a href="%s?%s=%s">add</a> Failure Category first.' % \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategoryShowAdd)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise WuiException(sExceptionMsg)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addIntRO (FailureReasonData.ksParam_idFailureReason, oData.idFailureReason, 'Failure Reason ID')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addTimestampRO (FailureReasonData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addTimestampRO (FailureReasonData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addIntRO (FailureReasonData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addComboBox (FailureReasonData.ksParam_idFailureCategory, oData.idFailureCategory, 'Failure Category',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoFailureCategories)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addText (FailureReasonData.ksParam_sShort, oData.sShort, 'Short Description')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addText (FailureReasonData.ksParam_sFull, oData.sFull, 'Full Description')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addInt (FailureReasonData.ksParam_iTicket, oData.iTicket, 'Ticket Number')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addMultilineText(FailureReasonData.ksParam_asUrls, oData.asUrls, 'Other URLs to reports '
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'or discussions of the '
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'observed symptoms')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addSubmit()
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass WuiAdminFailureReasonList(WuiListContentBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WUI Admin Failure Reasons Content Generator.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, aoEntries, iPage, cItemsPerPage, tsEffective, fnDPrint, oDisp):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WuiListContentBase.__init__(self, aoEntries, iPage, cItemsPerPage, tsEffective,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sTitle = 'Failure Reasons', sId = 'failureReasons',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fnDPrint = fnDPrint, oDisp = oDisp);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._asColumnHeaders = ['ID', 'Category', 'Short Description',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'Full Description', 'Ticket', 'External References', 'Actions' ]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._asColumnAttribs = ['align="right"', 'align="center"', 'align="center"',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'align="center"',' align="center"', 'align="center"', 'align="center"']
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _formatListEntry(self, iEntry):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testmanager.webui.wuiadmin import WuiAdmin
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEntry = self._aoEntries[iEntry]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return [ oEntry.idFailureReason,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEntry.idFailureCategory,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEntry.sShort,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEntry.sFull,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEntry.iTicket,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEntry.asUrls,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync [ WuiTmLink('Modify', WuiAdmin.ksScriptName,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonShowEdit,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WuiTmLink('Remove', WuiAdmin.ksScriptName,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDel,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason },
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sConfirm = 'Are you sure you want to remove failure reason #%d?' % (oEntry.idFailureReason,)),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ] ]