cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# $Id$
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncTest Manager WUI - Failure Categories 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.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.core.failurecategory import FailureCategoryData
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.webui.wuibase import WuiException
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass WuiFailureCategory(WuiFormContentBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WUI Failure Category HTML content generator.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, oFailureCategoryData, sMode, oDisp):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Prepare & initialize parent
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sMode == WuiFormContentBase.ksMode_Add:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sTitle = 'Add Failure Category'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSubmitAction = oDisp.ksActionFailureCategoryAdd
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sMode == WuiFormContentBase.ksMode_Edit:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sTitle = 'Edit Failure Category'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSubmitAction = oDisp.ksActionFailureCategoryEdit
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise WuiException('Unknown parameter')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WuiFormContentBase.__init__(self, oFailureCategoryData, sMode, 'FailureCategory', 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 oForm.addIntRO (FailureCategoryData.ksParam_idFailureCategory, oData.idFailureCategory, 'Failure Category ID')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addTimestampRO(FailureCategoryData.ksParam_tsEffective, oData.tsEffective, 'Last changed')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addTimestampRO(FailureCategoryData.ksParam_tsExpire, oData.tsExpire, 'Expires (excl)')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addIntRO (FailureCategoryData.ksParam_uidAuthor, oData.uidAuthor, 'Changed by UID')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addText (FailureCategoryData.ksParam_sShort, oData.sShort, 'Short Description')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addText (FailureCategoryData.ksParam_sFull, oData.sFull, 'Full Description')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oForm.addSubmit()
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass WuiFailureCategoryList(WuiListContentBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WUI Admin Failure Category 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 Categories', sId = 'failureCategories',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fnDPrint = fnDPrint, oDisp = oDisp);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._asColumnHeaders = ['ID', 'Short Description', 'Full Description', 'Actions' ]
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._asColumnAttribs = ['align="right"', '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.idFailureCategory,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEntry.sShort,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEntry.sFull,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync [ WuiTmLink('Modify', WuiAdmin.ksScriptName,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryShowEdit,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync FailureCategoryData.ksParam_idFailureCategory: oEntry.idFailureCategory }),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WuiTmLink('Remove', WuiAdmin.ksScriptName,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryDel,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync FailureCategoryData.ksParam_idFailureCategory: oEntry.idFailureCategory },
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sConfirm = 'Do you really want to remove failure cateogry #%d?' % (oEntry.idFailureCategory,)),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ] ];